From 5a03b7c3146ef4f5638df5d4457ff70fc0318f72 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 1 Dec 2011 11:38:45 +0100 Subject: [PATCH] gdb: Update to 7.3.50.20110722. Needed for the debugging stuff that is coming with pakfire soon. --- gdb/gdb.nm | 53 +- gdb/gdbinit | 4 + .../gdb-6.3-attach-see-vdso-test.patch | 103 + .../gdb-6.3-bz140532-ppc-unwinding-test.patch | 310 + ...-6.3-bz202689-exec-from-pthread-test.patch | 98 + .../gdb-6.3-bz231832-obstack-2gb.patch | 201 + gdb/patches/gdb-6.3-focus-cmd-prev-test.patch | 28 + .../gdb-6.3-gcore-thread-20050204.patch | 25 + gdb/patches/gdb-6.3-gstack-20050411.patch | 241 + .../gdb-6.3-ia64-gcore-page0-20050421.patch | 20 + .../gdb-6.3-ia64-gcore-speedup-20050714.patch | 126 + ...gdb-6.3-ia64-info-frame-fix-20050725.patch | 107 + .../gdb-6.3-ia64-sigill-20051115.patch | 95 + ...gdb-6.3-ia64-sigtramp-frame-20050708.patch | 158 + ...b-6.3-inferior-notification-20050721.patch | 315 + .../gdb-6.3-inheritancetest-20050726.patch | 153 + .../gdb-6.3-mapping-zero-inode-test.patch | 229 + .../gdb-6.3-ppc64displaysymbol-20041124.patch | 24 + .../gdb-6.3-ppc64syscall-20040622.patch | 111 + .../gdb-6.3-ppcdotsolib-20041022.patch | 31 + gdb/patches/gdb-6.3-readnever-20050907.patch | 98 + .../gdb-6.3-rh-dummykfail-20041202.patch | 22 + .../gdb-6.3-rh-testlibunwind-20041202.patch | 103 + .../gdb-6.3-rh-testversion-20041202.patch | 19 + .../gdb-6.3-security-errata-20050610.patch | 243 + ...b-6.3-step-thread-exit-20050211-test.patch | 188 + .../gdb-6.3-test-dtorfix-20050121.patch | 262 + .../gdb-6.3-test-movedir-20050125.patch | 95 + gdb/patches/gdb-6.3-test-pie-20050107.patch | 2089 +++ gdb/patches/gdb-6.3-test-self-20050110.patch | 101 + ...b-6.3-threaded-watchpoints2-20050225.patch | 243 + gdb/patches/gdb-6.5-BEA-testsuite.patch | 938 + ...db-6.5-bz109921-DW_AT_decl_file-test.patch | 120 + ...337-resolve-tls-without-debuginfo-v2.patch | 143 + ...b-6.5-bz190810-gdbserver-arch-advice.patch | 28 + .../gdb-6.5-bz203661-emit-relocs.patch | 17 + .../gdb-6.5-bz216711-clone-is-outermost.patch | 133 + ...5-bz218379-ppc-solib-trampoline-test.patch | 91 + ...379-solib-trampoline-lookup-lock-fix.patch | 21 + ...5-bz243845-stale-testing-zombie-test.patch | 79 + .../gdb-6.5-gcore-buffer-limit-test.patch | 139 + .../gdb-6.5-ia64-libunwind-leak-test.patch | 120 + ...gdb-6.5-last-address-space-byte-test.patch | 56 + .../gdb-6.5-missed-trap-on-step-test.patch | 83 + ...db-6.5-readline-long-line-crash-test.patch | 136 + .../gdb-6.5-section-num-fixup-test.patch | 111 + gdb/patches/gdb-6.5-sharedlibrary-path.patch | 171 + .../gdb-6.6-buildid-locate-core-as-arg.patch | 196 + gdb/patches/gdb-6.6-buildid-locate.patch | 1034 ++ ...-6.6-bz229517-gcore-without-terminal.patch | 171 + ...6.6-bz230000-power6-disassembly-test.patch | 83 + .../gdb-6.6-bz235197-fork-detach-info.patch | 121 + ....6-bz237572-ppc-atomic-sequence-test.patch | 270 + ....6-scheduler_locking-step-is-default.patch | 54 + ...heduler_locking-step-sw-watchpoints2.patch | 205 + gdb/patches/gdb-6.6-step-thread-exit.patch | 60 + gdb/patches/gdb-6.6-testsuite-timeouts.patch | 42 + gdb/patches/gdb-6.6-threads-static-test.patch | 23 + ...-bz426600-DW_TAG_interface_type-test.patch | 703 + gdb/patches/gdb-6.7-charsign-test.patch | 118 + ...-6.7-ppc-clobbered-registers-O2-test.patch | 96 + .../gdb-6.7-testsuite-stable-results.patch | 108 + ...-6.8-attach-signalled-detach-stopped.patch | 183 + .../gdb-6.8-bz254229-gcore-prpsinfo.patch | 289 + ...db-6.8-bz436037-reg-no-longer-active.patch | 25 + .../gdb-6.8-bz442765-threaded-exec-test.patch | 173 + .../gdb-6.8-bz457187-largefile-test.patch | 105 + ....8-bz466901-backtrace-full-prelinked.patch | 473 + gdb/patches/gdb-6.8-quit-never-aborts.patch | 72 + ...gdb-6.8-sparc64-silence-memcpy-check.patch | 11 + gdb/patches/gdb-6.8-tui-singlebinary.patch | 24 + ...gdb-6.8-watchpoint-conditionals-test.patch | 78 + ...add-workaround-to-broken-debug-files.patch | 51 + .../gdb-archer-next-over-throw-cxx-exec.patch | 85 + .../gdb-archer-pie-addons-keep-disabled.patch | 83 + gdb/patches/gdb-archer.patch | 15142 ++++++++++++++++ .../gdb-bz533176-fortran-omp-step.patch | 121 + .../gdb-bz541866-rwatch-before-run.patch | 151 + ...gdb-bz562763-pretty-print-2d-vectors.patch | 398 + gdb/patches/gdb-bz568248-oom-is-error.patch | 68 + .../gdb-bz592031-siginfo-lost-4of5.patch | 992 + .../gdb-bz592031-siginfo-lost-5of5.patch | 141 + gdb/patches/gdb-bz601887-dwarf4-rh-test.patch | 240 + gdb/patches/gdb-bz623749-gcore-relro.patch | 169 + gdb/patches/gdb-bz634108-solib_address.patch | 29 + gdb/patches/gdb-ccache-workaround.patch | 17 + gdb/patches/gdb-core-open-vdso-warning.patch | 85 + .../gdb-dlopen-skip_inline_frames-perf.patch | 90 + gdb/patches/gdb-dlopen-stap-probe-test.patch | 408 + gdb/patches/gdb-dlopen-stap-probe.patch | 358 + .../gdb-follow-child-stale-parent.patch | 27 + gdb/patches/gdb-fortran-common-reduce.patch | 507 + gdb/patches/gdb-fortran-common.patch | 585 + gdb/patches/gdb-gcc46-stdarg-prologue.patch | 655 + gdb/patches/gdb-gdb-add-index-script.patch | 118 + gdb/patches/gdb-glibc-vdso-workaround.patch | 30 + gdb/patches/gdb-implptr-64bit-1of2.patch | 110 + gdb/patches/gdb-implptr-64bit-2of2.patch | 411 + gdb/patches/gdb-lineno-makeup-test.patch | 151 + .../gdb-moribund-utrace-workaround.patch | 16 + .../gdb-optimized-out-internal-error.patch | 302 + gdb/patches/gdb-ppc-power7-test.patch | 295 + gdb/patches/gdb-runtest-pie-override.patch | 40 + ...ltaneous-step-resume-breakpoint-test.patch | 150 + gdb/patches/gdb-test-bt-cfi-without-die.patch | 220 + gdb/patches/gdb-test-dw2-aranges.patch | 214 + .../gdb-test-expr-cumulative-archer.patch | 207 + gdb/patches/gdb-test-pid0-core.patch | 80 + gdb/patches/gdb-tui-strip-stepi.patch | 73 + gdb/patches/gdb-unused-revert.patch | 44 + gdb/patches/gdb-upstream.patch | 1485 ++ gdb/patches/gdb-vla-frame-set.patch | 91 + .../gdb-x86_64-i386-syscall-restart.patch | 121 + 113 files changed, 37550 insertions(+), 8 deletions(-) create mode 100644 gdb/gdbinit create mode 100644 gdb/patches/gdb-6.3-attach-see-vdso-test.patch create mode 100644 gdb/patches/gdb-6.3-bz140532-ppc-unwinding-test.patch create mode 100644 gdb/patches/gdb-6.3-bz202689-exec-from-pthread-test.patch create mode 100644 gdb/patches/gdb-6.3-bz231832-obstack-2gb.patch create mode 100644 gdb/patches/gdb-6.3-focus-cmd-prev-test.patch create mode 100644 gdb/patches/gdb-6.3-gcore-thread-20050204.patch create mode 100644 gdb/patches/gdb-6.3-gstack-20050411.patch create mode 100644 gdb/patches/gdb-6.3-ia64-gcore-page0-20050421.patch create mode 100644 gdb/patches/gdb-6.3-ia64-gcore-speedup-20050714.patch create mode 100644 gdb/patches/gdb-6.3-ia64-info-frame-fix-20050725.patch create mode 100644 gdb/patches/gdb-6.3-ia64-sigill-20051115.patch create mode 100644 gdb/patches/gdb-6.3-ia64-sigtramp-frame-20050708.patch create mode 100644 gdb/patches/gdb-6.3-inferior-notification-20050721.patch create mode 100644 gdb/patches/gdb-6.3-inheritancetest-20050726.patch create mode 100644 gdb/patches/gdb-6.3-mapping-zero-inode-test.patch create mode 100644 gdb/patches/gdb-6.3-ppc64displaysymbol-20041124.patch create mode 100644 gdb/patches/gdb-6.3-ppc64syscall-20040622.patch create mode 100644 gdb/patches/gdb-6.3-ppcdotsolib-20041022.patch create mode 100644 gdb/patches/gdb-6.3-readnever-20050907.patch create mode 100644 gdb/patches/gdb-6.3-rh-dummykfail-20041202.patch create mode 100644 gdb/patches/gdb-6.3-rh-testlibunwind-20041202.patch create mode 100644 gdb/patches/gdb-6.3-rh-testversion-20041202.patch create mode 100644 gdb/patches/gdb-6.3-security-errata-20050610.patch create mode 100644 gdb/patches/gdb-6.3-step-thread-exit-20050211-test.patch create mode 100644 gdb/patches/gdb-6.3-test-dtorfix-20050121.patch create mode 100644 gdb/patches/gdb-6.3-test-movedir-20050125.patch create mode 100644 gdb/patches/gdb-6.3-test-pie-20050107.patch create mode 100644 gdb/patches/gdb-6.3-test-self-20050110.patch create mode 100644 gdb/patches/gdb-6.3-threaded-watchpoints2-20050225.patch create mode 100644 gdb/patches/gdb-6.5-BEA-testsuite.patch create mode 100644 gdb/patches/gdb-6.5-bz109921-DW_AT_decl_file-test.patch create mode 100644 gdb/patches/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch create mode 100644 gdb/patches/gdb-6.5-bz190810-gdbserver-arch-advice.patch create mode 100644 gdb/patches/gdb-6.5-bz203661-emit-relocs.patch create mode 100644 gdb/patches/gdb-6.5-bz216711-clone-is-outermost.patch create mode 100644 gdb/patches/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch create mode 100644 gdb/patches/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch create mode 100644 gdb/patches/gdb-6.5-bz243845-stale-testing-zombie-test.patch create mode 100644 gdb/patches/gdb-6.5-gcore-buffer-limit-test.patch create mode 100644 gdb/patches/gdb-6.5-ia64-libunwind-leak-test.patch create mode 100644 gdb/patches/gdb-6.5-last-address-space-byte-test.patch create mode 100644 gdb/patches/gdb-6.5-missed-trap-on-step-test.patch create mode 100644 gdb/patches/gdb-6.5-readline-long-line-crash-test.patch create mode 100644 gdb/patches/gdb-6.5-section-num-fixup-test.patch create mode 100644 gdb/patches/gdb-6.5-sharedlibrary-path.patch create mode 100644 gdb/patches/gdb-6.6-buildid-locate-core-as-arg.patch create mode 100644 gdb/patches/gdb-6.6-buildid-locate.patch create mode 100644 gdb/patches/gdb-6.6-bz229517-gcore-without-terminal.patch create mode 100644 gdb/patches/gdb-6.6-bz230000-power6-disassembly-test.patch create mode 100644 gdb/patches/gdb-6.6-bz235197-fork-detach-info.patch create mode 100644 gdb/patches/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch create mode 100644 gdb/patches/gdb-6.6-scheduler_locking-step-is-default.patch create mode 100644 gdb/patches/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch create mode 100644 gdb/patches/gdb-6.6-step-thread-exit.patch create mode 100644 gdb/patches/gdb-6.6-testsuite-timeouts.patch create mode 100644 gdb/patches/gdb-6.6-threads-static-test.patch create mode 100644 gdb/patches/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch create mode 100644 gdb/patches/gdb-6.7-charsign-test.patch create mode 100644 gdb/patches/gdb-6.7-ppc-clobbered-registers-O2-test.patch create mode 100644 gdb/patches/gdb-6.7-testsuite-stable-results.patch create mode 100644 gdb/patches/gdb-6.8-attach-signalled-detach-stopped.patch create mode 100644 gdb/patches/gdb-6.8-bz254229-gcore-prpsinfo.patch create mode 100644 gdb/patches/gdb-6.8-bz436037-reg-no-longer-active.patch create mode 100644 gdb/patches/gdb-6.8-bz442765-threaded-exec-test.patch create mode 100644 gdb/patches/gdb-6.8-bz457187-largefile-test.patch create mode 100644 gdb/patches/gdb-6.8-bz466901-backtrace-full-prelinked.patch create mode 100644 gdb/patches/gdb-6.8-quit-never-aborts.patch create mode 100644 gdb/patches/gdb-6.8-sparc64-silence-memcpy-check.patch create mode 100644 gdb/patches/gdb-6.8-tui-singlebinary.patch create mode 100644 gdb/patches/gdb-6.8-watchpoint-conditionals-test.patch create mode 100644 gdb/patches/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch create mode 100644 gdb/patches/gdb-archer-next-over-throw-cxx-exec.patch create mode 100644 gdb/patches/gdb-archer-pie-addons-keep-disabled.patch create mode 100644 gdb/patches/gdb-archer.patch create mode 100644 gdb/patches/gdb-bz533176-fortran-omp-step.patch create mode 100644 gdb/patches/gdb-bz541866-rwatch-before-run.patch create mode 100644 gdb/patches/gdb-bz562763-pretty-print-2d-vectors.patch create mode 100644 gdb/patches/gdb-bz568248-oom-is-error.patch create mode 100644 gdb/patches/gdb-bz592031-siginfo-lost-4of5.patch create mode 100644 gdb/patches/gdb-bz592031-siginfo-lost-5of5.patch create mode 100644 gdb/patches/gdb-bz601887-dwarf4-rh-test.patch create mode 100644 gdb/patches/gdb-bz623749-gcore-relro.patch create mode 100644 gdb/patches/gdb-bz634108-solib_address.patch create mode 100644 gdb/patches/gdb-ccache-workaround.patch create mode 100644 gdb/patches/gdb-core-open-vdso-warning.patch create mode 100644 gdb/patches/gdb-dlopen-skip_inline_frames-perf.patch create mode 100644 gdb/patches/gdb-dlopen-stap-probe-test.patch create mode 100644 gdb/patches/gdb-dlopen-stap-probe.patch create mode 100644 gdb/patches/gdb-follow-child-stale-parent.patch create mode 100644 gdb/patches/gdb-fortran-common-reduce.patch create mode 100644 gdb/patches/gdb-fortran-common.patch create mode 100644 gdb/patches/gdb-gcc46-stdarg-prologue.patch create mode 100644 gdb/patches/gdb-gdb-add-index-script.patch create mode 100644 gdb/patches/gdb-glibc-vdso-workaround.patch create mode 100644 gdb/patches/gdb-implptr-64bit-1of2.patch create mode 100644 gdb/patches/gdb-implptr-64bit-2of2.patch create mode 100644 gdb/patches/gdb-lineno-makeup-test.patch create mode 100644 gdb/patches/gdb-moribund-utrace-workaround.patch create mode 100644 gdb/patches/gdb-optimized-out-internal-error.patch create mode 100644 gdb/patches/gdb-ppc-power7-test.patch create mode 100644 gdb/patches/gdb-runtest-pie-override.patch create mode 100644 gdb/patches/gdb-simultaneous-step-resume-breakpoint-test.patch create mode 100644 gdb/patches/gdb-test-bt-cfi-without-die.patch create mode 100644 gdb/patches/gdb-test-dw2-aranges.patch create mode 100644 gdb/patches/gdb-test-expr-cumulative-archer.patch create mode 100644 gdb/patches/gdb-test-pid0-core.patch create mode 100644 gdb/patches/gdb-tui-strip-stepi.patch create mode 100644 gdb/patches/gdb-unused-revert.patch create mode 100644 gdb/patches/gdb-upstream.patch create mode 100644 gdb/patches/gdb-vla-frame-set.patch create mode 100644 gdb/patches/gdb-x86_64-i386-syscall-restart.patch diff --git a/gdb/gdb.nm b/gdb/gdb.nm index 7c377584c..c1f72400c 100644 --- a/gdb/gdb.nm +++ b/gdb/gdb.nm @@ -4,7 +4,7 @@ ############################################################################### name = gdb -version = 7.3.1 +version = 7.3.50.20110722 release = 1 groups = Development/Debuggers @@ -18,26 +18,63 @@ description and printing their data. end -source_dl = ftp://ftp.gnu.org/gnu/gdb/ -sources = %{thisapp}.tar.gz +#source_dl = ftp://ftp.gnu.org/gnu/gdb/ +source_dl = ftp://sourceware.org/pub/gdb/snapshots/current/ +sources = %{thisapp}.tar.bz2 build requires + bison + expat-devel ncurses-devel - readline-devel + texinfo zlib-devel end configure_options += \ + --with-system-gdbinit=/etc/gdbinit \ --mandir=/usr/share/man \ - --disable-werror + --enable-gdb-build-warnings=,-Wno-unused \ + --with-separate-debug-dir=/usr/lib/debug \ + --disable-sim \ + --disable-rpath \ + --without-system-readline \ + --disable-werror \ + --with-expat \ + --without-libexpat-prefix \ + --enable-tui \ + --with-python \ + --without-rpm \ + --without-libunwind \ + --enable-64-bit-bfd \ + %{DISTRO_MACHINE} + + prepare_cmds + echo "%{DISTRO_NAME} (%{thisver})" > gdb/version.in + end + + # Testsuite does not succeed. Needs to be fixed eventually. + #test + # make check + #end + + install_cmds + # Install gcore script. + cp -v gdb/gdb_gcore.sh %{BUILDROOT}/usr/bin/gcore + chmod -v 755 %{BUILDROOT}/usr/bin/gcore + + # Remove gdb/gdbtui binaries duplicity. + ln -svf gdb %{BUILDROOT}/usr/bin/gdbtui + ln -svf gdb.1 %{BUILDROOT}/usr/share/man/man1/gdbtui.1 + + mkdir -pv %{BUILDROOT}/etc/gdbinit.d + cp -vf %{DIR_SOURCE}/gdbinit %{BUILDROOT}/etc/gdbinit + end end packages package %{name} - requires = python - end - + package %{name}-devel template DEVEL end diff --git a/gdb/gdbinit b/gdb/gdbinit new file mode 100644 index 000000000..f1f45b017 --- /dev/null +++ b/gdb/gdbinit @@ -0,0 +1,4 @@ +# System-wide GDB initialization file. + +# FIXME: provide a wildcard. +source /etc/gdbinit.d/gdb-heap.py diff --git a/gdb/patches/gdb-6.3-attach-see-vdso-test.patch b/gdb/patches/gdb-6.3-attach-see-vdso-test.patch new file mode 100644 index 000000000..a0923f8b4 --- /dev/null +++ b/gdb/patches/gdb-6.3-attach-see-vdso-test.patch @@ -0,0 +1,103 @@ +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/attach-see-vdso.c 6 Jul 2007 14:14:44 -0000 +@@ -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 ++ ++int main () ++{ ++ pause (); ++ return 1; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/attach-see-vdso.exp 6 Jul 2007 14:14:44 -0000 +@@ -0,0 +1,72 @@ ++# 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 . ++ ++# This test only works on Linux ++if { ![istarget "*-*-linux-gnu*"] } { ++ return 0 ++} ++ ++set testfile "attach-see-vdso" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${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}" diff --git a/gdb/patches/gdb-6.3-bz140532-ppc-unwinding-test.patch b/gdb/patches/gdb-6.3-bz140532-ppc-unwinding-test.patch new file mode 100644 index 000000000..6494cdea5 --- /dev/null +++ b/gdb/patches/gdb-6.3-bz140532-ppc-unwinding-test.patch @@ -0,0 +1,310 @@ +diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S +--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S 2007-08-02 13:23:10.000000000 -0400 +@@ -0,0 +1,78 @@ ++/* 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. */ ++ ++ .section ".text" ++ .align 2 ++ .globl func0 ++ .type func0, @function ++func0: ++ stwu 1,-16(1) ++ mflr 0 ++ stw 31,12(1) ++ stw 0,20(1) ++ mr 31,1 ++ bl abort ++ .size func0, .-func0 ++ .align 2 ++ .globl func1 ++ .type func1, @function ++func1: ++ stwu 1,-16(1) ++ mflr 0 ++/* 20 = BO = branch always ++ 31 = BI = CR bit (ignored) */ ++ bcl 20,31,.Lpie ++.Lpie: stw 31,12(1) ++ stw 0,20(1) ++ mr 31,1 ++ bl func0 ++ mr 0,3 ++ lis 9,var@ha ++ lwz 9,var@l(9) ++ add 0,0,9 ++ mr 3,0 ++ lwz 11,0(1) ++ lwz 0,4(11) ++ mtlr 0 ++ lwz 31,-4(11) ++ mr 1,11 ++ blr ++ .size func1, .-func1 ++ .section .note.GNU-stack,"",@progbits ++ .ident "GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)" ++ ++/* Original source file: ++ ++#include ++ ++extern volatile int var; ++ ++int func0 (void) __attribute__((__noinline__)); ++int func0 (void) ++{ ++ abort (); ++ return var; ++} ++ ++int func1 (void) __attribute__((__noinline__)); ++int func1 (void) ++{ ++ return func0 () + var; ++} ++ ++*/ +diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S +--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S 2007-08-02 14:28:56.000000000 -0400 +@@ -0,0 +1,98 @@ ++/* 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. */ ++ ++ .section ".toc","aw" ++ .section ".text" ++ .align 2 ++ .globl func0 ++ .section ".opd","aw" ++ .align 3 ++func0: ++ .quad .L.func0,.TOC.@tocbase ++ .previous ++ .type func0, @function ++.L.func0: ++ mflr 0 ++ std 31,-8(1) ++ std 0,16(1) ++ stdu 1,-128(1) ++ mr 31,1 ++ bl abort ++ nop ++ .long 0 ++ .byte 0,0,0,1,128,1,0,1 ++ .size func0,.-.L.func0 ++ .section ".toc","aw" ++.LC1: ++ .tc var[TC],var ++ .section ".text" ++ .align 2 ++ .globl func1 ++ .section ".opd","aw" ++ .align 3 ++func1: ++ .quad .L.func1,.TOC.@tocbase ++ .previous ++ .type func1, @function ++.L.func1: ++ mflr 0 ++/* 20 = BO = branch always ++ 31 = BI = CR bit (ignored) */ ++ bcl 20,31,.Lpie ++.Lpie: std 31,-8(1) ++ std 0,16(1) ++ stdu 1,-128(1) ++ mr 31,1 ++ bl func0 ++ mr 11,3 ++ ld 9,.LC1@toc(2) ++ lwz 0,0(9) ++ add 0,11,0 ++ extsw 0,0 ++ mr 3,0 ++ ld 1,0(1) ++ ld 0,16(1) ++ mtlr 0 ++ ld 31,-8(1) ++ blr ++ .long 0 ++ .byte 0,0,0,1,128,1,0,1 ++ .size func1,.-.L.func1 ++ .section .note.GNU-stack,"",@progbits ++ .ident "GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)" ++ ++/* Original source file: ++ ++#include ++ ++extern volatile int var; ++ ++int func0 (void) __attribute__((__noinline__)); ++int func0 (void) ++{ ++ abort (); ++ return var; ++} ++ ++int func1 (void) __attribute__((__noinline__)); ++int func1 (void) ++{ ++ return func0 () + var; ++} ++ ++*/ +diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c +--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c 2007-08-02 13:25:10.000000000 -0400 +@@ -0,0 +1,29 @@ ++/* 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. */ ++ ++/* Force `-fpie' double jump bl->blrl. */ ++/* No longer used. */ ++volatile int var; ++ ++extern int func1 (void); ++ ++int main (void) ++{ ++ func1 (); ++ return 0; ++} +diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp +--- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp 2007-08-02 14:21:29.000000000 -0400 +@@ -0,0 +1,72 @@ ++# Copyright 2006, 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. ++ ++# Test unwinding fixes of the PPC platform, specifically on the coping with BCL ++# jump of the PIE code. ++ ++if ![istarget "powerpc*-*-linux*"] then { ++ verbose "Skipping powerpc-linux prologue tests." ++ return ++} ++ ++set testfile "powerpc-bcl-prologue" ++set srcfile1 ${testfile}.c ++set flags "debug" ++if [istarget "powerpc-*"] then { ++ set srcfile2 ${testfile}-asm32.S ++ set flags "$flags additional_flags=-m32" ++} elseif [istarget "powerpc64-*"] then { ++ set srcfile2 ${testfile}-asm64.S ++ set flags "$flags additional_flags=-m64" ++} else { ++ fail "powerpc arch test" ++ return ++} ++set objfile2 ${objdir}/${subdir}/${testfile}-asm.o ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2}" ${binfile} executable $flags] != ""} { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# We should stop in abort(3). ++ ++gdb_run_cmd ++ ++gdb_test_multiple {} "continue to abort()" { ++ -re ".*Program received signal SIGABRT,.*$gdb_prompt $" { ++ pass "continue to abort()" ++ } ++} ++ ++# Check backtrace: ++# #3 0x0804835f in func0 () ++# #4 0x0804836a in func1 () ++# #5 0x0804838c in main () ++# (gdb) ++# `\\.?' prefixes are needed for ppc64 without `debug' (another bug). ++ ++set test "matching unwind" ++gdb_test_multiple "backtrace" $test { ++ -re "\r\n#\[0-9\]\[^\r\n\]* in \\.?func0 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?func1 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?main \\(\[^\r\n\]*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} + +Fixup the testcase for ppc64 biarch GDB. + +--- ./gdb/testsuite/gdb.arch/powerpc-prologue.exp 2008-01-13 13:32:19.000000000 +0100 ++++ ./gdb/testsuite/gdb.arch/powerpc-prologue.exp 2008-01-02 00:04:10.000000000 +0100 +@@ -17,8 +17,9 @@ + # Test PowerPC prologue analyzer. + + # Do not run on AIX (where we won't be able to build the tests without +-# some surgery) or on PowerPC64 (ditto, dot symbols). +-if {[istarget *-*-aix*] || ![istarget "powerpc-*-*"]} then { ++# some surgery). PowerPC64 target would break due to dot symbols but we build ++# there PowerPC32 inferior. ++if {[istarget *-*-aix*] || ![istarget "powerpc*-*-*"]} then { + verbose "Skipping PowerPC prologue tests." + return + } diff --git a/gdb/patches/gdb-6.3-bz202689-exec-from-pthread-test.patch b/gdb/patches/gdb-6.3-bz202689-exec-from-pthread-test.patch new file mode 100644 index 000000000..91dc69ae7 --- /dev/null +++ b/gdb/patches/gdb-6.3-bz202689-exec-from-pthread-test.patch @@ -0,0 +1,98 @@ +2007-01-17 Jan Kratochvil + + * gdb.threads/threaded-exec.exp, gdb.threads/threaded-exec.c: New files. + + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threaded-exec.c 17 Jan 2007 23:10:22 -0000 +@@ -0,0 +1,46 @@ ++/* 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 ++#include ++#include ++#include ++#include ++ ++ ++static void * ++threader (void *arg) ++{ ++ return NULL; ++} ++ ++int ++main (void) ++{ ++ pthread_t t1; ++ int i; ++ ++ i = pthread_create (&t1, NULL, threader, (void *) NULL); ++ assert (i == 0); ++ i = pthread_join (t1, NULL); ++ assert (i == 0); ++ ++ execl ("/bin/true", "/bin/true", NULL); ++ abort (); ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threaded-exec.exp 17 Jan 2007 23:10:22 -0000 +@@ -0,0 +1,41 @@ ++# threaded-exec.exp -- Check reset of the tracked threads on exec*(2) ++# Copyright (C) 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 ++ ++set testfile threaded-exec ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++gdb_load ${binfile} ++ ++gdb_run_cmd ++ ++gdb_test_multiple {} "Program exited" { ++ -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" { ++ pass "Program exited" ++ } ++} diff --git a/gdb/patches/gdb-6.3-bz231832-obstack-2gb.patch b/gdb/patches/gdb-6.3-bz231832-obstack-2gb.patch new file mode 100644 index 000000000..38742cd08 --- /dev/null +++ b/gdb/patches/gdb-6.3-bz231832-obstack-2gb.patch @@ -0,0 +1,201 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=231832 + + +Index: gdb-7.2.50.20101116/gdb/symmisc.c +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/symmisc.c 2010-11-16 07:53:59.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/symmisc.c 2010-11-16 08:03:08.000000000 +0100 +@@ -186,8 +186,8 @@ print_objfile_statistics (void) + if (OBJSTAT (objfile, sz_strtab) > 0) + printf_filtered (_(" Space used by a.out string tables: %d\n"), + OBJSTAT (objfile, sz_strtab)); +- printf_filtered (_(" Total memory used for objfile obstack: %d\n"), +- obstack_memory_used (&objfile->objfile_obstack)); ++ printf_filtered (_(" Total memory used for objfile obstack: %ld\n"), ++ (long) obstack_memory_used (&objfile->objfile_obstack)); + printf_filtered (_(" Total memory used for psymbol cache: %d\n"), + bcache_memory_used (psymbol_bcache_get_bcache + (objfile->psymbol_cache))); +Index: gdb-7.2.50.20101116/include/obstack.h +=================================================================== +--- gdb-7.2.50.20101116.orig/include/obstack.h 2008-10-21 01:03:31.000000000 +0200 ++++ gdb-7.2.50.20101116/include/obstack.h 2010-11-16 08:02:37.000000000 +0100 +@@ -188,31 +188,31 @@ struct obstack /* control current objec + + /* Declare the external functions we use; they are in obstack.c. */ + +-extern void _obstack_newchunk (struct obstack *, int); ++extern void _obstack_newchunk (struct obstack *, PTR_INT_TYPE); + extern void _obstack_free (struct obstack *, void *); +-extern int _obstack_begin (struct obstack *, int, int, ++extern int _obstack_begin (struct obstack *, PTR_INT_TYPE, int, + void *(*) (long), void (*) (void *)); +-extern int _obstack_begin_1 (struct obstack *, int, int, ++extern int _obstack_begin_1 (struct obstack *, PTR_INT_TYPE, int, + void *(*) (void *, long), + void (*) (void *, void *), void *); +-extern int _obstack_memory_used (struct obstack *); ++extern PTR_INT_TYPE _obstack_memory_used (struct obstack *); + + /* Do the function-declarations after the structs + but before defining the macros. */ + + void obstack_init (struct obstack *obstack); + +-void * obstack_alloc (struct obstack *obstack, int size); ++void * obstack_alloc (struct obstack *obstack, PTR_INT_TYPE size); + +-void * obstack_copy (struct obstack *obstack, void *address, int size); +-void * obstack_copy0 (struct obstack *obstack, void *address, int size); ++void * obstack_copy (struct obstack *obstack, void *address, PTR_INT_TYPE size); ++void * obstack_copy0 (struct obstack *obstack, void *address, PTR_INT_TYPE size); + + void obstack_free (struct obstack *obstack, void *block); + +-void obstack_blank (struct obstack *obstack, int size); ++void obstack_blank (struct obstack *obstack, PTR_INT_TYPE size); + +-void obstack_grow (struct obstack *obstack, void *data, int size); +-void obstack_grow0 (struct obstack *obstack, void *data, int size); ++void obstack_grow (struct obstack *obstack, void *data, PTR_INT_TYPE size); ++void obstack_grow0 (struct obstack *obstack, void *data, PTR_INT_TYPE size); + + void obstack_1grow (struct obstack *obstack, int data_char); + void obstack_ptr_grow (struct obstack *obstack, void *data); +@@ -220,20 +220,20 @@ void obstack_int_grow (struct obstack *o + + void * obstack_finish (struct obstack *obstack); + +-int obstack_object_size (struct obstack *obstack); ++PTR_INT_TYPE obstack_object_size (struct obstack *obstack); + +-int obstack_room (struct obstack *obstack); +-void obstack_make_room (struct obstack *obstack, int size); ++PTR_INT_TYPE obstack_room (struct obstack *obstack); ++void obstack_make_room (struct obstack *obstack, PTR_INT_TYPE size); + void obstack_1grow_fast (struct obstack *obstack, int data_char); + void obstack_ptr_grow_fast (struct obstack *obstack, void *data); + void obstack_int_grow_fast (struct obstack *obstack, int data); +-void obstack_blank_fast (struct obstack *obstack, int size); ++void obstack_blank_fast (struct obstack *obstack, PTR_INT_TYPE size); + + void * obstack_base (struct obstack *obstack); + void * obstack_next_free (struct obstack *obstack); + int obstack_alignment_mask (struct obstack *obstack); +-int obstack_chunk_size (struct obstack *obstack); +-int obstack_memory_used (struct obstack *obstack); ++size_t obstack_chunk_size (struct obstack *obstack); ++size_t obstack_memory_used (struct obstack *obstack); + + /* Error handler called when `obstack_chunk_alloc' failed to allocate + more memory. This can be set to a user defined function. The +@@ -318,7 +318,7 @@ extern int obstack_exit_failure; + # define obstack_make_room(OBSTACK,length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ +- int __len = (length); \ ++ PTR_INT_TYPE __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + (void) 0; }) +@@ -331,7 +331,7 @@ __extension__ \ + # define obstack_grow(OBSTACK,where,length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ +- int __len = (length); \ ++ PTR_INT_TYPE __len = (length); \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + _obstack_memcpy (__o->next_free, (where), __len); \ +@@ -341,7 +341,7 @@ __extension__ \ + # define obstack_grow0(OBSTACK,where,length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ +- int __len = (length); \ ++ PTR_INT_TYPE __len = (length); \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + _obstack_memcpy (__o->next_free, (where), __len); \ +@@ -392,7 +392,7 @@ __extension__ \ + # define obstack_blank(OBSTACK,length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ +- int __len = (length); \ ++ PTR_INT_TYPE __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + obstack_blank_fast (__o, __len); \ +@@ -532,7 +532,7 @@ __extension__ \ + # define obstack_free(h,obj) \ + ( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ +- ? (int) ((h)->next_free = (h)->object_base \ ++ ? (PTR_INT_TYPE) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) + +Index: gdb-7.2.50.20101116/libiberty/obstack.c +=================================================================== +--- gdb-7.2.50.20101116.orig/libiberty/obstack.c 2005-05-10 17:33:33.000000000 +0200 ++++ gdb-7.2.50.20101116/libiberty/obstack.c 2010-11-16 08:02:37.000000000 +0100 +@@ -44,9 +44,11 @@ + #if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 + #include + #if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION ++#if 0 /* 64-bit obstack is not compatible with any glibc implementation. */ + #define ELIDE_CODE + #endif + #endif ++#endif + + + #ifndef ELIDE_CODE +@@ -139,7 +141,7 @@ struct obstack *_obstack; + free up some memory, then call this again. */ + + int +-_obstack_begin (struct obstack *h, int size, int alignment, ++_obstack_begin (struct obstack *h, PTR_INT_TYPE size, int alignment, + POINTER (*chunkfun) (long), void (*freefun) (void *)) + { + register struct _obstack_chunk *chunk; /* points to new chunk */ +@@ -183,7 +185,7 @@ _obstack_begin (struct obstack *h, int s + } + + int +-_obstack_begin_1 (struct obstack *h, int size, int alignment, ++_obstack_begin_1 (struct obstack *h, PTR_INT_TYPE size, int alignment, + POINTER (*chunkfun) (POINTER, long), + void (*freefun) (POINTER, POINTER), POINTER arg) + { +@@ -235,7 +237,7 @@ _obstack_begin_1 (struct obstack *h, int + to the beginning of the new one. */ + + void +-_obstack_newchunk (struct obstack *h, int length) ++_obstack_newchunk (struct obstack *h, PTR_INT_TYPE length) + { + register struct _obstack_chunk *old_chunk = h->chunk; + register struct _obstack_chunk *new_chunk; +@@ -388,11 +390,11 @@ obstack_free (struct obstack *h, POINTER + abort (); + } + +-int ++PTR_INT_TYPE + _obstack_memory_used (struct obstack *h) + { + register struct _obstack_chunk* lp; +- register int nbytes = 0; ++ register PTR_INT_TYPE nbytes = 0; + + for (lp = h->chunk; lp != 0; lp = lp->prev) + { +@@ -421,6 +423,7 @@ print_and_abort (void) + } + + #if 0 ++/* These functions are now broken for 64-bit obstack! */ + /* These are now turned off because the applications do not use it + and it uses bcopy via obstack_grow, which causes trouble on sysV. */ + diff --git a/gdb/patches/gdb-6.3-focus-cmd-prev-test.patch b/gdb/patches/gdb-6.3-focus-cmd-prev-test.patch new file mode 100644 index 000000000..88f52f1fa --- /dev/null +++ b/gdb/patches/gdb-6.3-focus-cmd-prev-test.patch @@ -0,0 +1,28 @@ +--- /dev/null 2008-03-23 13:41:46.072650180 +0100 ++++ gdb-6.3/gdb/testsuite/gdb.base/focus-cmd-prev.exp 2008-03-23 23:46:45.000000000 +0100 +@@ -0,0 +1,25 @@ ++# 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 $tracelevel then { ++ strace $tracelevel ++} ++ ++gdb_exit ++gdb_start ++ ++gdb_test "focus cmd" ++gdb_test "focus prev" diff --git a/gdb/patches/gdb-6.3-gcore-thread-20050204.patch b/gdb/patches/gdb-6.3-gcore-thread-20050204.patch new file mode 100644 index 000000000..31ecbba22 --- /dev/null +++ b/gdb/patches/gdb-6.3-gcore-thread-20050204.patch @@ -0,0 +1,25 @@ +2005-02-07 Jeff Johnston + + * linux-nat.c (linux_nat_xfer_memory): Don't use + linux_proc_xfer_memory for ia64. + +Index: gdb-6.8.50.20090803/gdb/linux-nat.c +=================================================================== +--- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-08-04 06:29:47.000000000 +0200 ++++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-04 06:29:55.000000000 +0200 +@@ -4495,10 +4495,15 @@ linux_xfer_partial (struct target_ops *o + offset &= ((ULONGEST) 1 << addr_bit) - 1; + } + ++#ifndef NATIVE_XFER_UNWIND_TABLE ++ /* FIXME: For ia64, we cannot currently use linux_proc_xfer_memory ++ for accessing thread storage. Revert when Bugzilla 147436 ++ is fixed. */ + xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf, + offset, len); + if (xfer != 0) + return xfer; ++#endif + + return super_xfer_partial (ops, object, annex, readbuf, writebuf, + offset, len); diff --git a/gdb/patches/gdb-6.3-gstack-20050411.patch b/gdb/patches/gdb-6.3-gstack-20050411.patch new file mode 100644 index 000000000..98d5bb05d --- /dev/null +++ b/gdb/patches/gdb-6.3-gstack-20050411.patch @@ -0,0 +1,241 @@ +2004-11-23 Andrew Cagney + + * Makefile.in (uninstall-gstack, install-gstack): New rules, add + to install and uninstall. + * gstack.sh, gstack.1: New files. + +Index: gdb-7.2.50.20101116/gdb/Makefile.in +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/Makefile.in 2010-11-05 15:31:25.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/Makefile.in 2010-11-16 07:56:10.000000000 +0100 +@@ -972,7 +972,7 @@ gdb.z:gdb.1 + install: all + @$(MAKE) $(FLAGS_TO_PASS) install-only + +-install-only: $(CONFIG_INSTALL) ++install-only: install-gstack $(CONFIG_INSTALL) + transformed_name=`t='$(program_transform_name)'; \ + echo gdb | sed -e "$$t"` ; \ + if test "x$$transformed_name" = x; then \ +@@ -1008,7 +1008,25 @@ install-tui: + install-python: + $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb + +-uninstall: force $(CONFIG_UNINSTALL) ++GSTACK=gstack ++.PHONY: install-gstack ++install-gstack: ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo $(GSTACK) | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=$(GSTACK) ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \ ++ $(INSTALL_PROGRAM) $(srcdir)/$(GSTACK).sh \ ++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ ++ : $(SHELL) $(srcdir)/../mkinstalldirs \ ++ $(DESTDIR)$(man1dir) ; \ ++ : $(INSTALL_DATA) $(srcdir)/gstack.1 \ ++ $(DESTDIR)$(man1dir)/$$transformed_name.1 ++ ++uninstall: force uninstall-gstack $(CONFIG_UNINSTALL) + transformed_name=`t='$(program_transform_name)'; \ + echo gdb | sed -e $$t` ; \ + if test "x$$transformed_name" = x; then \ +@@ -1030,6 +1048,17 @@ uninstall-tui: + fi ; \ + rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ + $(DESTDIR)$(man1dir)/$$transformed_name.1 ++.PHONY: uninstall-gstack ++uninstall-gstack: ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo $(GSTACK) | sed -e $$t` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=$(GSTACK) ; \ ++ else \ ++ true ; \ ++ 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 +Index: gdb-7.2.50.20101116/gdb/gstack.sh +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101116/gdb/gstack.sh 2010-11-16 07:55:47.000000000 +0100 +@@ -0,0 +1,48 @@ ++#!/bin/sh ++ ++if test $# -ne 1; then ++ echo "Usage: `basename $0 .sh` " 1>&2 ++ exit 1 ++fi ++ ++if test ! -r /proc/$1; then ++ echo "Process $1 not found." 1>&2 ++ exit 1 ++fi ++ ++# GDB doesn't allow "thread apply all bt" when the process isn't ++# threaded; need to peek at the process to determine if that or the ++# simpler "bt" should be used. ++ ++backtrace="bt" ++if test -d /proc/$1/task ; then ++ # Newer kernel; has a task/ directory. ++ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then ++ backtrace="thread apply all bt" ++ fi ++elif test -f /proc/$1/maps ; then ++ # Older kernel; go by it loading libpthread. ++ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then ++ backtrace="thread apply all bt" ++ fi ++fi ++ ++GDB=${GDB:-/usr/bin/gdb} ++ ++if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then ++ readnever=--readnever ++else ++ readnever= ++fi ++ ++# Run GDB, strip out unwanted noise. ++$GDB --quiet $readnever -nx /proc/$1/exe $1 <&1 | ++set width 0 ++set height 0 ++set pagination no ++$backtrace ++EOF ++/bin/sed -n \ ++ -e 's/^\((gdb) \)*//' \ ++ -e '/^#/p' \ ++ -e '/^Thread/p' +Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp 2010-11-16 07:55:47.000000000 +0100 +@@ -0,0 +1,71 @@ ++# Copyright (C) 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 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 . ++ ++set testfile gstack ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/$executable ++if {[build_executable ${testfile} ${executable} "" {debug}] == -1} { ++ return -1 ++} ++ ++set test "spawn inferior" ++set command "${binfile}" ++set res [remote_spawn host $command]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $command failed." ++ fail $test ++ return ++} ++set pid [exp_pid -i $res] ++gdb_expect { ++ -re "looping\r\n" { ++ pass $test ++ } ++ eof { ++ fail "$test (eof)" ++ return ++ } ++ timeout { ++ fail "$test (timeout)" ++ return ++ } ++} ++gdb_exit ++ ++# Testcase uses the most simple notification not to get caught by attach on ++# exiting the function. Still we could retry the gstack command if we fail. ++ ++set test "spawn gstack" ++set command "sh -c GDB=$GDB\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END" ++set res [remote_spawn host $command]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $command failed." ++ fail $test ++} ++set pid [exp_pid -i $res] ++gdb_expect { ++ -re {^#0 +0x[0-9a-f]+ in \.?func \(\)\r\n#1 +0x[0-9a-f]+ in \.?main \(\)\r\nGSTACK-END\r\n$} { ++ pass $test ++ } ++ eof { ++ fail "$test (eof)" ++ } ++ timeout { ++ fail "$test (timeout)" ++ } ++} ++gdb_exit ++ ++remote_exec host "kill -9 $pid" +Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c 2010-11-16 07:55:47.000000000 +0100 +@@ -0,0 +1,43 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007, 2008, 2009 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 . */ ++ ++#include ++#include ++#include ++ ++void ++func (void) ++{ ++ const char msg[] = "looping\n"; ++ ++ /* Use the most simple notification not to get caught by attach on exiting ++ the function. */ ++ write (1, msg, strlen (msg)); ++ ++ for (;;); ++} ++ ++int ++main (void) ++{ ++ alarm (60); ++ nice (100); ++ ++ func (); ++ ++ return 0; ++} diff --git a/gdb/patches/gdb-6.3-ia64-gcore-page0-20050421.patch b/gdb/patches/gdb-6.3-ia64-gcore-page0-20050421.patch new file mode 100644 index 000000000..ecdfbae8b --- /dev/null +++ b/gdb/patches/gdb-6.3-ia64-gcore-page0-20050421.patch @@ -0,0 +1,20 @@ +Index: gdb-7.2.50.20110107/gdb/gcore.c +=================================================================== +--- gdb-7.2.50.20110107.orig/gdb/gcore.c 2011-01-05 23:22:49.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/gcore.c 2011-01-07 09:04:28.000000000 +0100 +@@ -534,8 +534,14 @@ gcore_copy_callback (bfd *obfd, asection + if (size > total_size) + size = total_size; + ++ /* Warn if read error occurs except if we were trying to read the ++ first page for ia64. The first page is marked readable, but it cannot ++ be read. */ + if (target_read_memory (bfd_section_vma (obfd, osec) + offset, +- memhunk, size) != 0) ++ memhunk, size) != 0 ++ && (strcmp (gdbarch_bfd_arch_info (target_gdbarch)->arch_name, ++ "ia64") ++ || bfd_section_vma (obfd, osec) != 0)) + { + warning (_("Memory read failed for corefile " + "section, %s bytes at %s."), diff --git a/gdb/patches/gdb-6.3-ia64-gcore-speedup-20050714.patch b/gdb/patches/gdb-6.3-ia64-gcore-speedup-20050714.patch new file mode 100644 index 000000000..f902e62f6 --- /dev/null +++ b/gdb/patches/gdb-6.3-ia64-gcore-speedup-20050714.patch @@ -0,0 +1,126 @@ +2005-07-14 Jeff Johnsotn + + * linux-nat.c (linux_nat_xfer_memory): Incorporate Fujitsu + work-around to use /proc/mem for storage, but to fall-back + to PTRACE for ia64 rse register areas. + * ia64-linux-nat.c (ia64_rse_slot_num): New static function. + (ia64_rse_skip_regs): Ditto. + (ia64_linux_check_stack_region): New function. + +Index: gdb-6.8.50.20090803/gdb/linux-nat.c +=================================================================== +--- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-08-04 06:29:55.000000000 +0200 ++++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-04 06:30:53.000000000 +0200 +@@ -4495,15 +4495,38 @@ linux_xfer_partial (struct target_ops *o + offset &= ((ULONGEST) 1 << addr_bit) - 1; + } + +-#ifndef NATIVE_XFER_UNWIND_TABLE +- /* FIXME: For ia64, we cannot currently use linux_proc_xfer_memory +- for accessing thread storage. Revert when Bugzilla 147436 +- is fixed. */ + xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf, + offset, len); + if (xfer != 0) +- return xfer; ++ { ++#ifdef NATIVE_XFER_UNWIND_TABLE ++ struct mem_region range; ++ range.lo = memaddr; ++ range.hi = memaddr + len; ++ ++ /* FIXME: For ia64, we cannot currently use ++ linux_proc_xfer_partial for accessing rse register storage. ++ Revert when Bugzilla 147436 is fixed. */ ++#ifdef NATIVE_XFER_UNWIND_TABLE ++ extern int ia64_linux_check_stack_region (struct lwp_info *lwp, ++ void *range); ++#endif ++ if (iterate_over_lwps (ia64_linux_check_stack_region, &range) != NULL) ++ { /* This region contains ia64 rse registers, we have to re-read. */ ++ int xxfer; ++ ++ /* Re-read register stack area. */ ++ xxfer = super_xfer_partial (ops, object, annex, ++ readbuf + (range.lo - memaddr), ++ writebuf + (range.lo - memaddr), ++ offset + (range.lo - memaddr), ++ range.hi - range.lo); ++ if (xxfer == 0) ++ xfer = 0; ++ } + #endif ++ return xfer; ++ } + + return super_xfer_partial (ops, object, annex, readbuf, writebuf, + offset, len); +Index: gdb-6.8.50.20090803/gdb/ia64-linux-nat.c +=================================================================== +--- gdb-6.8.50.20090803.orig/gdb/ia64-linux-nat.c 2009-02-23 01:03:49.000000000 +0100 ++++ gdb-6.8.50.20090803/gdb/ia64-linux-nat.c 2009-08-04 06:30:53.000000000 +0200 +@@ -809,6 +809,64 @@ ia64_linux_xfer_partial (struct target_o + + void _initialize_ia64_linux_nat (void); + ++/* ++ * Note: taken from ia64_tdep.c ++ * ++ */ ++ ++static __inline__ unsigned long ++ia64_rse_slot_num (unsigned long addr) ++{ ++ return (addr >> 3) & 0x3f; ++} ++ ++/* Skip over a designated number of registers in the backing ++ store, remembering every 64th position is for NAT. */ ++static __inline__ unsigned long ++ia64_rse_skip_regs (unsigned long addr, long num_regs) ++{ ++ long delta = ia64_rse_slot_num(addr) + num_regs; ++ ++ if (num_regs < 0) ++ delta -= 0x3e; ++ return addr + ((num_regs + delta/0x3f) << 3); ++} ++ ++/* ++ * Check mem_region is stack or not. If stack, /proc//mem cannot return ++ * expected value. ++ */ ++int ia64_linux_check_stack_region(struct lwp_info *ti, struct mem_region *range) ++{ ++ CORE_ADDR addr; ++ int error; ++ unsigned long bsp, cfm, bspstore; ++ long sof; ++ pid_t pid = ptid_get_lwp(ti->ptid); ++ bsp = ptrace(PTRACE_PEEKUSER, pid, PT_AR_BSP ,NULL); ++ if (bsp == (unsigned long)-1) { ++ return 1; ++ } ++ /* stack is allocated by one-segment, not separated into several segments. ++ So, we only have to check whether bsp is in *range* or not. */ ++ if((range->lo <= bsp) && (bsp <= range->hi)) { ++ bspstore = ptrace(PTRACE_PEEKUSER, pid, PT_AR_BSPSTORE, NULL); ++ cfm = ptrace(PTRACE_PEEKUSER, pid, PT_CFM, NULL); ++ sof = cfm & 0x3f; ++ bsp = ia64_rse_skip_regs(bsp, -sof); ++ range->lo = bspstore; ++ range->hi = bsp; ++ /* we have to check the size of dirty register stack area */ ++ /* ++ fprintf_unfiltered(gdb_stdlog, "<%d> <%p> <%lx> <%p> <%p>\n", ++ pid, bsp, sof, range->lo, range->hi); ++ */ ++ return 1; ++ } ++ ++ return 0; ++} ++ + void + _initialize_ia64_linux_nat (void) + { diff --git a/gdb/patches/gdb-6.3-ia64-info-frame-fix-20050725.patch b/gdb/patches/gdb-6.3-ia64-info-frame-fix-20050725.patch new file mode 100644 index 000000000..2ebab9eaa --- /dev/null +++ b/gdb/patches/gdb-6.3-ia64-info-frame-fix-20050725.patch @@ -0,0 +1,107 @@ +2005-07-25 Jeff Johnstno + + * libunwind-frame.c (libunwind_frame_prev_register): Check valuep + is not NULL before copying cursor address into it. + +testsuite: +2005-07-25 Jeff Johnstno + + * gdb.arch/ia64-sigtramp.exp: New test. + * gdb.arch/ia64-sigtramp.c: Ditto. + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. (Only the testcase has remained.) + +--- gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.c.fix 2005-07-25 16:42:46.000000000 -0400 ++++ gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.c 2005-07-25 16:42:08.000000000 -0400 +@@ -0,0 +1,23 @@ ++#include ++#include ++ ++int *l; ++ ++void x (int sig) ++{ ++ printf ("in signal handler for signal %d\n", sig); ++} ++ ++int main() ++{ ++ int k; ++ ++ signal (SIGSEGV, &x); ++ ++ k = *l; ++ ++ printf ("k is %d\n", k); ++ ++ return 0; ++} ++ +--- gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.exp.fix 2005-07-25 16:42:50.000000000 -0400 ++++ gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.exp 2005-07-25 16:42:01.000000000 -0400 +@@ -0,0 +1,63 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Jeff Johnston (jjohnstn@redhat.com) ++ ++if ![istarget "ia64-*-*"] then { ++ return ++} ++ ++set testfile "ia64-sigtramp" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++gdb_exit ++set match_max_old [match_max] ++match_max -d 1000000 ++gdb_start ++match_max -d $match_max_old ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return 0 ++} ++ ++gdb_test "handle SIGSEGV" "SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault" ++gdb_test "next" "" "first next" ++gdb_test "next" "Program received signal SIGSEGV.*" "getting SIGSEGV" ++gdb_breakpoint "x" ++gdb_test "continue" "Breakpoint.*x.*" "continue to x" ++ ++gdb_test "f 1" ".*signal handler called.*" "frame 1" ++ ++# gdb-7.0+ no longer prints the pseudo registers as they are computed. ++# frame_info says: /* For moment, only display registers that were saved on the ++# stack. */ ++gdb_test "set debug frame 1" ++gdb_test "info frame" "Stack level 1, .*frame_unwind_register_value \\(frame=1,regnum=750\\(p63\\),\[^\r\n\]*\r\n\[^\r\n\]*-> computed bytes=.*" "info sigtramp frame" diff --git a/gdb/patches/gdb-6.3-ia64-sigill-20051115.patch b/gdb/patches/gdb-6.3-ia64-sigill-20051115.patch new file mode 100644 index 000000000..bf8a1f169 --- /dev/null +++ b/gdb/patches/gdb-6.3-ia64-sigill-20051115.patch @@ -0,0 +1,95 @@ +2005-11-15 Jeff Johnston + + * linux-thread-db.c (thread_db_wait): Don't bother continuing if + the wait result indicates the program terminated with a signal. + * linux-nat.c (linux_nat_wait): For SIGILL and SIGTRAP, don't + throw away the event if the user has specified nostop noprint. + +gdb/testsuite: + +2005-11-15 Jeff Johnston + + * gdb.arch/ia64-sigill.c: New test. + * gdb.arch/ia64-sigill.exp: Ditto. + +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/ia64-sigill.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/ia64-sigill.exp 2011-07-22 19:16:13.000000000 +0200 +@@ -0,0 +1,49 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Jeff Johnston (jjohnstn@redhat.com) ++ ++if ![istarget "ia64-*-*"] then { ++ return ++} ++ ++set testfile "ia64-sigill" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++# Deliberately compile with pthreads, even though test is single-threaded. ++# We want to force gdb thread code to be exercised. ++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# We set up SIGILL nostop, noprint, pass and then run the program. ++# We expect to just see a normal run. ++gdb_test "handle SIGILL nostop noprint" "SIGILL.*No.*No.*Yes.*" "handle sigill" ++gdb_test "run" "Starting program.*ia64-sigill.*\[New thread.*\].*hello world.*Program exited normally." "run to exit" ++ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/ia64-sigill.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/ia64-sigill.c 2011-07-22 19:16:13.000000000 +0200 +@@ -0,0 +1,8 @@ ++#include ++ ++int main() ++{ ++ printf ("hello world\n"); ++ return 0; ++} ++ +Index: gdb-7.3.50.20110722/gdb/linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linux-nat.c 2011-07-22 19:15:05.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linux-nat.c 2011-07-22 19:16:13.000000000 +0200 +@@ -3733,7 +3733,8 @@ retry: + threads can be a bit time-consuming so if we want decent + performance with heavily multi-threaded programs, especially when + they're using a high frequency timer, we'd better avoid it if we +- can. */ ++ can. For possible trap signals like SIGTRAP and SIGILL, don't ++ avoid reporting. */ + + if (WIFSTOPPED (status)) + { diff --git a/gdb/patches/gdb-6.3-ia64-sigtramp-frame-20050708.patch b/gdb/patches/gdb-6.3-ia64-sigtramp-frame-20050708.patch new file mode 100644 index 000000000..c6a7789bb --- /dev/null +++ b/gdb/patches/gdb-6.3-ia64-sigtramp-frame-20050708.patch @@ -0,0 +1,158 @@ +2005-07-08 Jeff Johnston + + * ia64-tdep.c (ia64_sigtramp_frame_prev_register): Build + pseudo-registers the same as ia64_pseudo_register_read. + +2008-04-16 Yi Zhan + + * ia64-tdep.c (ia64_sigtramp_frame_prev_register): Fix an + ISO C compliance compilation error. + +2008-02-12 Jan Kratochvil + + Port to gdb-6.8.50.20081128, follow the upstream change: + http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ia64-tdep.c.diff?cvsroot=src&r1=1.176&r2=1.177 + +Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c +=================================================================== +--- gdb-6.8.50.20081128.orig/gdb/ia64-tdep.c 2008-11-26 06:27:48.000000000 +0100 ++++ gdb-6.8.50.20081128/gdb/ia64-tdep.c 2008-12-02 19:04:32.000000000 +0100 +@@ -2107,6 +2107,94 @@ ia64_sigtramp_frame_prev_register (struc + return frame_unwind_got_constant (this_frame, regnum, pc); + } + ++ /* Red Hat patch begin. */ ++ else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM) ++ { ++ /* NAT pseudo registers 0-31: get them from UNAT. ++ * "copied" from ia64_pseudo_register_read() */ ++ ULONGEST unatN_val; ++ ULONGEST unat; ++ read_memory (cache->saved_regs[IA64_UNAT_REGNUM], (char *) &unat, ++ register_size (target_gdbarch, IA64_UNAT_REGNUM)); ++ unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0; ++ return frame_unwind_got_constant (this_frame, regnum, unatN_val); ++ } ++ else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM) ++ { ++ /* NAT pseudo registers 32-127. ++ * "copied" from ia64_pseudo_register_read() ++ * FIXME: Not currently tested -- cannot get the frame to include ++ * NAT32-NAT127. */ ++ ULONGEST bsp; ++ ULONGEST cfm; ++ ULONGEST natN_val = 0; ++ CORE_ADDR gr_addr = 0, nat_addr = 0; ++ ++ read_memory (cache->saved_regs[IA64_BSP_REGNUM], (char *) &bsp, ++ register_size (target_gdbarch, IA64_BSP_REGNUM)); ++ read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); ++ ++ /* The bsp points at the end of the register frame so we ++ subtract the size of frame from it to get start of register frame. */ ++ bsp = rse_address_add (bsp, -(cfm & 0x7f)); ++ ++ if ((cfm & 0x7f) > regnum - V32_REGNUM) ++ gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM)); ++ ++ if (gr_addr != 0) ++ { ++ /* Compute address of nat collection bits */ ++ CORE_ADDR nat_collection; ++ int nat_bit; ++ nat_addr = gr_addr | 0x1f8; ++ /* If our nat collection address is bigger than bsp, we have to get ++ the nat collection from rnat. Otherwise, we fetch the nat ++ collection from the computed address. FIXME: Do not know if ++ RNAT can be not stored in the frame--being extra cautious. */ ++ if (nat_addr >= bsp) ++ { ++ nat_addr = cache->saved_regs[IA64_RNAT_REGNUM]; ++ if (nat_addr != 0) ++ read_memory (nat_addr, (char *) &nat_collection, ++ register_size (target_gdbarch, IA64_RNAT_REGNUM)); ++ } ++ else ++ nat_collection = read_memory_integer (nat_addr, 8, BFD_ENDIAN_LITTLE); ++ if (nat_addr != 0) ++ { ++ nat_bit = (gr_addr >> 3) & 0x3f; ++ natN_val = (nat_collection >> nat_bit) & 1; ++ return frame_unwind_got_constant (this_frame, regnum, natN_val); ++ } ++ } ++ warning (_("ia64_sigtramp_frame_prev_register: unhandled register %d"), ++ regnum); ++ } ++ else if (regnum == VBOF_REGNUM) ++ { ++ /* BOF pseudo register. ++ * "copied" from ia64_pseudo_register_read() ++ * ++ * A virtual register frame start is provided for user convenience. ++ * It can be calculated as the bsp - sof (sizeof frame). */ ++ ULONGEST bsp; ++ ULONGEST cfm; ++ ULONGEST bof; ++ ++ read_memory (cache->saved_regs[IA64_BSP_REGNUM], (char *) &bsp, ++ register_size (target_gdbarch, IA64_BSP_REGNUM)); ++ read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); ++ ++ /* The bsp points at the end of the register frame so we ++ subtract the size of frame from it to get beginning of frame. */ ++ bof = rse_address_add (bsp, -(cfm & 0x7f)); ++ ++ return frame_unwind_got_constant (this_frame, regnum, bof); ++ } ++ /* Red Hat patch end. */ ++ + else if ((regnum >= IA64_GR32_REGNUM && regnum <= IA64_GR127_REGNUM) + || (regnum >= V32_REGNUM && regnum <= V127_REGNUM)) + { +@@ -2121,7 +2209,42 @@ ia64_sigtramp_frame_prev_register (struc + return frame_unwind_got_constant (this_frame, regnum, 0); + } + +- else /* All other registers not listed above. */ ++ /* Red Hat patch begin. */ ++ else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM) ++ { ++ /* VP 0-63. ++ * "copied" from ia64_pseudo_register_read() ++ * ++ * FIXME: Not currently tested--cannot get the frame to include PR. */ ++ CORE_ADDR pr_addr = 0; ++ ++ pr_addr = cache->saved_regs[IA64_PR_REGNUM]; ++ if (pr_addr != 0) ++ { ++ ULONGEST pr; ++ ULONGEST cfm; ++ ULONGEST prN_val; ++ read_memory (pr_addr, (char *) &pr, ++ register_size (target_gdbarch, IA64_PR_REGNUM)); ++ read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); ++ ++ /* Get the register rename base for this frame and adjust the ++ * register name to take rotation into account. */ ++ if (VP16_REGNUM <= regnum && regnum <= VP63_REGNUM) ++ { ++ int rrb_pr = (cfm >> 32) & 0x3f; ++ regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48; ++ } ++ prN_val = (pr & (1LL << (regnum - VP0_REGNUM))) != 0; ++ return frame_unwind_got_constant (this_frame, regnum, prN_val); ++ } ++ warning (_("ia64_sigtramp_frame_prev_register: unhandled register %d"), ++ regnum); ++ } ++ /* Red Hat patch end. */ ++ ++ /* All other registers not listed above. */ + { + CORE_ADDR addr = cache->saved_regs[regnum]; + diff --git a/gdb/patches/gdb-6.3-inferior-notification-20050721.patch b/gdb/patches/gdb-6.3-inferior-notification-20050721.patch new file mode 100644 index 000000000..0eb397c07 --- /dev/null +++ b/gdb/patches/gdb-6.3-inferior-notification-20050721.patch @@ -0,0 +1,315 @@ +2005-07-21 Jeff Johnston + + * 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 + + * gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set. + +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c 2011-03-20 20:15:57.000000000 +0100 +@@ -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 ++ ++int should_exit = 0; ++ ++int main () ++{ ++ int local_i = 0; ++ ++ while (! should_exit) ++ { ++ local_i++; ++ } ++ return 0; ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp 2011-03-20 20:20:03.000000000 +0100 +@@ -0,0 +1,245 @@ ++# 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 [is_remote target] then { ++ return 0 ++} ++ ++set testfile "attach-32" ++set srcfile ${testfile}.c ++set srcfile2 ${testfile}b.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binfile2 ${objdir}/${subdir}/${testfile}b ++set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${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 "--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 "--pid=$testpid" ++gdb_start ++set GDBFLAGS $GDBFLAGS_orig ++ ++gdb_reinitialize_dir $srcdir/$subdir ++do_call_attach_tests ++ ++return 0 +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c 2011-03-20 20:15:57.000000000 +0100 +@@ -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 ++#include ++#include ++ ++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); ++} diff --git a/gdb/patches/gdb-6.3-inheritancetest-20050726.patch b/gdb/patches/gdb-6.3-inheritancetest-20050726.patch new file mode 100644 index 000000000..ab819761d --- /dev/null +++ b/gdb/patches/gdb-6.3-inheritancetest-20050726.patch @@ -0,0 +1,153 @@ +2005-07-26 Jeff Johnston + + * gdb.cp/b146835.exp: New testcase. + * gdb.cp/b146835.cc: Ditto. + * gdb.cp/b146835b.cc: Ditto. + * gdb.cp/b146835.h: Ditto. + +Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835b.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835b.cc 2009-08-12 06:07:50.000000000 +0200 +@@ -0,0 +1,11 @@ ++#include "b146835.h" ++ ++C::C() { d = 0; x = 3; } ++ ++int C::z (char *s) { return 0; } ++ ++C::~C() {} ++ ++void A::funcD (class E *e, class D *d) {} ++void A::funcE (E *e, D *d) {} ++void A::funcF (unsigned long x, D *d) {} +Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.cc 2009-08-12 06:07:50.000000000 +0200 +@@ -0,0 +1,32 @@ ++#include "b146835.h" ++#include ++ ++class F : public C { ++ ++protected: ++ ++ virtual void funcA (unsigned long a, B *b); ++ virtual void funcB (E *e); ++ virtual void funcC (unsigned long x, bool y); ++ ++ char *s1, *s2; ++ bool b1; ++ int k; ++ ++public: ++ void foo() { ++ std::cout << "foo" << std::endl; ++ } ++}; ++ ++ ++void F::funcA (unsigned long a, B *b) {} ++void F::funcB (E *e) {} ++void F::funcC (unsigned long x, bool y) {} ++ ++int main() ++{ ++ F f; ++ f.foo(); ++} ++ +Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.exp 2009-08-12 06:58:28.000000000 +0200 +@@ -0,0 +1,47 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# 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. ++ ++# Check that GDB can properly print an inherited member variable ++# (Bugzilla 146835) ++ ++set testfile "b146835" ++set srcfile ${testfile}.cc ++set srcfile2 ${testfile}b.cc ++set binfile ${objdir}/${subdir}/${testfile} ++if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable {debug c++}] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# ++# Run to `main' where we begin our tests. ++# ++ ++if ![runto_main] then { ++ gdb_suppress_tests ++} ++ ++gdb_test "break 'F::foo()'" "" ++gdb_continue_to_breakpoint "First line foo" ++ ++# Verify that we can access the inherited member d ++gdb_test "p d" " = \\(D \\*\\) *0x0" "Verify inherited member d accessible" +Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.h 2009-08-12 06:07:50.000000000 +0200 +@@ -0,0 +1,36 @@ ++ ++class A { ++ ++protected: ++ ++ virtual void funcA (unsigned long a, class B *b) = 0; ++ virtual void funcB (class E *e) = 0; ++ virtual void funcC (unsigned long x, bool y) = 0; ++ ++ void funcD (class E *e, class D* d); ++ virtual void funcE (E *e, D *d); ++ virtual void funcF (unsigned long x, D *d); ++}; ++ ++ ++class C : public A { ++ ++protected: ++ ++ int x; ++ class K *k; ++ class H *h; ++ ++ D *d; ++ ++ class W *w; ++ class N *n; ++ class L *l; ++ unsigned long *r; ++ ++public: ++ ++ C(); ++ int z (char *s); ++ virtual ~C(); ++}; diff --git a/gdb/patches/gdb-6.3-mapping-zero-inode-test.patch b/gdb/patches/gdb-6.3-mapping-zero-inode-test.patch new file mode 100644 index 000000000..73d24464c --- /dev/null +++ b/gdb/patches/gdb-6.3-mapping-zero-inode-test.patch @@ -0,0 +1,229 @@ +Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp 2009-06-29 16:24:36.000000000 +0200 +@@ -0,0 +1,96 @@ ++# Copyright 2007, 2009 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. ++ ++# Test GDB's handling of gcore for mapping with a name but zero inode. ++ ++if { [prepare_for_testing gcore-shmid0.exp gcore-shmid0] } { ++ return -1 ++} ++ ++# Does this gdb support gcore? ++set test "help gcore" ++gdb_test_multiple $test $test { ++ -re "Undefined command: .gcore.*$gdb_prompt $" { ++ # gcore command not supported -- nothing to test here. ++ unsupported "gdb does not support gcore on this target" ++ return -1; ++ } ++ -re "Save a core file .*$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++if { ! [ runto_main ] } then { ++ untested gcore-shmid0.exp ++ return -1 ++} ++ ++gdb_breakpoint "initialized" ++gdb_breakpoint "unresolved" ++ ++set test "Continue to initialized." ++gdb_test_multiple "continue" $test { ++ -re "Breakpoint .*, initialized .* at .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Breakpoint .*, unresolved .* at .*\r\n$gdb_prompt $" { ++ unsupported $test ++ return -1 ++ } ++} ++ ++set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore-shmid0.test] ++ ++set test "save a corefile" ++gdb_test_multiple "gcore ${objdir}/${subdir}/gcore-shmid0.test" $test { ++ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" { ++ unsupported $test ++ } ++} ++ ++# Be sure to remove the handle first. ++# But it would get removed even on a kill by GDB as the handle is already ++# deleted, just it is still attached. ++gdb_continue_to_end "finish" ++ ++set test "core-file command" ++gdb_test_multiple "core-file $objdir/$subdir/gcore-shmid0.test" $test { ++ -re ".* program is being debugged already.*y or n. $" { ++ # gdb_load may connect us to a gdbserver. ++ send_gdb "y\n" ++ exp_continue; ++ } ++ -re "Core was generated by .*\r\n\#0 .*\\\(\\\).*\r\n$gdb_prompt $" { ++ # The filename does not fit there anyway so do not check it. ++ pass $test ++ } ++ -re ".*registers from core file: File in wrong format.* $" { ++ fail "core-file command (could not read registers from core file)" ++ } ++} ++ ++set test "backtrace" ++gdb_test_multiple "bt" $test { ++ -re "#0 *initialized \\\(\\\) at .*#1 .* main \\\(.*$gdb_prompt $" { ++ pass $test ++ } ++ -re "#0 *initialized \\\(\\\) at .*Cannot access memory at address .*$gdb_prompt $" { ++ fail $test ++ } ++} +Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c 2009-06-29 16:22:49.000000000 +0200 +@@ -0,0 +1,123 @@ ++/* Copyright 2007, 2009 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 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. */ ++ ++/* ++ * Test GDB's handling of gcore for mapping with a name but zero inode. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* The same test running in a parallel testsuite may steal us the zero SID, ++ even if we never get any EEXIST. Just try a while. */ ++ ++#define TIMEOUT_SEC 10 ++ ++static void ++initialized (void) ++{ ++} ++ ++static void ++unresolved (void) ++{ ++} ++ ++int ++main (void) ++{ ++ int sid; ++ unsigned int *addr = (void *) -1L; ++ int attempt, round = 0; ++ time_t ts_start, ts; ++ ++ if (time (&ts_start) == (time_t) -1) ++ { ++ printf ("time (): %m\n"); ++ exit (1); ++ } ++ ++ /* The generated SID will cycle with an increment of 32768, attempt until it ++ * wraps to 0. */ ++ ++ for (attempt = 0; addr == (void *) -1L; attempt++) ++ { ++ /* kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by ++ shmget(2). shmget returns SID range 0..1<<31 in steps of 32768, ++ 0x1000 should be enough but wrap the range it to be sure. */ ++ ++ if (attempt > 0x21000) ++ { ++ if (time (&ts) == (time_t) -1) ++ { ++ printf ("time (): %m\n"); ++ exit (1); ++ } ++ ++ if (ts >= ts_start && ts < ts_start + TIMEOUT_SEC) ++ { ++ attempt = 0; ++ round++; ++ continue; ++ } ++ ++ printf ("Problem is not reproducible on this kernel (attempt %d, " ++ "round %d))\n", attempt, round); ++ unresolved (); ++ exit (1); ++ } ++ ++ sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777); ++ if (sid == -1) ++ { ++ if (errno == EEXIST) ++ continue; ++ ++ printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno); ++ exit (1); ++ } ++ ++ /* Use SID only if it is 0, retry it otherwise. */ ++ ++ if (sid == 0) ++ { ++ addr = shmat (sid, NULL, SHM_RND); ++ if (addr == (void *) -1L) ++ { ++ printf ("shmat (%d, NULL, SHM_RND): errno %d\n", sid, ++ errno); ++ exit (1); ++ } ++ } ++ if (shmctl (sid, IPC_RMID, NULL) != 0) ++ { ++ printf ("shmctl (%d, IPC_RMID, NULL): errno %d\n", sid, errno); ++ exit (1); ++ } ++ } ++ ++ initialized (); ++ ++ return 0; ++} diff --git a/gdb/patches/gdb-6.3-ppc64displaysymbol-20041124.patch b/gdb/patches/gdb-6.3-ppc64displaysymbol-20041124.patch new file mode 100644 index 000000000..8e94e002c --- /dev/null +++ b/gdb/patches/gdb-6.3-ppc64displaysymbol-20041124.patch @@ -0,0 +1,24 @@ +2004-11-24 Andrew Cagney + + * printcmd.c (build_address_symbolic): Find a section for the + address. + +Index: gdb-6.8.50.20081128/gdb/printcmd.c +=================================================================== +--- gdb-6.8.50.20081128.orig/gdb/printcmd.c 2008-12-04 01:36:05.000000000 +0100 ++++ gdb-6.8.50.20081128/gdb/printcmd.c 2008-12-04 01:37:18.000000000 +0100 +@@ -616,6 +616,14 @@ build_address_symbolic (CORE_ADDR addr, + addr = overlay_mapped_address (addr, section); + } + } ++ /* To ensure that the symbol returned belongs to the correct setion ++ (and that the last [random] symbol from the previous section ++ isn't returned) try to find the section containing PC. First try ++ the overlay code (which by default returns NULL); and second try ++ the normal section code (which almost always succeeds). */ ++ section = find_pc_overlay (addr); ++ if (section == NULL) ++ section = find_pc_section (addr); + + /* First try to find the address in the symbol table, then + in the minsyms. Take the closest one. */ diff --git a/gdb/patches/gdb-6.3-ppc64syscall-20040622.patch b/gdb/patches/gdb-6.3-ppc64syscall-20040622.patch new file mode 100644 index 000000000..a237cc116 --- /dev/null +++ b/gdb/patches/gdb-6.3-ppc64syscall-20040622.patch @@ -0,0 +1,111 @@ +2004-06-22 Andrew Cagney + + * rs6000-tdep.c (struct rs6000_framedata): Add field "func_start". + (skip_prologue): Delete local variable "orig_pc", use + "func_start". Add local variable "num_skip_linux_syscall_insn", + use to skip over first half of a GNU/Linux syscall and update + "func_start". + +Index: gdb-7.2.50.20110117/gdb/rs6000-tdep.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/rs6000-tdep.c 2011-01-11 20:23:02.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/rs6000-tdep.c 2011-01-17 15:48:19.000000000 +0100 +@@ -126,6 +126,7 @@ static const char *powerpc_vector_abi_st + + struct rs6000_framedata + { ++ CORE_ADDR func_start; /* True function start. */ + int offset; /* total size of frame --- the distance + by which we decrement sp to allocate + the frame */ +@@ -1496,7 +1497,6 @@ static CORE_ADDR + skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, + struct rs6000_framedata *fdata) + { +- CORE_ADDR orig_pc = pc; + CORE_ADDR last_prologue_pc = pc; + CORE_ADDR li_found_pc = 0; + gdb_byte buf[4]; +@@ -1514,12 +1514,14 @@ skip_prologue (struct gdbarch *gdbarch, + int minimal_toc_loaded = 0; + int prev_insn_was_prologue_insn = 1; + int num_skip_non_prologue_insns = 0; ++ int num_skip_ppc64_gnu_linux_syscall_insn = 0; + int r0_contains_arg = 0; + const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + + memset (fdata, 0, sizeof (struct rs6000_framedata)); ++ fdata->func_start = pc; + fdata->saved_gpr = -1; + fdata->saved_fpr = -1; + fdata->saved_vr = -1; +@@ -1553,6 +1555,55 @@ skip_prologue (struct gdbarch *gdbarch, + break; + op = extract_unsigned_integer (buf, 4, byte_order); + ++ /* A PPC64 GNU/Linux system call function is split into two ++ sub-functions: a non-threaded fast-path (__NAME_nocancel) ++ which does not use a frame; and a threaded slow-path ++ (Lpseudo_cancel) that does create a frame. Ref: ++ nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h ++ ++ *INDENT-OFF* ++ NAME: ++ SINGLE_THREAD_P ++ bne- .Lpseudo_cancel ++ __NAME_nocancel: ++ li r0,162 ++ sc ++ bnslr+ ++ b 0x7fe014ef64 <.__syscall_error> ++ Lpseudo_cancel: ++ stdu r1,-128(r1) ++ ... ++ *INDENT-ON* ++ ++ Unfortunatly, because the latter case uses a local label (not ++ in the symbol table) a PC in "Lpseudo_cancel" appears to be ++ in "__NAME_nocancel". The following code recognizes this, ++ adjusting FUNC_START to point to where "Lpseudo_cancel" ++ should be, and parsing the prologue sequence as if ++ "Lpseudo_cancel" was the entry point. */ ++ ++ if (((op & 0xffff0000) == 0x38000000 /* li r0,N */ ++ && pc == fdata->func_start + 0 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 0) ++ || (op == 0x44000002 /* sc */ ++ && pc == fdata->func_start + 4 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 1) ++ || (op == 0x4ca30020 /* bnslr+ */ ++ && pc == fdata->func_start + 8 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 2)) ++ { ++ num_skip_ppc64_gnu_linux_syscall_insn++; ++ continue; ++ } ++ else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */ ++ && pc == fdata->func_start + 12 ++ && num_skip_ppc64_gnu_linux_syscall_insn == 3) ++ { ++ num_skip_ppc64_gnu_linux_syscall_insn = -1; ++ fdata->func_start = pc; ++ continue; ++ } ++ + if ((op & 0xfc1fffff) == 0x7c0802a6) + { /* mflr Rx */ + /* Since shared library / PIC code, which needs to get its +@@ -1734,9 +1785,9 @@ skip_prologue (struct gdbarch *gdbarch, + we have no line table information or the line info tells + us that the subroutine call is not part of the line + associated with the prologue. */ +- if ((pc - orig_pc) > 8) ++ if ((pc - fdata->func_start) > 8) + { +- struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0); ++ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0); + struct symtab_and_line this_sal = find_pc_line (pc, 0); + + if ((prologue_sal.line == 0) diff --git a/gdb/patches/gdb-6.3-ppcdotsolib-20041022.patch b/gdb/patches/gdb-6.3-ppcdotsolib-20041022.patch new file mode 100644 index 000000000..7226c0d8b --- /dev/null +++ b/gdb/patches/gdb-6.3-ppcdotsolib-20041022.patch @@ -0,0 +1,31 @@ +2004-10-22 Andrew Cagney + + * solib-svr4.c (enable_break): Convert a symbol descriptor into + the corresponding function entry point. + (solib_break_names): Delete "._dl_debug_state", no longer needed. + +2007-10-12 Jan Kratochvil + + Port to GDB-6.7. + +Index: gdb-6.8.50.20090802/gdb/solib-svr4.c +=================================================================== +--- gdb-6.8.50.20090802.orig/gdb/solib-svr4.c 2009-08-03 10:03:36.000000000 +0200 ++++ gdb-6.8.50.20090802/gdb/solib-svr4.c 2009-08-03 10:51:15.000000000 +0200 +@@ -1431,7 +1431,15 @@ enable_break (struct svr4_info *info) + { + sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep); + if (sym_addr != 0) +- break; ++ { ++ /* The symbol might be a descriptor, convert to into the ++ corresponding code address. */ ++ sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, ++ sym_addr, ++ tmp_bfd_target); ++ if (sym_addr != 0) ++ break; ++ } + } + + if (sym_addr != 0) diff --git a/gdb/patches/gdb-6.3-readnever-20050907.patch b/gdb/patches/gdb-6.3-readnever-20050907.patch new file mode 100644 index 000000000..f32705174 --- /dev/null +++ b/gdb/patches/gdb-6.3-readnever-20050907.patch @@ -0,0 +1,98 @@ +2004-11-18 Andrew Cagney + + * dwarf2read.c: Include "top.c". + (dwarf2_has_info): Check for readnever_symbol_files. + * symfile.c (readnever_symbol_files): Define. + * top.h (readnever_symbol_files): Declare. + * main.c (captured_main): Add --readnever option. + (print_gdb_help): Ditto. + +2004-11-18 Andrew Cagney + + * gdb.texinfo (File Options): Document --readnever. + +Index: gdb-7.3.50.20110722/gdb/doc/gdb.texinfo +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/doc/gdb.texinfo 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/doc/gdb.texinfo 2011-07-22 19:15:13.000000000 +0200 +@@ -1005,6 +1005,12 @@ Read each symbol file's entire symbol ta + the default, which is to read it incrementally as it is needed. + This makes startup slower, but makes future operations faster. + ++@item --readnever ++@cindex @code{--readnever} ++Do not read each symbol file's symbolic debug information. This makes ++startup faster but at the expense of not being able to perform ++symbolic debugging. ++ + @end table + + @node Mode Options +Index: gdb-7.3.50.20110722/gdb/main.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/main.c 2011-07-22 19:14:25.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/main.c 2011-07-22 19:15:13.000000000 +0200 +@@ -399,6 +399,7 @@ captured_main (void *data) + {"xdb", no_argument, &xdb_commands, 1}, + {"dbx", no_argument, &dbx_commands, 1}, + {"readnow", no_argument, &readnow_symbol_files, 1}, ++ {"readnever", no_argument, &readnever_symbol_files, 1}, + {"r", no_argument, &readnow_symbol_files, 1}, + {"quiet", no_argument, &quiet, 1}, + {"q", no_argument, &quiet, 1}, +@@ -1065,6 +1066,7 @@ Options:\n\n\ + fputs_unfiltered (_("\ + --quiet Do not print version number on startup.\n\ + --readnow Fully read symbol files on first access.\n\ ++ --readnever Do not read symbol files.\n\ + "), stream); + fputs_unfiltered (_("\ + --se=FILE Use FILE as symbol file and executable file.\n\ +Index: gdb-7.3.50.20110722/gdb/symfile.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symfile.c 2011-05-11 06:56:07.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symfile.c 2011-07-22 19:15:13.000000000 +0200 +@@ -81,6 +81,7 @@ static void clear_symtab_users_cleanup ( + + /* Global variables owned by this file. */ + int readnow_symbol_files; /* Read full symbols immediately. */ ++int readnever_symbol_files; /* Never read full symbols. */ + + /* External variables and functions referenced. */ + +Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-22 19:15:41.000000000 +0200 +@@ -58,6 +58,7 @@ + #include "c-lang.h" + #include "valprint.h" + #include ++#include "top.h" + + #include + #include "gdb_string.h" +@@ -1388,8 +1389,9 @@ dwarf2_has_info (struct objfile *objfile + (void *) names); + dwarf2_per_objfile->objfile = objfile; + } +- return (dwarf2_per_objfile->info.asection != NULL +- && dwarf2_per_objfile->abbrev.asection != NULL); ++ return (! readnever_symbol_files ++ && (dwarf2_per_objfile->info.asection != NULL ++ && dwarf2_per_objfile->abbrev.asection != NULL)); + } + + /* When loading sections, we look either for uncompressed section or for +Index: gdb-7.3.50.20110722/gdb/top.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/top.h 2011-07-21 13:03:45.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/top.h 2011-07-22 19:15:13.000000000 +0200 +@@ -59,6 +59,7 @@ extern void set_prompt (const char *); + + /* From random places. */ + extern int readnow_symbol_files; ++extern int readnever_symbol_files; + + /* Perform _initialize initialization. */ + extern void gdb_init (char *); diff --git a/gdb/patches/gdb-6.3-rh-dummykfail-20041202.patch b/gdb/patches/gdb-6.3-rh-dummykfail-20041202.patch new file mode 100644 index 000000000..1f0bc9da8 --- /dev/null +++ b/gdb/patches/gdb-6.3-rh-dummykfail-20041202.patch @@ -0,0 +1,22 @@ +2003-07-11 Elena Zannoni + + * lib/gdb.exp (setup_kfail, kfail): Redefine procedures. + +--- ./gdb/testsuite/lib/gdb.exp.1 2004-11-24 15:59:46.131394720 -0500 ++++ ./gdb/testsuite/lib/gdb.exp 2004-11-24 16:01:06.304206600 -0500 +@@ -63,6 +63,15 @@ + + ### Only procedures should come after this point. + ++if {![llength [info procs kfail]]} { ++ proc setup_kfail { args } { ++ #setup_xfail args ++ } ++ proc kfail { bugid message } { ++ fail $message ++ } ++} ++ + # + # gdb_version -- extract and print the version number of GDB + # diff --git a/gdb/patches/gdb-6.3-rh-testlibunwind-20041202.patch b/gdb/patches/gdb-6.3-rh-testlibunwind-20041202.patch new file mode 100644 index 000000000..0a121c30f --- /dev/null +++ b/gdb/patches/gdb-6.3-rh-testlibunwind-20041202.patch @@ -0,0 +1,103 @@ +2003-11-17 Elena Zannoni + + From Jeff Johnston + * gdb.arch/ia64-libunwind.exp: New file. + * gdb.arch/ia64-libunwind.c: New file. + +2004-08-03 Jeff Johnston + + * gdb.arch/ia64-libunwind.exp: Fix test string to match + current code base. + + [ acquire_unwind_info -> ia64_find_proc_info_x ] + +2009-04-30 Jan Kratochvil + + Remove a race from send_gdb "COMMAND\n". + Cleanup. + Merge in: Patch4: gdb-6.3-rh-testlibunwind1fix-20041202.patch + +--- /dev/null 2009-04-19 08:52:54.499000000 +0200 ++++ gdb-6.8/gdb/testsuite/gdb.arch/ia64-libunwind.c 2009-04-30 19:15:16.000000000 +0200 +@@ -0,0 +1,26 @@ ++/* Copyright 2003, 2009 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 . */ ++ ++#include ++ ++int ++main () ++{ ++ printf ("hello world\n"); ++ ++ return 0; ++} +--- /dev/null 2009-04-19 08:52:54.499000000 +0200 ++++ gdb-6.8/gdb/testsuite/gdb.arch/ia64-libunwind.exp 2009-04-30 19:19:22.000000000 +0200 +@@ -0,0 +1,52 @@ ++# Copyright 2003, 2009 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 ++ ++# This file was written by Jeff Johnston (jjohnstn@redhat.com) ++ ++if ![istarget "ia64-*-*"] then { ++ return ++} ++ ++set testfile "ia64-libunwind" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "set debug arch 1" ++gdb_breakpoint "main" ++gdb_run_cmd ++ ++set test "libunwind message" ++gdb_test_multiple "" $test { ++ -re "ia64_find_proc_info_x.*$gdb_prompt $" { ++ pass $test ++ } ++} diff --git a/gdb/patches/gdb-6.3-rh-testversion-20041202.patch b/gdb/patches/gdb-6.3-rh-testversion-20041202.patch new file mode 100644 index 000000000..7839200cc --- /dev/null +++ b/gdb/patches/gdb-6.3-rh-testversion-20041202.patch @@ -0,0 +1,19 @@ +2003-02-24 Elena Zannoni + + * gdb.gdb/selftest.exp: Add matching on specific Red Hat only version + string. + +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.gdb/selftest.exp +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.gdb/selftest.exp 2010-06-26 08:44:47.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.gdb/selftest.exp 2010-07-12 09:59:42.000000000 +0200 +@@ -342,6 +342,9 @@ proc test_with_self { executable } { + -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { + pass "printed version with cast" + } ++ -re ".\[0-9\]+ = .(Fedora|Red Hat Enterprise Linux) \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" { ++ pass "printed version Fedora or Red Hat Enterprise Linux only" ++ } + } + + do_steps_and_nexts diff --git a/gdb/patches/gdb-6.3-security-errata-20050610.patch b/gdb/patches/gdb-6.3-security-errata-20050610.patch new file mode 100644 index 000000000..3763332c2 --- /dev/null +++ b/gdb/patches/gdb-6.3-security-errata-20050610.patch @@ -0,0 +1,243 @@ +http://sourceware.org/ml/gdb-patches/2005-05/threads.html#00637 +Proposed upstream but never committed upstream. + +2005-06-09 Jeff Johnston + + * gdb.base/gdbinit.exp: New testcase. + * gdb.base/gdbinit.sample: Sample .gdbinit for gdbinit.exp. + +2005-06-08 Daniel Jacobowitz + Jeff Johnston + + * Makefile.in (cli-cmds.o): Update. + * configure.in: Add check for getuid. + * configure: Regenerated. + * config.in: Ditto. + * main.c (captured_main): Pass -1 to source_command when loading + gdbinit files. + * cli/cli-cmds.c: Include "gdb_stat.h" and . + (source_command): Update documentation. Check permissions if + FROM_TTY is -1. + +Index: gdb-7.3.50.20110722/gdb/cli/cli-cmds.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/cli/cli-cmds.c 2011-06-07 19:26:46.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/cli/cli-cmds.c 2011-07-22 19:14:25.000000000 +0200 +@@ -39,6 +39,7 @@ + #include "source.h" + #include "disasm.h" + #include "tracepoint.h" ++#include "gdb_stat.h" + + #include "ui-out.h" + +@@ -489,7 +490,7 @@ show_script_ext_mode (struct ui_file *fi + + int + find_and_open_script (const char *script_file, int search_path, +- FILE **streamp, char **full_pathp) ++ FILE **streamp, char **full_pathp, int from_tty) + { + char *file; + int fd; +@@ -515,6 +516,32 @@ find_and_open_script (const char *script + return 0; + } + ++#ifdef HAVE_GETUID ++ if (from_tty == -1) ++ { ++ struct stat statbuf; ++ ++ if (fstat (fd, &statbuf) < 0) ++ { ++ int save_errno = errno; ++ ++ close (fd); ++ do_cleanups (old_cleanups); ++ errno = save_errno; ++ return 0; ++ } ++ if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH)) ++ { ++ /* FILE gets freed by do_cleanups (old_cleanups). */ ++ warning (_("not using untrusted file \"%s\""), file); ++ close (fd); ++ do_cleanups (old_cleanups); ++ errno = EPERM; ++ return 0; ++ } ++ } ++#endif ++ + do_cleanups (old_cleanups); + + *streamp = fdopen (fd, FOPEN_RT); +@@ -574,13 +601,14 @@ source_script_with_search (const char *f + if (file == NULL || *file == 0) + error (_("source command requires file name of file to source.")); + +- if (!find_and_open_script (file, search_path, &stream, &full_path)) ++ if (!find_and_open_script (file, search_path, &stream, &full_path, ++ from_tty)) + { + /* The script wasn't found, or was otherwise inaccessible. + If the source command was invoked interactively, throw an + error. Otherwise (e.g. if it was invoked by a script), + silently ignore the error. */ +- if (from_tty) ++ if (from_tty > 0) + perror_with_name (file); + else + return; +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/gdbinit.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/gdbinit.exp 2011-07-22 19:14:25.000000000 +0200 +@@ -0,0 +1,91 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Jeff Johnston . ++ ++# are we on a target board ++if [is_remote target] { ++ return ++} ++ ++ ++global verbose ++global GDB ++global GDBFLAGS ++global gdb_prompt ++global timeout ++global gdb_spawn_id; ++ ++gdb_stop_suppressing_tests; ++ ++verbose "Spawning $GDB -nw" ++ ++if [info exists gdb_spawn_id] { ++ return 0; ++} ++ ++if ![is_remote host] { ++ if { [which $GDB] == 0 } then { ++ perror "$GDB does not exist." ++ exit 1 ++ } ++} ++ ++set env(HOME) [pwd] ++remote_exec build "rm .gdbinit" ++remote_exec build "cp ${srcdir}/${subdir}/gdbinit.sample .gdbinit" ++remote_exec build "chmod 646 .gdbinit" ++ ++set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $GDB failed." ++ return 1; ++} ++gdb_expect 360 { ++ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" { ++ pass "untrusted .gdbinit caught." ++ } ++ -re "$gdb_prompt $" { ++ fail "untrusted .gdbinit caught." ++ } ++ timeout { ++ fail "(timeout) untrusted .gdbinit caught." ++ } ++} ++ ++remote_exec build "chmod 644 .gdbinit" ++set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $GDB failed." ++ return 1; ++} ++gdb_expect 360 { ++ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" { ++ fail "trusted .gdbinit allowed." ++ } ++ -re "in gdbinit.*$gdb_prompt $" { ++ pass "trusted .gdbinit allowed." ++ } ++ timeout { ++ fail "(timeout) trusted .gdbinit allowed." ++ } ++} ++ ++remote_exec build "rm .gdbinit" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/gdbinit.sample +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/gdbinit.sample 2011-07-22 19:14:25.000000000 +0200 +@@ -0,0 +1 @@ ++echo "\nin gdbinit" +Index: gdb-7.3.50.20110722/gdb/main.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/main.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/main.c 2011-07-22 19:14:25.000000000 +0200 +@@ -849,7 +849,7 @@ captured_main (void *data) + debugging or what directory you are in. */ + + if (home_gdbinit && !inhibit_gdbinit) +- catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL); ++ catch_command_errors (source_script, home_gdbinit, -1, RETURN_MASK_ALL); + + /* Now perform all the actions indicated by the arguments. */ + if (cdarg != NULL) +@@ -928,7 +928,7 @@ captured_main (void *data) + /* Read the .gdbinit file in the current directory, *if* it isn't + the same as the $HOME/.gdbinit file (it should exist, also). */ + if (local_gdbinit && !inhibit_gdbinit) +- catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); ++ catch_command_errors (source_script, local_gdbinit, -1, RETURN_MASK_ALL); + + /* Now that all .gdbinit's have been read and all -d options have been + processed, we can read any scripts mentioned in SYMARG. +Index: gdb-7.3.50.20110722/gdb/python/py-auto-load.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/python/py-auto-load.c 2011-05-16 18:33:57.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/python/py-auto-load.c 2011-07-22 19:14:54.000000000 +0200 +@@ -284,7 +284,7 @@ source_section_scripts (struct objfile * + } + + opened = find_and_open_script (file, 1 /*search_path*/, +- &stream, &full_path); ++ &stream, &full_path, 1 /* from_tty */); + + /* If one script isn't found it's not uncommon for more to not be + found either. We don't want to print an error message for each +Index: gdb-7.3.50.20110722/gdb/cli/cli-cmds.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/cli/cli-cmds.h 2011-01-01 16:33:20.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/cli/cli-cmds.h 2011-07-22 19:14:25.000000000 +0200 +@@ -127,7 +127,8 @@ extern void source_script (char *, int); + /* Exported to objfiles.c. */ + + extern int find_and_open_script (const char *file, int search_path, +- FILE **streamp, char **full_path); ++ FILE **streamp, char **full_path, ++ int from_tty); + + /* Command tracing state. */ + diff --git a/gdb/patches/gdb-6.3-step-thread-exit-20050211-test.patch b/gdb/patches/gdb-6.3-step-thread-exit-20050211-test.patch new file mode 100644 index 000000000..11c2a446a --- /dev/null +++ b/gdb/patches/gdb-6.3-step-thread-exit-20050211-test.patch @@ -0,0 +1,188 @@ +2005-02-11 Jeff Johnston + + * testsuite/gdb.threads/step-thread-exit.c: New testcase. + * testsuite/gdb.threads/step-thread-exit.exp: Ditto. + +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.c 2008-12-08 22:21:26.000000000 +0100 +@@ -0,0 +1,50 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. */ ++ ++#include ++#include ++#include ++#include ++ ++void *thread_function (void *ptr) ++{ ++ int *x = (int *)ptr; ++ printf("In thread_function, *x is %d\n", *x); ++} /* thread_function_end */ ++ ++volatile int repeat = 0; ++ ++main() ++{ ++ int ret; ++ pthread_t th; ++ int i = 3; ++ ++ ret = pthread_create (&th, NULL, thread_function, &i); ++ do ++ { ++ repeat = 0; ++ sleep (3); /* sleep */ ++ } ++ while (repeat); ++ pthread_join (th, NULL); ++ return 0; ++} ++ ++ +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp 2008-12-08 22:22:14.000000000 +0100 +@@ -0,0 +1,123 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# 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. ++ ++# Check that GDB can step over a thread exit. ++ ++set testfile "step-thread-exit" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# Reset the debug file directory so we can't debug within the C library ++gdb_test "set debug-file-directory ." "" "" ++ ++# ++# Run to `main' where we begin our tests. ++# ++ ++if ![runto_main] then { ++ gdb_suppress_tests ++} ++ ++# FIXME: Currently the main thread will escape/exit before our thread finishes ++# without this setting. ++gdb_test "set scheduler-locking step" ++gdb_test "show scheduler-locking" "Mode for locking scheduler during execution is \"step\"." "check scheduler-locking first" ++ ++set sleep_line [expr [gdb_get_line_number "sleep"]] ++set end_line [expr [gdb_get_line_number "thread_function_end"]] ++ ++gdb_breakpoint "$end_line" ++gdb_test "continue" "Break.*thread_function.*" "continue to thread_function 1" ++ ++# Keep nexting until we cause the thread to exit. We expect the main ++# thread to be stopped and a message printed to tell us we have stepped ++# over the thread exit. ++set test "step over thread exit 1" ++gdb_test_multiple "next" "$test" { ++ -re "\}.*$gdb_prompt $" { ++ send_gdb "next\n" ++ exp_continue ++ } ++ -re "\[Thread .* exited\].*Program received signal SIGSTOP.*$gdb_prompt $" { ++ pass "$test" ++ } ++ -re "start_thread.*$gdb_prompt $" { ++ send_gdb "next\n" ++ exp_continue ++ } ++} ++ ++# Without this fixup we could end up in: ++# #0 0x00110416 in __kernel_vsyscall () ++# #1 0x0011de26 in __lll_unlock_wake_private () from /lib/libpthread.so.0 ++# #2 0x001179f4 in _L_unlock_3164 () from /lib/libpthread.so.0 ++# #3 0x00116f01 in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.0 ++# #4 0x08048531 in main () at ../.././gdb/testsuite/gdb.threads/step-thread-exit.c:39 ++gdb_breakpoint "$sleep_line" ++gdb_test "set repeat=1" "" "Get to the sleep function prepare 1" ++gdb_test "continue" "Break.*$sleep_line.*" "Get to the sleep function 1" ++ ++gdb_test "bt" "main.*$sleep_line.*" "backtrace after step 1" ++ ++runto_main ++gdb_test "show scheduler-locking" "Mode for locking scheduler during execution is \"step\"." "check scheduler-locking second" ++ ++gdb_breakpoint "$sleep_line" ++gdb_breakpoint "$end_line" ++set test "continue to thread_function 2" ++gdb_test_multiple "continue" "$test" { ++ -re "Break.*thread_function.*$gdb_prompt $" { ++ pass $test ++ } ++ -re "Break.*$sleep_line.*$gdb_prompt $" { ++ gdb_test "set repeat=1" "" "" ++ send_gdb "continue\n" ++ exp_continue ++ } ++} ++ ++# Keep nexting until we cause the thread to exit. In this case, we ++# expect the breakpoint in the main thread to have already triggered ++# and so we should stop there with a message that we stepped over ++# the thread exit. ++set test "step over thread exit 2" ++gdb_test_multiple "next" "$test" { ++ -re "\}.*$gdb_prompt $" { ++ send_gdb "next\n" ++ exp_continue ++ } ++ -re "\[Thread .* exited\].*Break.*$sleep_line.*$gdb_prompt $" { ++ pass "$test (breakpoint hit)" ++ } ++ -re "\[Thread .* exited\].*$gdb_prompt $" { ++ pass "$test (breakpoint not hit)" ++ } ++ -re "start_thread.*$gdb_prompt $" { ++ send_gdb "next\n" ++ exp_continue ++ } ++} ++ diff --git a/gdb/patches/gdb-6.3-test-dtorfix-20050121.patch b/gdb/patches/gdb-6.3-test-dtorfix-20050121.patch new file mode 100644 index 000000000..51308bce5 --- /dev/null +++ b/gdb/patches/gdb-6.3-test-dtorfix-20050121.patch @@ -0,0 +1,262 @@ +Index: gdb/testsuite/ChangeLog +2005-01-21 Jeff Johnston + + * gdb.cp/constructortest.exp: New test. + * gdb.cp/constructortest.cc: Ditto. + * gdb.cp/templates.exp: Change break of dtor to be fully quoted. + +2007-09-22 Jan Kratochvil + + * gdb.cp/constructortest.exp, gdb.cp/constructortest.cc: Test also the + `$delete' destructor variant. + +2007-09-25 Jan Kratochvil + + * gdb.cp/constructortest.exp: Delete the FIXME workaround of restarting + the whole GDB. + +2007-10-05 Jan Kratochvil + + * gdb.cp/constructortest.exp: Test BREAKPOINT_RE_SET for multiple PCs + by PIE. + * gdb.cp/constructortest.exp: Handle the change of settings breakpoints + always at all the ctor/dtor variants. + +[ Removed the `gdb.cp/templates.exp' patch. ] +[ Updated the patch for "(X location") of GDB-6.8+. ] + +--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc.fix Fri Jan 21 17:06:56 2005 ++++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc Fri Jan 21 17:05:18 2005 +@@ -0,0 +1,99 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. */ ++ ++class A ++{ ++ public: ++ A(); ++ ~A(); ++ int k; ++ private: ++ int x; ++}; ++ ++class B: public A ++{ ++ public: ++ B(); ++ private: ++ int y; ++}; ++ ++/* C and D are for the $delete destructor. */ ++ ++class C ++{ ++ public: ++ C(); ++ virtual ~C(); ++ private: ++ int x; ++}; ++ ++class D: public C ++{ ++ public: ++ D(); ++ private: ++ int y; ++}; ++ ++int main(int argc, char *argv[]) ++{ ++ A* a = new A; ++ B* b = new B; ++ D* d = new D; ++ delete a; ++ delete b; ++ delete d; ++ return 0; ++} ++ ++A::A() /* Constructor A */ ++{ ++ x = 1; /* First line A */ ++ k = 4; /* Second line A */ ++} ++ ++A::~A() /* Destructor A */ ++{ ++ x = 3; /* First line ~A */ ++ k = 6; /* Second line ~A */ ++} ++ ++B::B() ++{ ++ y = 2; /* First line B */ ++ k = 5; ++} ++ ++C::C() /* Constructor C */ ++{ ++ x = 1; /* First line C */ ++} ++ ++C::~C() /* Destructor C */ ++{ ++ x = 3; /* First line ~C */ ++} ++ ++D::D() ++{ ++ y = 2; /* First line D */ ++} +--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp.fix Fri Jan 21 17:07:02 2005 ++++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp Fri Jan 21 17:05:29 2005 +@@ -0,0 +1,130 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# Copyright 2005, 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. ++ ++# Check that GDB can break at multiple forms of constructors. ++ ++set testfile "constructortest" ++set srcfile ${testfile}.cc ++set binfile ${objdir}/${subdir}/${testfile} ++# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC ++# breakpoints. ++if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# ++# Run to `main' where we begin our tests. ++# ++ ++if ![runto_main] then { ++ gdb_suppress_tests ++} ++ ++# 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_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A" ++gdb_continue_to_breakpoint "First line A" ++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A" ++ ++# Now do the same for destructors ++gdb_test "break 'A::~A()'" "" ++ ++# Verify that we break for the A destructor two times ++# Once for delete a and once for delete b ++gdb_continue_to_breakpoint "First line ~A" ++gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A" ++gdb_continue_to_breakpoint "First line ~A" ++gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A" ++ ++ ++# Verify that we can break by line number in a constructor and find ++# both occurrences ++runto_main ++gdb_test "break 'A::A()'" "" "break in constructor A 2" ++gdb_continue_to_breakpoint "First line A" ++set second_line [gdb_get_line_number "Second line A"] ++# " (2 locations)" is displayed depending on G++ version. ++gdb_test "break $second_line" "Breakpoint .*, line $second_line\\..*" "break by line in constructor" ++gdb_continue_to_breakpoint "Second line A" ++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line" ++gdb_continue_to_breakpoint "Second line A" ++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line" ++ ++# Verify that we can break by line number in a destructor and find ++# both occurrences ++gdb_test "break 'A::~A()'" "" "break in constructor ~A 2" ++gdb_continue_to_breakpoint "First line ~A" ++set second_line_dtor [gdb_get_line_number "Second line ~A"] ++# " (2 locations)" is displayed depending on G++ version. ++gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor\\..*" "break by line in destructor" ++gdb_continue_to_breakpoint "Second line ~A" ++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line" ++# FIXME: Analyse this case better. ++gdb_continue_to_breakpoint "Second line ~A" ++gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2" ++gdb_continue_to_breakpoint "Second line ~A" ++gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line" ++ ++ ++# Test now the $delete destructors. ++ ++gdb_load ${binfile} ++runto_main ++ ++set first_line_dtor [gdb_get_line_number "First line ~C"] ++set define_line_dtor [gdb_get_line_number "Destructor C"] ++# Break on the various forms of the C::~C destructor ++# " ([23] locations)" is displayed depending on G++ version. ++gdb_test "break C\:\:~C" "Breakpoint .*, line ($define_line_dtor|$define_line_dtor)\\..*" "breaking on C::~C" ++gdb_continue_to_breakpoint "First line ~C" ++ ++# Verify that we can break by line number in a destructor and find ++# the $delete occurence ++ ++gdb_load ${binfile} ++delete_breakpoints ++ ++# " (3 locations)" is displayed depending on G++ version. ++gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor\\..*" "break by line in destructor" ++ ++# Run to `main' where we begin our tests. ++# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET. ++# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS. ++ ++if ![gdb_breakpoint main] { ++ gdb_suppress_tests ++} ++gdb_run_cmd ++set test "running to main" ++gdb_test_multiple "" $test { ++ -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++gdb_continue_to_breakpoint "First line ~C" diff --git a/gdb/patches/gdb-6.3-test-movedir-20050125.patch b/gdb/patches/gdb-6.3-test-movedir-20050125.patch new file mode 100644 index 000000000..4b05c1342 --- /dev/null +++ b/gdb/patches/gdb-6.3-test-movedir-20050125.patch @@ -0,0 +1,95 @@ +2005-01-25 Elena Zannoni + + * gdb.base/move-dir.exp: New test. + * gdb.base/move-dir.c: Ditto. + * gdb.base/move-dir.h: Ditto. + +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.c 2008-12-07 23:57:41.000000000 +0100 +@@ -0,0 +1,10 @@ ++#include ++#include ++#include "move-dir.h" ++ ++int main() { ++ const char* hw = "hello world."; ++ printf ("%s\n", hw);; ++ other(); ++} ++ +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.exp 2008-12-07 10:13:01.000000000 +0100 +@@ -0,0 +1,57 @@ ++# 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. ++ ++set testfile "move-dir" ++set srcfile ${testfile}.c ++set incfile ${testfile}.h ++set binfile ${objdir}/${subdir}/${testfile} ++ ++set testdir "${objdir}/${subdir}/incdir" ++ ++remote_exec build "mkdir $testdir" ++remote_exec build "cp ${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}" ++remote_exec build "cp ${srcdir}/${subdir}/${incfile} ${testdir}" ++ ++set additional_flags "additional_flags=-I${subdir}/incdir" ++ ++if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++# Create and source the file that provides information about the compiler ++# used to compile the test case. ++ ++if [get_compiler_info ${binfile}] { ++ return -1; ++} ++ ++ ++set oldtimeout $timeout ++set timeout [expr "$timeout + 60"] ++ ++# Start with a fresh gdb. ++ ++gdb_exit ++gdb_start ++gdb_test "cd ../.." "" "" ++gdb_load ${binfile} ++gdb_test "list main" ".*hw.*other.*" "found main" ++gdb_test "list other" ".*ostring.*" "found include file" ++ ++ ++set timeout $oldtimeout ++return 0 +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.h 2008-12-07 10:13:01.000000000 +0100 +@@ -0,0 +1,7 @@ ++#include ++ ++void other() { ++ const char* ostring = "other"; ++ printf ("%s\n", ostring);; ++} ++ diff --git a/gdb/patches/gdb-6.3-test-pie-20050107.patch b/gdb/patches/gdb-6.3-test-pie-20050107.patch new file mode 100644 index 000000000..0b4a2dbe4 --- /dev/null +++ b/gdb/patches/gdb-6.3-test-pie-20050107.patch @@ -0,0 +1,2089 @@ +Index: gdb-7.2.50.20110320/gdb/testsuite/configure.ac +=================================================================== +--- gdb-7.2.50.20110320.orig/gdb/testsuite/configure.ac 2011-03-03 17:57:55.000000000 +0100 ++++ gdb-7.2.50.20110320/gdb/testsuite/configure.ac 2011-03-20 20:21:43.000000000 +0100 +@@ -97,6 +97,6 @@ AC_OUTPUT([Makefile \ + gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \ + gdb.hp/gdb.defects/Makefile \ + gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \ +- gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile \ ++ gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \ + gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile \ + gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile]) +Index: gdb-7.2.50.20110320/gdb/testsuite/configure +=================================================================== +--- gdb-7.2.50.20110320.orig/gdb/testsuite/configure 2011-03-03 17:57:55.000000000 +0100 ++++ gdb-7.2.50.20110320/gdb/testsuite/configure 2011-03-20 20:21:43.000000000 +0100 +@@ -3448,7 +3448,7 @@ done + + + +-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" ++ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" + + cat >confcache <<\_ACEOF + # This file is a shell script that caches the results of configure +@@ -4173,6 +4173,7 @@ do + "gdb.opencl/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opencl/Makefile" ;; + "gdb.opt/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opt/Makefile" ;; + "gdb.pascal/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pascal/Makefile" ;; ++ "gdb.pie/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;; + "gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;; + "gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;; + "gdb.stabs/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.stabs/Makefile" ;; +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.c 2011-03-20 20:21:43.000000000 +0100 +@@ -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 ++ ++int should_exit = 0; ++ ++int main () ++{ ++ int local_i = 0; ++ ++ while (! should_exit) ++ { ++ local_i++; ++ } ++ return 0; ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach2.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach2.c 2011-03-20 20:21:43.000000000 +0100 +@@ -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 ++#include ++#include ++ ++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); ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.c 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,146 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 */ ++ ++#ifdef vxworks ++ ++# include ++ ++/* VxWorks does not supply atoi. */ ++static int ++atoi (z) ++ char *z; ++{ ++ int i = 0; ++ ++ while (*z >= '0' && *z <= '9') ++ i = i * 10 + (*z++ - '0'); ++ return i; ++} ++ ++/* I don't know of any way to pass an array to VxWorks. This function ++ can be called directly from gdb. */ ++ ++vxmain (arg) ++char *arg; ++{ ++ char *argv[2]; ++ ++ argv[0] = ""; ++ argv[1] = arg; ++ main (2, argv, (char **) 0); ++} ++ ++#else /* ! vxworks */ ++# include ++# include ++#endif /* ! vxworks */ ++ ++#ifdef PROTOTYPES ++extern int marker1 (void); ++extern int marker2 (int a); ++extern void marker3 (char *a, char *b); ++extern void marker4 (long d); ++#else ++extern int marker1 (); ++extern int marker2 (); ++extern void marker3 (); ++extern void marker4 (); ++#endif ++ ++/* ++ * This simple classical example of recursion is useful for ++ * testing stack backtraces and such. ++ */ ++ ++#ifdef PROTOTYPES ++int factorial(int); ++ ++int ++main (int argc, char **argv, char **envp) ++#else ++int ++main (argc, argv, envp) ++int argc; ++char *argv[], **envp; ++#endif ++{ ++#ifdef usestubs ++ set_debug_traps(); /* set breakpoint 5 here */ ++ breakpoint(); ++#endif ++ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ ++ fprintf (stderr, "usage: factorial \n"); ++ return 1; ++ } ++ printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */ ++ /* set breakpoint 12 here */ ++ marker1 (); /* set breakpoint 11 here */ ++ marker2 (43); /* set breakpoint 20 here */ ++ marker3 ("stack", "trace"); /* set breakpoint 21 here */ ++ marker4 (177601976L); ++ argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */ ++ return argc; /* set breakpoint 10 here */ ++} ++ ++#ifdef PROTOTYPES ++int factorial (int value) ++#else ++int factorial (value) ++int value; ++#endif ++{ ++ if (value > 1) { /* set breakpoint 7 here */ ++ value *= factorial (value - 1); ++ } ++ return (value); /* set breakpoint 19 here */ ++} ++ ++#ifdef PROTOTYPES ++int multi_line_if_conditional (int a, int b, int c) ++#else ++int multi_line_if_conditional (a, b, c) ++ int a, b, c; ++#endif ++{ ++ if (a /* set breakpoint 3 here */ ++ && b ++ && c) ++ return 0; ++ else ++ return 1; ++} ++ ++#ifdef PROTOTYPES ++int multi_line_while_conditional (int a, int b, int c) ++#else ++int multi_line_while_conditional (a, b, c) ++ int a, b, c; ++#endif ++{ ++ while (a /* set breakpoint 4 here */ ++ && b ++ && c) ++ { ++ a--, b--, c--; ++ } ++ return 0; ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break1.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break1.c 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,44 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 */ ++ ++/* The code for this file was extracted from the gdb testsuite ++ testcase "break.c". */ ++ ++/* The following functions do nothing useful. They are included ++ simply as places to try setting breakpoints at. They are ++ explicitly "one-line functions" to verify that this case works ++ (some versions of gcc have or have had problems with this). ++ ++ These functions are in a separate source file to prevent an ++ optimizing compiler from inlining them and optimizing them away. */ ++ ++#ifdef PROTOTYPES ++int marker1 (void) { return (0); } /* set breakpoint 15 here */ ++int marker2 (int a) { return (1); } /* set breakpoint 8 here */ ++void marker3 (char *a, char *b) {} /* set breakpoint 17 here */ ++void marker4 (long d) {} /* set breakpoint 14 here */ ++#else ++int marker1 () { return (0); } /* set breakpoint 16 here */ ++int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */ ++void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */ ++void marker4 (d) long d; {} /* set breakpoint 13 here */ ++#endif +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/coremaker.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/coremaker.c 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,142 @@ ++/* Copyright 1992, 1993, 1994, 1995, 1996, 1999 ++ 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 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. */ ++ ++/* Simple little program that just generates a core dump from inside some ++ nested function calls. */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifndef __STDC__ ++#define const /**/ ++#endif ++ ++#define MAPSIZE (8 * 1024) ++ ++/* Don't make these automatic vars or we will have to walk back up the ++ stack to access them. */ ++ ++char *buf1; ++char *buf2; ++ ++int coremaker_data = 1; /* In Data section */ ++int coremaker_bss; /* In BSS section */ ++ ++const int coremaker_ro = 201; /* In Read-Only Data section */ ++ ++/* Note that if the mapping fails for any reason, we set buf2 ++ to -1 and the testsuite notices this and reports it as ++ a failure due to a mapping error. This way we don't have ++ to test for specific errors when running the core maker. */ ++ ++void ++mmapdata () ++{ ++ int j, fd; ++ ++ /* Allocate and initialize a buffer that will be used to write ++ the file that is later mapped in. */ ++ ++ buf1 = (char *) malloc (MAPSIZE); ++ for (j = 0; j < MAPSIZE; ++j) ++ { ++ buf1[j] = j; ++ } ++ ++ /* Write the file to map in */ ++ ++ fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666); ++ if (fd == -1) ++ { ++ perror ("coremmap.data open failed"); ++ buf2 = (char *) -1; ++ return; ++ } ++ write (fd, buf1, MAPSIZE); ++ ++ /* Now map the file into our address space as buf2 */ ++ ++ buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); ++ if (buf2 == (char *) -1) ++ { ++ perror ("mmap failed"); ++ return; ++ } ++ ++ /* Verify that the original data and the mapped data are identical. ++ If not, we'd rather fail now than when trying to access the mapped ++ data from the core file. */ ++ ++ for (j = 0; j < MAPSIZE; ++j) ++ { ++ if (buf1[j] != buf2[j]) ++ { ++ fprintf (stderr, "mapped data is incorrect"); ++ buf2 = (char *) -1; ++ return; ++ } ++ } ++} ++ ++void ++func2 () ++{ ++ int coremaker_local[5]; ++ int i; ++ ++#ifdef SA_FULLDUMP ++ /* Force a corefile that includes the data section for AIX. */ ++ { ++ struct sigaction sa; ++ ++ sigaction (SIGABRT, (struct sigaction *)0, &sa); ++ sa.sa_flags |= SA_FULLDUMP; ++ sigaction (SIGABRT, &sa, (struct sigaction *)0); ++ } ++#endif ++ ++ /* Make sure that coremaker_local doesn't get optimized away. */ ++ for (i = 0; i < 5; i++) ++ coremaker_local[i] = i; ++ coremaker_bss = 0; ++ for (i = 0; i < 5; i++) ++ coremaker_bss += coremaker_local[i]; ++ coremaker_data = coremaker_ro + 1; ++ abort (); ++} ++ ++void ++func1 () ++{ ++ func2 (); ++} ++ ++int main () ++{ ++ mmapdata (); ++ func1 (); ++ return 0; ++} ++ +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.exp 2011-03-20 20:25:53.000000000 +0100 +@@ -0,0 +1,417 @@ ++# Copyright 1997, 1999, 2002 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. */ ++ ++# 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 "hppa*-*-hpux*"] } { ++ return 0 ++} ++ ++# are we on a target board ++if [is_remote target] then { ++ return 0 ++} ++ ++set testfile "attach" ++set srcfile ${testfile}.c ++set srcfile2 ${testfile}2.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binfile2 ${objdir}/${subdir}/${testfile}2 ++set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}] ++set cleanupfile ${objdir}/${subdir}/${testfile}.awk ++ ++#execute_anywhere "rm -f ${binfile} ${binfile2}" ++remote_exec build "rm -f ${binfile} ${binfile2}" ++# For debugging this test ++# ++#log_user 1 ++ ++# Clean out any old files from past runs. ++# ++remote_exec build "${cleanupfile}" ++ ++# build the first test case ++# ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } { ++ 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 {debug "additional_flags= -fpie -pie"}] != "" } { ++ 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 ++ ++ # 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 ++ ++ # Verify that we cannot attach to nonsense. ++ # ++ send_gdb "attach abc\n" ++ gdb_expect { ++ -re ".*Illegal process-id: abc.*$gdb_prompt $"\ ++ {pass "attach to nonsense is prohibited"} ++ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ ++ { ++ # Response expected from /proc-based systems. ++ pass "attach to nonsense is prohibited" ++ } ++ -re "Attaching to.*$gdb_prompt $"\ ++ {fail "attach to nonsense is prohibited (bogus pid allowed)"} ++ -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"} ++ timeout {fail "(timeout) attach to nonsense is prohibited"} ++ } ++ ++ # Verify that we cannot attach to what appears to be a valid ++ # process ID, but is a process that doesn't exist. Traditionally, ++ # most systems didn't have a process with ID 0, so we take that as ++ # the default. However, there are a few exceptions. ++ # ++ set boguspid 0 ++ if { [istarget "*-*-*bsd*"] } { ++ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead ++ # (which should have the desired effect on any version of ++ # FreeBSD, and probably other *BSD's too). ++ set boguspid -1 ++ } ++ send_gdb "attach $boguspid\n" ++ gdb_expect { ++ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\ ++ { ++ # Response expected on ptrace-based systems (i.e. HP-UX 10.20). ++ pass "attach to nonexistent process is prohibited" ++ } ++ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\ ++ { ++ # Response expected on ttrace-based systems (i.e. HP-UX 11.0). ++ pass "attach to nonexistent process is prohibited" ++ } ++ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\ ++ {pass "attach to nonexistent process is prohibited"} ++ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\ ++ {pass "attach to nonexistent process is prohibited"} ++ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ ++ { ++ # Response expected from /proc-based systems. ++ pass "attach to nonexistent process is prohibited" ++ } ++ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"} ++ timeout { ++ fail "(timeout) attach to nonexistent process is prohibited" ++ } ++ } ++ ++ # Verify that we can attach to the process by first giving its ++ # executable name via the file command, and using attach with ++ # the process ID. ++ # ++ # (Actually, the test system appears to do this automatically ++ # for us. So, we must also be prepared to be asked if we want ++ # to discard an existing set of symbols.) ++ # ++ send_gdb "file $binfile\n" ++ gdb_expect { ++ -re "Load new symbol table from.*y or n.*$" { ++ send_gdb "y\n" ++ gdb_expect { ++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\ ++ {pass "(re)set file, before attach1"} ++ -re "$gdb_prompt $" {fail "(re)set file, before attach1"} ++ timeout {fail "(timeout) (re)set file, before attach1"} ++ } ++ } ++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\ ++ {pass "set file, before attach1"} ++ -re "$gdb_prompt $" {fail "set file, before attach1"} ++ timeout {fail "(timeout) set file, before attach1"} ++ } ++ ++ send_gdb "attach $testpid\n" ++ gdb_expect { ++ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\ ++ {pass "attach1, after setting file"} ++ -re "$gdb_prompt $" {fail "attach1, after setting file"} ++ timeout {fail "(timeout) attach1, after setting file"} ++ } ++ ++ # Verify that we can "see" the variable "should_exit" in the ++ # program, and that it is zero. ++ # ++ send_gdb "print should_exit\n" ++ gdb_expect { ++ -re ".* = 0.*$gdb_prompt $"\ ++ {pass "after attach1, print should_exit"} ++ -re "$gdb_prompt $" {fail "after attach1, print should_exit"} ++ timeout {fail "(timeout) after attach1, print should_exit"} ++ } ++ ++ # Detach the process. ++ # ++ send_gdb "detach\n" ++ gdb_expect { ++ -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\ ++ {pass "attach1 detach"} ++ -re "$gdb_prompt $" {fail "attach1 detach"} ++ timeout {fail "(timeout) attach1 detach"} ++ } ++ ++ # Wait a bit for gdb to finish detaching ++ # ++ exec sleep 5 ++ ++ # Purge the symbols from gdb's brain. (We want to be certain ++ # the next attach, which won't be preceded by a "file" command, ++ # is really getting the executable file without our help.) ++ # ++ set old_timeout $timeout ++ set timeout 15 ++ send_gdb "file\n" ++ gdb_expect { ++ -re ".*gdb internal error.*$" { ++ fail "Internal error, prob. Memory corruption" ++ } ++ -re "No executable file now.*Discard symbol table.*y or n.*$" { ++ send_gdb "y\n" ++ gdb_expect { ++ -re "No symbol file now.*$gdb_prompt $"\ ++ {pass "attach1, purging symbols after detach"} ++ -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"} ++ timeout {fail "(timeout) attach1, purging symbols after detach"} ++ } ++ } ++ -re "$gdb_prompt $" {fail "attach1, purging file after detach"} ++ timeout { ++ fail "(timeout) attach1, purging file after detach" ++ } ++ } ++ set timeout $old_timeout ++ ++ # Verify that we can attach to the process just by giving the ++ # process ID. ++ # ++ send_gdb "attach $testpid\n" ++ gdb_expect { ++ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ ++ {pass "attach2"} ++ -re "$gdb_prompt $" {fail "attach2"} ++ timeout {fail "(timeout) attach2"} ++ } ++ ++ # Verify that we can modify the variable "should_exit" in the ++ # program. ++ # ++ send_gdb "set should_exit=1\n" ++ gdb_expect { ++ -re "$gdb_prompt $" {pass "after attach2, set should_exit"} ++ timeout {fail "(timeout) after attach2, 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 attach2, set tbreak postloop"} ++ -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"} ++ timeout {fail "(timeout) after attach2, set tbreak postloop"} ++ } ++ send_gdb "continue\n" ++ gdb_expect { ++ -re "main.*at.*$srcfile:19.*$gdb_prompt $"\ ++ {pass "after attach2, reach tbreak postloop"} ++ -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"} ++ timeout {fail "(timeout) after attach2, reach tbreak postloop"} ++ } ++ ++ # Allow the test process to exit, to cleanup after ourselves. ++ # ++ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach2, 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 ++ ++ # 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.) ++ # ++ send_gdb "dir ${objdir}/${subdir}\n" ++ gdb_expect { ++ -re ".*Source directories searched: .*$gdb_prompt $"\ ++ {pass "set source path"} ++ -re "$gdb_prompt $" {fail "set source path"} ++ timeout {fail "(timeout) set source path"} ++ } ++ ++ send_gdb "cd /tmp\n" ++ gdb_expect { ++ -re ".*Working directory /tmp.*$gdb_prompt $"\ ++ {pass "cd away from process' a.out"} ++ -re "$gdb_prompt $" {fail "cd away from process' a.out"} ++ timeout {fail "(timeout) cd away from process' a.out"} ++ } ++ ++ # Explicitly flush out any knowledge of the previous attachment. ++ send_gdb "symbol\n" ++ gdb_expect { ++ -re ".*Discard symbol table from.*y or n. $"\ ++ {send_gdb "y\n" ++ gdb_expect { ++ -re ".*No symbol file now.*$gdb_prompt $"\ ++ {pass "before attach3, flush symbols"} ++ -re "$gdb_prompt $" {fail "before attach3, flush symbols"} ++ timeout {fail "(timeout) before attach3, flush symbols"} ++ } ++ } ++ -re ".*No symbol file now.*$gdb_prompt $"\ ++ {pass "before attach3, flush symbols"} ++ -re "$gdb_prompt $" {fail "before attach3, flush symbols"} ++ timeout {fail "(timeout) before attach3, flush symbols"} ++ } ++ send_gdb "exec\n" ++ gdb_expect { ++ -re ".*No executable file now.*$gdb_prompt $"\ ++ {pass "before attach3, flush exec"} ++ -re "$gdb_prompt $" {fail "before attach3, flush exec"} ++ timeout {fail "(timeout) before attach3, flush exec"} ++ } ++ ++ send_gdb "attach $testpid\n" ++ gdb_expect { ++ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ ++ {pass "attach when process' a.out not in cwd"} ++ -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"} ++ timeout {fail "(timeout) attach when process' a.out not in cwd"} ++ } ++ ++ send_gdb "kill\n" ++ gdb_expect { ++ -re ".*Kill the program being debugged.*y or n. $"\ ++ {send_gdb "y\n" ++ gdb_expect { ++ -re "$gdb_prompt $" {pass "after attach3, exit"} ++ timeout {fail "(timeout) after attach3, exit"} ++ } ++ } ++ -re "$gdb_prompt $" {fail "after attach3, exit"} ++ timeout {fail "(timeout) after attach3, exit"} ++ } ++ ++ # Another "don't leave a process around" ++ remote_exec build "kill -9 ${testpid}" ++} ++ ++proc do_call_attach_tests {} { ++ global gdb_prompt ++ global binfile2 ++ ++ # Start the program running and then wait for a bit, to be sure ++ # that it can be attached to. ++ # ++ set testpid [eval exec $binfile2 &] ++ exec sleep 2 ++ ++ # Attach ++ # ++ gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary" ++ send_gdb "attach $testpid\n" ++ gdb_expect { ++ -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" { ++ fail "attach call, read register 3 error" ++ } ++ -re "Attaching to.*process $testpid.*$gdb_prompt $" { ++ # libc is relocated, not relocated, therefore not printed. ++ pass "attach call" ++ } ++ -re "$gdb_prompt $" {fail "attach call"} ++ timeout {fail "(timeout) attach call"} ++ } ++ ++ # See if other registers are problems ++ # ++ send_gdb "i r r3\n" ++ gdb_expect { ++ -re ".*warning: reading register.*$gdb_prompt $" { ++ pass "CHFts23490: known bug" ++ } ++ -re ".*r3.*$gdb_prompt $" { ++ pass "Bug fixed, Yayyy!" ++ } ++ timeout { fail "timeout on info reg" } ++ } ++ ++ # 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 ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# 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 ++gdb_start ++ ++gdb_reinitialize_dir $srcdir/$subdir ++do_call_attach_tests ++ ++return 0 +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.exp 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,966 @@ ++# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, ++# 2000, 2002, 2003, 2004 ++# 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 ++ ++# This file was written by Rob Savoye. (rob@cygnus.com) ++ ++# Test the same stuff but with PIE executables ++ ++set testfile "break" ++set srcfile ${testfile}.c ++set srcfile1 ${testfile}1.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if [target_info exists gdb_stub] { ++ gdb_step_for_stub; ++} ++# ++# test simple breakpoint setting commands ++# ++ ++# Test deleting all breakpoints when there are none installed, ++# GDB should not prompt for confirmation. ++# Note that gdb-init.exp provides a "delete_breakpoints" proc ++# for general use elsewhere. ++ ++send_gdb "delete breakpoints\n" ++gdb_expect { ++ -re "Delete all breakpoints.*$" { ++ send_gdb "y\n" ++ gdb_expect { ++ -re "$gdb_prompt $" { ++ fail "Delete all breakpoints when none (unexpected prompt)" ++ } ++ timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" } ++ } ++ } ++ -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" } ++ timeout { fail "Delete all breakpoints when none (timeout)" } ++} ++ ++# ++# test break at function ++# ++gdb_test "break main" \ ++ "Breakpoint.*at.* file .*$srcfile, line.*" \ ++ "breakpoint function" ++ ++# ++# test break at quoted function ++# ++gdb_test "break \"marker2\"" \ ++ "Breakpoint.*at.* file .*$srcfile1, line.*" \ ++ "breakpoint quoted function" ++ ++# ++# test break at function in file ++# ++gdb_test "break $srcfile:factorial" \ ++ "Breakpoint.*at.* file .*$srcfile, line.*" \ ++ "breakpoint function in file" ++ ++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] ++ ++# ++# test break at line number ++# ++# Note that the default source file is the last one whose source text ++# was printed. For native debugging, before we've executed the ++# program, this is the file containing main, but for remote debugging, ++# it's wherever the processor was stopped when we connected to the ++# board. So, to be sure, we do a list command. ++# ++gdb_test "list main" \ ++ ".*main \\(argc, argv, envp\\).*" \ ++ "use `list' to establish default source file" ++gdb_test "break $bp_location1" \ ++ "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ ++ "breakpoint line number" ++ ++# ++# test duplicate breakpoint ++# ++gdb_test "break $bp_location1" \ ++ "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \ ++ "breakpoint duplicate" ++ ++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] ++ ++# ++# test break at line number in file ++# ++gdb_test "break $srcfile:$bp_location2" \ ++ "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ ++ "breakpoint line number in file" ++ ++set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] ++set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] ++ ++# ++# Test putting a break at the start of a multi-line if conditional. ++# Verify the breakpoint was put at the start of the conditional. ++# ++gdb_test "break multi_line_if_conditional" \ ++ "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ ++ "breakpoint at start of multi line if conditional" ++ ++gdb_test "break multi_line_while_conditional" \ ++ "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ ++ "breakpoint at start of multi line while conditional" ++ ++set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] ++set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] ++ ++# ++# check to see what breakpoints are set ++# ++if [target_info exists gdb_stub] { ++ set main_line $bp_location5 ++} else { ++ set main_line $bp_location6 ++} ++ ++if {$hp_aCC_compiler} { ++ set proto "\\(int\\)" ++} else { ++ set proto "" ++} ++ ++set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] ++set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] ++set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] ++ ++# Test a pending breakpoint in PIE executable does not crash later GDB. ++gdb_breakpoint "non_existent_function" allow-pending ++ ++gdb_test "info break" \ ++ "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).* ++\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.* ++\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4.* ++\[0-9\]+\[\t \]+breakpoint keep y.* *non_existent_function" \ ++ "breakpoint info" ++ ++# FIXME: The rest of this test doesn't work with anything that can't ++# handle arguments. ++# Huh? There doesn't *appear* to be anything that passes arguments ++# below. ++if [istarget "mips-idt-*"] then { ++ return ++} ++ ++# ++# run until the breakpoint at main is hit. For non-stubs-using targets. ++# ++if ![target_info exists use_gdb_stub] { ++ if [istarget "*-*-vxworks*"] then { ++ send_gdb "run vxmain \"2\"\n" ++ set timeout 120 ++ verbose "Timeout is now $timeout seconds" 2 ++ } else { ++ send_gdb "run\n" ++ } ++ gdb_expect { ++ -re "The program .* has been started already.*y or n. $" { ++ send_gdb "y\n" ++ exp_continue ++ } ++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ ++ { pass "run until function breakpoint" } ++ -re ".*$gdb_prompt $" { fail "run until function breakpoint" } ++ timeout { fail "run until function breakpoint (timeout)" } ++ } ++} else { ++ if ![target_info exists gdb_stub] { ++ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue" ++ } ++} ++ ++# ++# run until the breakpoint at a line number ++# ++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ ++ "run until breakpoint set at a line number" ++ ++# ++# Run until the breakpoint set in a function in a file ++# ++for {set i 6} {$i >= 1} {incr i -1} { ++ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ ++ "run until file:function($i) breakpoint" ++} ++ ++# ++# Run until the breakpoint set at a quoted function ++# ++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \ ++ "run until quoted breakpoint" ++# ++# run until the file:function breakpoint at a line number in a file ++# ++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ ++ "run until file:linenum breakpoint" ++ ++# Test break at offset +1 ++set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] ++ ++gdb_test "break +1" \ ++ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ ++ "breakpoint offset +1" ++ ++# Check to see if breakpoint is hit when stepped onto ++ ++gdb_test "step" \ ++ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ ++ "step onto breakpoint" ++ ++# ++# delete all breakpoints so we can start over, course this can be a test too ++# ++delete_breakpoints ++ ++# ++# test temporary breakpoint at function ++# ++ ++gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function" ++ ++# ++# test break at function in file ++# ++ ++gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \ ++ "Temporary breakpoint function in file" ++ ++# ++# test break at line number ++# ++send_gdb "tbreak $bp_location1\n" ++gdb_expect { ++ -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } ++ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } ++ timeout { fail "breakpoint line number #1 (timeout)" } ++} ++ ++gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2" ++ ++# ++# test break at line number in file ++# ++send_gdb "tbreak $srcfile:$bp_location2\n" ++gdb_expect { ++ -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } ++ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } ++ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" } ++} ++ ++set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] ++gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2" ++ ++# ++# check to see what breakpoints are set (temporary this time) ++# ++gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\] ++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ ++ "Temporary breakpoint info" ++ ++ ++#*********** ++ ++# Verify that catchpoints for fork, vfork and exec don't trigger ++# inappropriately. (There are no calls to those system functions ++# in this test program.) ++# ++if ![runto_main] then { fail "break tests suppressed" } ++ ++send_gdb "catch\n" ++gdb_expect { ++ -re "Catch requires an event name.*$gdb_prompt $"\ ++ {pass "catch requires an event name"} ++ -re "$gdb_prompt $"\ ++ {fail "catch requires an event name"} ++ timeout {fail "(timeout) catch requires an event name"} ++} ++ ++ ++set name "set catch fork, never expected to trigger" ++send_gdb "catch fork\n" ++gdb_expect { ++ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $" ++ {pass $name} ++ -re "Catch of fork not yet implemented.*$gdb_prompt $" ++ {pass $name} ++ -re "$gdb_prompt $" ++ {fail $name} ++ timeout {fail "(timeout) $name"} ++} ++ ++ ++set name "set catch vfork, never expected to trigger" ++send_gdb "catch vfork\n" ++ ++# If we are on HP-UX 10.20, we expect an error message to be ++# printed if we type "catch vfork" at the gdb gdb_prompt. This is ++# because on HP-UX 10.20, we cannot catch vfork events. ++ ++if [istarget "hppa*-hp-hpux10.20"] then { ++ gdb_expect { ++ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $" ++ {pass $name} ++ -re "$gdb_prompt $" ++ {fail $name} ++ timeout {fail "(timeout) $name"} ++ } ++} else { ++ gdb_expect { ++ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $" ++ {pass $name} ++ -re "Catch of vfork not yet implemented.*$gdb_prompt $" ++ {pass $name} ++ -re "$gdb_prompt $" ++ {fail $name} ++ timeout {fail "(timeout) $name"} ++ } ++} ++ ++set name "set catch exec, never expected to trigger" ++send_gdb "catch exec\n" ++gdb_expect { ++ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $" ++ {pass $name} ++ -re "Catch of exec not yet implemented.*$gdb_prompt $" ++ {pass $name} ++ -re "$gdb_prompt $" {fail $name} ++ timeout {fail "(timeout) $name"} ++} ++ ++# Verify that GDB responds gracefully when asked to set a breakpoint ++# on a nonexistent source line. ++# ++send_gdb "break 999\n" ++gdb_expect { ++ -re "No line 999 in file .*$gdb_prompt $"\ ++ {pass "break on non-existent source line"} ++ -re "$gdb_prompt $"\ ++ {fail "break on non-existent source line"} ++ timeout {fail "(timeout) break on non-existent source line"} ++} ++ ++# Run to the desired default location. If not positioned here, the ++# tests below don't work. ++# ++gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1" ++ ++ ++# Verify that GDB allows one to just say "break", which is treated ++# as the "default" breakpoint. Note that GDB gets cute when printing ++# the informational message about other breakpoints at the same ++# location. We'll hit that bird with this stone too. ++# ++send_gdb "break\n" ++gdb_expect { ++ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\ ++ {pass "break on default location, 1st time"} ++ -re "$gdb_prompt $"\ ++ {fail "break on default location, 1st time"} ++ timeout {fail "(timeout) break on default location, 1st time"} ++} ++ ++send_gdb "break\n" ++gdb_expect { ++ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ ++ {pass "break on default location, 2nd time"} ++ -re "$gdb_prompt $"\ ++ {fail "break on default location, 2nd time"} ++ timeout {fail "(timeout) break on default location, 2nd time"} ++} ++ ++send_gdb "break\n" ++gdb_expect { ++ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ ++ {pass "break on default location, 3rd time"} ++ -re "$gdb_prompt $"\ ++ {fail "break on default location, 3rd time"} ++ timeout {fail "(timeout) break on default location, 3rd time"} ++} ++ ++send_gdb "break\n" ++gdb_expect { ++ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ ++ {pass "break on default location, 4th time"} ++ -re "$gdb_prompt $"\ ++ {fail "break on default location, 4th time"} ++ timeout {fail "(timeout) break on default location, 4th time"} ++} ++ ++# Verify that a "silent" breakpoint can be set, and that GDB is indeed ++# "silent" about its triggering. ++# ++if ![runto_main] then { fail "break tests suppressed" } ++ ++send_gdb "break $bp_location1\n" ++gdb_expect { ++ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\ ++ {pass "set to-be-silent break bp_location1"} ++ -re "$gdb_prompt $"\ ++ {fail "set to-be-silent break bp_location1"} ++ timeout {fail "(timeout) set to-be-silent break bp_location1"} ++} ++ ++send_gdb "commands $expect_out(1,string)\n" ++send_gdb "silent\n" ++send_gdb "end\n" ++gdb_expect { ++ -re ".*$gdb_prompt $"\ ++ {pass "set silent break bp_location1"} ++ timeout {fail "(timeout) set silent break bp_location1"} ++} ++ ++send_gdb "info break $expect_out(1,string)\n" ++gdb_expect { ++ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\ ++ {pass "info silent break bp_location1"} ++ -re "$gdb_prompt $"\ ++ {fail "info silent break bp_location1"} ++ timeout {fail "(timeout) info silent break bp_location1"} ++} ++send_gdb "continue\n" ++gdb_expect { ++ -re "Continuing.\r\n$gdb_prompt $"\ ++ {pass "hit silent break bp_location1"} ++ -re "$gdb_prompt $"\ ++ {fail "hit silent break bp_location1"} ++ timeout {fail "(timeout) hit silent break bp_location1"} ++} ++send_gdb "bt\n" ++gdb_expect { ++ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\ ++ {pass "stopped for silent break bp_location1"} ++ -re "$gdb_prompt $"\ ++ {fail "stopped for silent break bp_location1"} ++ timeout {fail "(timeout) stopped for silent break bp_location1"} ++} ++ ++# Verify that GDB can at least parse a breakpoint with the ++# "thread" keyword. (We won't attempt to test here that a ++# thread-specific breakpoint really triggers appropriately. ++# The gdb.threads subdirectory contains tests for that.) ++# ++set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] ++send_gdb "break $bp_location12 thread 999\n" ++gdb_expect { ++ -re "Unknown thread 999.*$gdb_prompt $"\ ++ {pass "thread-specific breakpoint on non-existent thread disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "thread-specific breakpoint on non-existent thread disallowed"} ++ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"} ++} ++send_gdb "break $bp_location12 thread foo\n" ++gdb_expect { ++ -re "Junk after thread keyword..*$gdb_prompt $"\ ++ {pass "thread-specific breakpoint on bogus thread ID disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "thread-specific breakpoint on bogus thread ID disallowed"} ++ timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"} ++} ++ ++# Verify that GDB responds gracefully to a breakpoint command with ++# trailing garbage. ++# ++send_gdb "break $bp_location12 foo\n" ++gdb_expect { ++ -re "Junk at end of arguments..*$gdb_prompt $"\ ++ {pass "breakpoint with trailing garbage disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "breakpoint with trailing garbage disallowed"} ++ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"} ++} ++ ++# Verify that GDB responds gracefully to a "clear" command that has ++# no matching breakpoint. (First, get us off the current source line, ++# which we know has a breakpoint.) ++# ++send_gdb "next\n" ++gdb_expect { ++ -re ".*$gdb_prompt $"\ ++ {pass "step over breakpoint"} ++ timeout {fail "(timeout) step over breakpoint"} ++} ++send_gdb "clear 81\n" ++gdb_expect { ++ -re "No breakpoint at 81..*$gdb_prompt $"\ ++ {pass "clear line has no breakpoint disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "clear line has no breakpoint disallowed"} ++ timeout {fail "(timeout) clear line has no breakpoint disallowed"} ++} ++send_gdb "clear\n" ++gdb_expect { ++ -re "No breakpoint at this line..*$gdb_prompt $"\ ++ {pass "clear current line has no breakpoint disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "clear current line has no breakpoint disallowed"} ++ timeout {fail "(timeout) clear current line has no breakpoint disallowed"} ++} ++ ++# Verify that we can set and clear multiple breakpoints. ++# ++# We don't test that it deletes the correct breakpoints. We do at ++# least test that it deletes more than one breakpoint. ++# ++gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1" ++gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2" ++gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*} ++ ++# Verify that a breakpoint can be set via a convenience variable. ++# ++send_gdb "set \$foo=$bp_location11\n" ++gdb_expect { ++ -re "$gdb_prompt $"\ ++ {pass "set convenience variable \$foo to bp_location11"} ++ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"} ++} ++send_gdb "break \$foo\n" ++gdb_expect { ++ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\ ++ {pass "set breakpoint via convenience variable"} ++ -re "$gdb_prompt $"\ ++ {fail "set breakpoint via convenience variable"} ++ timeout {fail "(timeout) set breakpoint via convenience variable"} ++} ++ ++# Verify that GDB responds gracefully to an attempt to set a ++# breakpoint via a convenience variable whose type is not integer. ++# ++send_gdb "set \$foo=81.5\n" ++gdb_expect { ++ -re "$gdb_prompt $"\ ++ {pass "set convenience variable \$foo to 81.5"} ++ timeout {fail "(timeout) set convenience variable \$foo to 81.5"} ++} ++send_gdb "break \$foo\n" ++gdb_expect { ++ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\ ++ {pass "set breakpoint via non-integer convenience variable disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "set breakpoint via non-integer convenience variable disallowed"} ++ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"} ++} ++ ++# Verify that we can set and trigger a breakpoint in a user-called function. ++# ++send_gdb "break marker2\n" ++gdb_expect { ++ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ ++ {pass "set breakpoint on to-be-called function"} ++ -re "$gdb_prompt $"\ ++ {fail "set breakpoint on to-be-called function"} ++ timeout {fail "(timeout) set breakpoint on to-be-called function"} ++} ++send_gdb "print marker2(99)\n" ++gdb_expect { ++ -re "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2$proto. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.\r\n$gdb_prompt $"\ ++ {pass "hit breakpoint on called function"} ++ -re "$gdb_prompt $"\ ++ {fail "hit breakpoint on called function"} ++ timeout {fail "(timeout) hit breakpoint on called function"} ++} ++ ++# As long as we're stopped (breakpointed) in a called function, ++# verify that we can successfully backtrace & such from here. ++# ++# In this and the following test, the _sr4export check apparently is needed ++# for hppa*-*-hpux. ++# ++send_gdb "bt\n" ++gdb_expect { ++ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ ++ {pass "backtrace while in called function"} ++ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ ++ {pass "backtrace while in called function"} ++ -re "$gdb_prompt $"\ ++ {fail "backtrace while in called function"} ++ timeout {fail "(timeout) backtrace while in called function"} ++} ++ ++# Return from the called function. For remote targets, it's important to do ++# this before runto_main, which otherwise may silently stop on the dummy ++# breakpoint inserted by GDB at the program's entry point. ++# ++send_gdb "finish\n" ++gdb_expect { ++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ ++ {pass "finish from called function"} ++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ ++ {pass "finish from called function"} ++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ ++ {pass "finish from called function"} ++ -re "$gdb_prompt $"\ ++ {fail "finish from called function"} ++ timeout {fail "(timeout) finish from called function"} ++} ++ ++# Verify that GDB responds gracefully to a "finish" command with ++# arguments. ++# ++if ![runto_main] then { fail "break tests suppressed" } ++ ++send_gdb "finish 123\n" ++gdb_expect { ++ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\ ++ {pass "finish with arguments disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "finish with arguments disallowed"} ++ timeout {fail "(timeout) finish with arguments disallowed"} ++} ++ ++# Verify that GDB responds gracefully to a request to "finish" from ++# the outermost frame. On a stub that never exits, this will just ++# run to the stubs routine, so we don't get this error... Thus the ++# second condition. ++# ++ ++send_gdb "finish\n" ++gdb_expect { ++ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\ ++ {pass "finish from outermost frame disallowed"} ++ -re "Run till exit from.*\r\n$gdb_prompt $" { ++ pass "finish from outermost frame disallowed" ++ } ++ -re "$gdb_prompt $"\ ++ {fail "finish from outermost frame disallowed"} ++ timeout {fail "(timeout) finish from outermost frame disallowed"} ++} ++ ++# Verify that we can explicitly ask GDB to stop on all shared library ++# events, and that it does so. ++# ++if [istarget "hppa*-*-hpux*"] then { ++ if ![runto_main] then { fail "break tests suppressed" } ++ ++ send_gdb "set stop-on-solib-events 1\n" ++ gdb_expect { ++ -re "$gdb_prompt $"\ ++ {pass "set stop-on-solib-events"} ++ timeout {fail "(timeout) set stop-on-solib-events"} ++ } ++ ++ send_gdb "run\n" ++ gdb_expect { ++ -re ".*Start it from the beginning.*y or n. $"\ ++ {send_gdb "y\n" ++ gdb_expect { ++ -re ".*Stopped due to shared library event.*$gdb_prompt $"\ ++ {pass "triggered stop-on-solib-events"} ++ -re "$gdb_prompt $"\ ++ {fail "triggered stop-on-solib-events"} ++ timeout {fail "(timeout) triggered stop-on-solib-events"} ++ } ++ } ++ -re "$gdb_prompt $"\ ++ {fail "rerun for stop-on-solib-events"} ++ timeout {fail "(timeout) rerun for stop-on-solib-events"} ++ } ++ ++ send_gdb "set stop-on-solib-events 0\n" ++ gdb_expect { ++ -re "$gdb_prompt $"\ ++ {pass "reset stop-on-solib-events"} ++ timeout {fail "(timeout) reset stop-on-solib-events"} ++ } ++} ++ ++# Hardware breakpoints are unsupported on HP-UX. Verify that GDB ++# gracefully responds to requests to create them. ++# ++if [istarget "hppa*-*-hpux*"] then { ++ if ![runto_main] then { fail "break tests suppressed" } ++ ++ send_gdb "hbreak\n" ++ gdb_expect { ++ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ ++ {pass "hw breaks disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "hw breaks disallowed"} ++ timeout {fail "(timeout) hw breaks disallowed"} ++ } ++ ++ send_gdb "thbreak\n" ++ gdb_expect { ++ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ ++ {pass "temporary hw breaks disallowed"} ++ -re "$gdb_prompt $"\ ++ {fail "temporary hw breaks disallowed"} ++ timeout {fail "(timeout) temporary hw breaks disallowed"} ++ } ++} ++ ++#******** ++ ++ ++# ++# Test "next" over recursive function call. ++# ++ ++proc test_next_with_recursion {} { ++ global gdb_prompt ++ global decimal ++ global binfile ++ ++ if [target_info exists use_gdb_stub] { ++ # Reload the program. ++ delete_breakpoints ++ gdb_load ${binfile}; ++ } else { ++ # FIXME: should be using runto ++ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y" ++ ++ delete_breakpoints ++ } ++ ++ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial" ++ ++ # Run until we call factorial with 6 ++ ++ if [istarget "*-*-vxworks*"] then { ++ send_gdb "run vxmain \"6\"\n" ++ } else { ++ gdb_run_cmd ++ } ++ gdb_expect { ++ -re "Break.* factorial .value=6. .*$gdb_prompt $" {} ++ -re ".*$gdb_prompt $" { ++ fail "run to factorial(6)"; ++ gdb_suppress_tests; ++ } ++ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } ++ } ++ ++ # Continue until we call factorial recursively with 5. ++ ++ if [gdb_test "continue" \ ++ "Continuing.*Break.* factorial .value=5. .*" \ ++ "continue to factorial(5)"] then { gdb_suppress_tests } ++ ++ # Do a backtrace just to confirm how many levels deep we are. ++ ++ if [gdb_test "backtrace" \ ++ "#0\[ \t\]+ factorial .value=5..*" \ ++ "backtrace from factorial(5)"] then { gdb_suppress_tests } ++ ++ # Now a "next" should position us at the recursive call, which ++ # we will be performing with 4. ++ ++ if [gdb_test "next" \ ++ ".* factorial .value - 1.;.*" \ ++ "next to recursive call"] then { gdb_suppress_tests } ++ ++ # Disable the breakpoint at the entry to factorial by deleting them all. ++ # The "next" should run until we return to the next line from this ++ # recursive call to factorial with 4. ++ # Buggy versions of gdb will stop instead at the innermost frame on ++ # the line where we are trying to "next" to. ++ ++ delete_breakpoints ++ ++ if [istarget "mips*tx39-*"] { ++ set timeout 60 ++ } ++ # We used to set timeout here for all other targets as well. This ++ # is almost certainly wrong. The proper timeout depends on the ++ # target system in use, and how we communicate with it, so there ++ # is no single value appropriate for all targets. The timeout ++ # should be established by the Dejagnu config file(s) for the ++ # board, and respected by the test suite. ++ # ++ # For example, if I'm running GDB over an SSH tunnel talking to a ++ # portmaster in California talking to an ancient 68k board running ++ # a crummy ROM monitor (a situation I can only wish were ++ # hypothetical), then I need a large timeout. But that's not the ++ # kind of knowledge that belongs in this file. ++ ++ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \ ++ "next over recursive call" ++ ++ # OK, we should be back in the same stack frame we started from. ++ # Do a backtrace just to confirm. ++ ++ set result [gdb_test "backtrace" \ ++ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \ ++ "backtrace from factorial(5.1)"] ++ if { $result != 0 } { gdb_suppress_tests } ++ ++ if [target_info exists gdb,noresults] { gdb_suppress_tests } ++ gdb_continue_to_end "recursive next test" ++ gdb_stop_suppressing_tests; ++} ++ ++test_next_with_recursion ++ ++ ++#******** ++ ++# build a new file with optimization enabled so that we can try breakpoints ++# on targets with optimized prologues ++ ++set binfileo2 ${objdir}/${subdir}/${testfile}o2 ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfileo2}] { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfileo2} ++ ++if [target_info exists gdb_stub] { ++ gdb_step_for_stub; ++} ++ ++# ++# test break at function ++# ++gdb_test "break main" \ ++ "Breakpoint.*at.* file .*$srcfile, line.*" \ ++ "breakpoint function, optimized file" ++ ++# ++# test break at function ++# ++gdb_test "break marker4" \ ++ "Breakpoint.*at.* file .*$srcfile1, line.*" \ ++ "breakpoint small function, optimized file" ++ ++# ++# run until the breakpoint at main is hit. For non-stubs-using targets. ++# ++if ![target_info exists use_gdb_stub] { ++ if [istarget "*-*-vxworks*"] then { ++ send_gdb "run vxmain \"2\"\n" ++ set timeout 120 ++ verbose "Timeout is now $timeout seconds" 2 ++ } else { ++ send_gdb "run\n" ++ } ++ gdb_expect { ++ -re "The program .* has been started already.*y or n. $" { ++ send_gdb "y\n" ++ exp_continue ++ } ++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ ++ { pass "run until function breakpoint, optimized file" } ++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\ ++ { pass "run until function breakpoint, optimized file (code motion)" } ++ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" } ++ timeout { fail "run until function breakpoint, optimized file (timeout)" } ++ } ++} else { ++ if ![target_info exists gdb_stub] { ++ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" ++ } ++} ++ ++# ++# run until the breakpoint at a small function ++# ++ ++# ++# Add a second pass pattern. The behavior differs here between stabs ++# and dwarf for one-line functions. Stabs preserves two line symbols ++# (one before the prologue and one after) with the same line number, ++# but dwarf regards these as duplicates and discards one of them. ++# Therefore the address after the prologue (where the breakpoint is) ++# has no exactly matching line symbol, and GDB reports the breakpoint ++# as if it were in the middle of a line rather than at the beginning. ++ ++set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] ++set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] ++send_gdb "continue\n" ++gdb_expect { ++ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { ++ pass "run until breakpoint set at small function, optimized file" ++ } ++ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { ++ pass "run until breakpoint set at small function, optimized file" ++ } ++ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { ++ # marker4() is defined at line 46 when compiled with -DPROTOTYPES ++ pass "run until breakpoint set at small function, optimized file (line bp_location14)" ++ } ++ -re ".*$gdb_prompt " { ++ fail "run until breakpoint set at small function, optimized file" ++ } ++ timeout { ++ fail "run until breakpoint set at small function, optimized file (timeout)" ++ } ++} ++ ++ ++# Reset the default arguments for VxWorks ++if [istarget "*-*-vxworks*"] { ++ set timeout 10 ++ verbose "Timeout is now $timeout seconds" 2 ++ send_gdb "set args main\n" ++ gdb_expect -re ".*$gdb_prompt $" {} ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/corefile.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/corefile.exp 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,233 @@ ++# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 ++# 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 file was written by Fred Fish. (fnf@cygnus.com) ++ ++# are we on a target board ++if ![isnative] then { ++ return ++} ++ ++set testfile "coremaker" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++# Create and source the file that provides information about the compiler ++# used to compile the test case. ++if [get_compiler_info ${binfile}] { ++ return -1; ++} ++ ++# Create a core file named "corefile" rather than just "core", to ++# avoid problems with sys admin types that like to regularly prune all ++# files named "core" from the system. ++# ++# Arbitrarily try setting the core size limit to "unlimited" since ++# this does not hurt on systems where the command does not work and ++# allows us to generate a core on systems where it does. ++# ++# Some systems append "core" to the name of the program; others append ++# the name of the program to "core"; still others (like Linux, as of ++# May 2003) create cores named "core.PID". In the latter case, we ++# could have many core files lying around, and it may be difficult to ++# tell which one is ours, so let's run the program in a subdirectory. ++set found 0 ++set coredir "${objdir}/${subdir}/coredir.[getpid]" ++file mkdir $coredir ++catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" ++# remote_exec host "${binfile}" ++foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { ++ if [remote_file build exists $i] { ++ remote_exec build "mv $i ${objdir}/${subdir}/corefile" ++ set found 1 ++ } ++} ++# Check for "core.PID". ++if { $found == 0 } { ++ set names [glob -nocomplain -directory $coredir core.*] ++ if {[llength $names] == 1} { ++ set corefile [file join $coredir [lindex $names 0]] ++ remote_exec build "mv $corefile ${objdir}/${subdir}/corefile" ++ set found 1 ++ } ++} ++if { $found == 0 } { ++ # The braindamaged HPUX shell quits after the ulimit -c above ++ # without executing ${binfile}. So we try again without the ++ # ulimit here if we didn't find a core file above. ++ # Oh, I should mention that any "braindamaged" non-Unix system has ++ # the same problem. I like the cd bit too, it's really neat'n stuff. ++ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\"" ++ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" { ++ if [remote_file build exists $i] { ++ remote_exec build "mv $i ${objdir}/${subdir}/corefile" ++ set found 1 ++ } ++ } ++} ++ ++# Try to clean up after ourselves. ++remote_file build delete [file join $coredir coremmap.data] ++remote_exec build "rmdir $coredir" ++ ++if { $found == 0 } { ++ warning "can't generate a core file - core tests suppressed - check ulimit -c" ++ return 0 ++} ++ ++# ++# Test that we can simply startup with a "-core=corefile" command line arg ++# and recognize that the core file is a valid, usable core file. ++# To do this, we must shutdown the currently running gdb and restart ++# with the -core args. We can't use gdb_start because it looks for ++# the first gdb prompt, and the message we are looking for occurs ++# before the first prompt. Also, we can't include GDBFLAGS because ++# if it is empty, this confuses gdb with an empty argument that it ++# grumbles about (said grumbling currently being ignored in gdb_start). ++# **FIXME** ++# ++# Another problem is that on some systems (solaris for example), there ++# is apparently a limit on the length of a fully specified path to ++# the coremaker executable, at about 80 chars. For this case, consider ++# it a pass, but note that the program name is bad. ++ ++gdb_exit ++if $verbose>1 then { ++ send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n" ++} ++ ++set oldtimeout $timeout ++set timeout [expr "$timeout + 60"] ++verbose "Timeout is now $timeout seconds" 2 ++eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile" ++expect { ++ -re "Couldn't find .* registers in core file.*$gdb_prompt $" { ++ fail "args: -core=corefile (couldn't find regs)" ++ } ++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "args: -core=corefile" ++ } ++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "args: -core=corefile (with bad program name)" ++ } ++ -re ".*registers from core file: File in wrong format.* $" { ++ fail "args: -core=corefile (could not read registers from core file)" ++ } ++ -re ".*$gdb_prompt $" { fail "args: -core=corefile" } ++ timeout { fail "(timeout) starting with -core" } ++} ++ ++ ++# ++# Test that startup with both an executable file and -core argument. ++# See previous comments above, they are still applicable. ++# ++ ++close; ++ ++if $verbose>1 then { ++ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n" ++} ++ ++ ++eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile"; ++expect { ++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "args: execfile -core=corefile" ++ } ++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "args: execfile -core=corefile (with bad program name)" ++ } ++ -re ".*registers from core file: File in wrong format.* $" { ++ fail "args: execfile -core=corefile (could not read registers from core file)" ++ } ++ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" } ++ timeout { fail "(timeout) starting with -core" } ++} ++set timeout $oldtimeout ++verbose "Timeout is now $timeout seconds" 2 ++ ++close; ++ ++# Now restart normally. ++ ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# Test basic corefile recognition via core-file command. ++ ++send_gdb "core-file $objdir/$subdir/corefile\n" ++gdb_expect { ++ -re ".* program is being debugged already.*y or n. $" { ++ # gdb_load may connect us to a gdbserver. ++ send_gdb "y\n" ++ exp_continue; ++ } ++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "core-file command" ++ } ++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { ++ pass "core-file command (with bad program name)" ++ } ++ -re ".*registers from core file: File in wrong format.* $" { ++ fail "core-file command (could not read registers from core file)" ++ } ++ -re ".*$gdb_prompt $" { fail "core-file command" } ++ timeout { fail "(timeout) core-file command" } ++} ++ ++# Test correct mapping of corefile sections by printing some variables. ++ ++gdb_test "print coremaker_data" "\\\$$decimal = 202" ++gdb_test "print coremaker_bss" "\\\$$decimal = 10" ++gdb_test "print coremaker_ro" "\\\$$decimal = 201" ++ ++gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}" ++ ++# Somehow we better test the ability to read the registers out of the core ++# file correctly. I don't think the other tests do this. ++ ++gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp" ++gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" ++ ++# Test ability to read mmap'd data ++ ++gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file" ++setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*" ++set test "accessing mmapped data in core file" ++gdb_test_multiple "x/8bd buf2" "$test" { ++ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" { ++ pass "$test" ++ } ++ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" { ++ fail "$test (mapping failed at runtime)" ++ } ++ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" { ++ fail "$test (mapping address not found in core file)" ++ } ++} ++ ++# test reinit_frame_cache ++ ++gdb_load ${binfile} ++gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)" ++ ++gdb_test "core" "No core file now." +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/Makefile.in +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/Makefile.in 2011-03-20 20:21:43.000000000 +0100 +@@ -0,0 +1,19 @@ ++VPATH = @srcdir@ ++srcdir = @srcdir@ ++ ++EXECUTABLES = ++MISCELLANEOUS = arch.inc ++ ++all info install-info dvi install uninstall installcheck check: ++ @echo "Nothing to be done for $@..." ++ ++clean mostlyclean: ++ -rm -f *~ *.o a.out *.x *.ci *.tmp ++ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES) ++ -rm -f $(MISCELLANEOUS) ++ ++distclean maintainer-clean realclean: clean ++ -rm -f *~ core ++ -rm -f Makefile config.status config.log ++ -rm -f *-init.exp ++ -rm -fr *.log summary detail *.plog *.sum *.psum site.* diff --git a/gdb/patches/gdb-6.3-test-self-20050110.patch b/gdb/patches/gdb-6.3-test-self-20050110.patch new file mode 100644 index 000000000..a3ada089c --- /dev/null +++ b/gdb/patches/gdb-6.3-test-self-20050110.patch @@ -0,0 +1,101 @@ +2004-02-23 Elena Zannoni + + * gdb.gdb/selftest.exp: Make sure that the debug directory is + set up properly. + * gdb.gdb/complaints.exp: Ditto. + * gdb.gdb/xfullpath.exp: Ditto. + * gdb.gdb/observer.exp: Ditto. + +Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/complaints.exp +=================================================================== +--- gdb-6.8.50.20090226.orig/gdb/testsuite/gdb.gdb/complaints.exp 2009-01-03 06:58:04.000000000 +0100 ++++ gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/complaints.exp 2009-02-26 22:10:48.000000000 +0100 +@@ -302,13 +302,13 @@ proc find_gdb { arg } { + set GDB_FULLPATH [find_gdb $GDB] + + # Remove any old copy lying around. +-remote_file host delete x$tool ++#remote_file host delete x$tool + + gdb_start + +-set file [remote_download host $GDB_FULLPATH x$tool] ++#set file [remote_download host $GDB_FULLPATH x$tool] + +-set setup_result [setup_test $file ] ++set setup_result [setup_test $GDB_FULLPATH ] + if {$setup_result <0} then { + return -1 + } +@@ -319,4 +319,4 @@ test_short_complaints + test_empty_complaints + + gdb_exit; +-catch "remote_file host delete $file"; ++#catch "remote_file host delete $file"; +Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/observer.exp +=================================================================== +--- gdb-6.8.50.20090226.orig/gdb/testsuite/gdb.gdb/observer.exp 2009-02-17 20:52:27.000000000 +0100 ++++ gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/observer.exp 2009-02-26 22:11:40.000000000 +0100 +@@ -258,13 +258,13 @@ proc find_gdb { arg } { + set GDB_FULLPATH [find_gdb $GDB] + + # Remove any old copy lying around. +-remote_file host delete x$tool ++#remote_file host delete x$tool + + gdb_start +-set file [remote_download host $GDB_FULLPATH x$tool] +-set result [test_observer $file]; ++#set file [remote_download host $GDB_FULLPATH x$tool] ++set result [test_observer $GDB_FULLPATH]; + gdb_exit; +-catch "remote_file host delete $file"; ++#catch "remote_file host delete $file"; + + if {$result <0} then { + warning "Couldn't test self" +Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/selftest.exp +=================================================================== +--- gdb-6.8.50.20090226.orig/gdb/testsuite/gdb.gdb/selftest.exp 2009-02-26 22:09:59.000000000 +0100 ++++ gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/selftest.exp 2009-02-26 22:10:48.000000000 +0100 +@@ -551,13 +551,13 @@ proc find_gdb { arg } { + set GDB_FULLPATH [find_gdb $GDB] + + # Remove any old copy lying around. +-remote_file host delete x$tool ++#remote_file host delete x$tool + + gdb_start +-set file [remote_download host $GDB_FULLPATH x$tool] +-set result [test_with_self $file]; ++#set file [remote_download host $GDB_FULLPATH x$tool] ++set result [test_with_self $GDB_FULLPATH]; + gdb_exit; +-catch "remote_file host delete $file"; ++#catch "remote_file host delete $file"; + + if {$result <0} then { + warning "Couldn't test self" +Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/xfullpath.exp +=================================================================== +--- gdb-6.8.50.20090226.orig/gdb/testsuite/gdb.gdb/xfullpath.exp 2009-01-03 06:58:04.000000000 +0100 ++++ gdb-6.8.50.20090226/gdb/testsuite/gdb.gdb/xfullpath.exp 2009-02-26 22:10:48.000000000 +0100 +@@ -179,13 +179,13 @@ proc find_gdb { arg } { + set GDB_FULLPATH [find_gdb $GDB] + + # Remove any old copy lying around. +-remote_file host delete x$tool ++#remote_file host delete x$tool + + gdb_start +-set file [remote_download host $GDB_FULLPATH x$tool] +-set result [test_with_self $file]; ++#set file [remote_download host $GDB_FULLPATH x$tool] ++set result [test_with_self $GDB_FULLPATH]; + gdb_exit; +-catch "remote_file host delete $file"; ++#catch "remote_file host delete $file"; + + if {$result <0} then { + warning "Couldn't test self" diff --git a/gdb/patches/gdb-6.3-threaded-watchpoints2-20050225.patch b/gdb/patches/gdb-6.3-threaded-watchpoints2-20050225.patch new file mode 100644 index 000000000..187a33e1b --- /dev/null +++ b/gdb/patches/gdb-6.3-threaded-watchpoints2-20050225.patch @@ -0,0 +1,243 @@ +2005-02-28 Jeff Johnston + + * config/i386/nm-linux.h: Change dr register routines to + accept a ptid_t first argument. Change all calling macros + to default the inferior_ptid for the first argument. + (i386_linux_insert_watchpoint): New prototype. + (i386_linux_remove_watchpoint, i386_linux_insert_hw_breakpoint): Ditto. + (i386_linux_remove_hw_breakpoint): Ditto. + (target_insert_watchpoint, target_remove_watchpoint): Undef and + override. + (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Ditto. + * config/i386/nm-linux64.h: Ditto except add amd64 versions of + the watchpoint/hw-breakpoint insert/remove routines. + * i386-nat.c: Include "inferior.h" to define inferior_ptid. + * i386-linux-nat.c: Change all dr get/set routines to accept + ptid_t as first argument and to use this argument to determine + the tid for PTRACE. + (i386_linux_set_debug_regs_for_thread): New function. + (i386_linux_sync_debug_registers_callback): Ditto. + (i386_linux_sync_debug_registers_across_threads): Ditto. + (i386_linux_insert_watchpoint, i386_linux_remove_watchpoint): Ditto. + (i386_linux_hw_breakpoint, i386_linux_remove_hw_breakpoint): Ditto. + (i386_linux_new_thread): Ditto. + (_initialize_i386_linux_nat): Ditto. + * amd64-linux-nat.c: Change all dr get/set routines to accept + ptid_t as first argument and to use this argument to determine + the tid for PTRACE. + (amd64_linux_set_debug_regs_for_thread): New function. + (amd64_linux_sync_debug_registers_callback): Ditto. + (amd64_linux_sync_debug_registers_across_threads): Ditto. + (amd64_linux_insert_watchpoint, amd64_linux_remove_watchpoint): Ditto. + (amd64_linux_hw_breakpoint, amd64_linux_remove_hw_breakpoint): Ditto. + (amd64_linux_new_thread): Ditto. + (_initialize_amd64_linux_nat): Register linux new thread observer. + * testsuite/gdb.threads/watchthreads2.c: New test case. + * testsuite/gdb.threads/watchthreads2.exp: Ditto. + +[ With recent upstream GDB (6.8) reduced only to the testcase. ] + +FIXME: The testcase does not expects multiple watchpoints hits per one stop. + +Index: gdb-6.5/gdb/testsuite/gdb.threads/watchthreads2.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.5/gdb/testsuite/gdb.threads/watchthreads-threaded.c 2006-07-12 01:54:29.000000000 -0300 +@@ -0,0 +1,66 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2002, 2003, 2004, 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 file is copied from schedlock.c. */ ++ ++#include ++#include ++#include ++#include ++ ++void *thread_function(void *arg); /* Pointer to function executed by each thread */ ++ ++#define NUM 5 ++ ++unsigned int args[NUM+1]; ++ ++int main() { ++ int res; ++ pthread_t threads[NUM]; ++ void *thread_result; ++ long i; ++ ++ for (i = 0; i < NUM; i++) ++ { ++ args[i] = 1; /* Init value. */ ++ res = pthread_create(&threads[i], ++ NULL, ++ thread_function, ++ (void *) i); ++ } ++ ++ args[i] = 1; ++ thread_function ((void *) i); ++ ++ exit(EXIT_SUCCESS); ++} ++ ++void *thread_function(void *arg) { ++ int my_number = (long) arg; ++ int *myp = (int *) &args[my_number]; ++ ++ /* Don't run forever. Run just short of it :) */ ++ while (*myp > 0) ++ { ++ (*myp) ++; usleep (1); /* Loop increment. */ ++ } ++ ++ pthread_exit(NULL); ++} ++ +Index: gdb-6.5/gdb/testsuite/gdb.threads/watchthreads2.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.5/gdb/testsuite/gdb.threads/watchthreads-threaded.exp 2006-07-12 01:54:29.000000000 -0300 +@@ -0,0 +1,126 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# 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. ++ ++# Check that GDB can support multiple watchpoints across threads. ++ ++# This test verifies that a watchpoint is detected in the proper thread ++# so the test is only meaningful on a system with hardware watchpoints. ++if [target_info exists gdb,no_hardware_watchpoints] { ++ return 0; ++} ++ ++set testfile "watchthreads2" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "set can-use-hw-watchpoints 1" "" "" ++ ++# ++# Run to `main' where we begin our tests. ++# ++ ++if ![runto_main] then { ++ gdb_suppress_tests ++} ++ ++set args_2 0 ++set args_3 0 ++ ++gdb_breakpoint "thread_function" ++gdb_continue_to_breakpoint "thread_function" ++gdb_test "disable 2" "" ++ ++gdb_test_multiple "p args\[2\]" "get initial args2" { ++ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" { ++ set init_args_2 $expect_out(1,string) ++ pass "get initial args2" ++ } ++} ++ ++gdb_test_multiple "p args\[3\]" "get initial args3" { ++ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" { ++ set init_args_3 $expect_out(1,string) ++ pass "get initial args3" ++ } ++} ++ ++set args_2 $init_args_2 ++set args_3 $init_args_3 ++ ++# Watch values that will be modified by distinct threads. ++gdb_test "watch args\[2\]" "Hardware watchpoint 3: args\\\[2\\\]" ++gdb_test "watch args\[3\]" "Hardware watchpoint 4: args\\\[3\\\]" ++ ++set init_line [expr [gdb_get_line_number "Init value"]+1] ++set inc_line [gdb_get_line_number "Loop increment"] ++ ++# Loop and continue to allow both watchpoints to be triggered. ++for {set i 0} {$i < 30} {incr i} { ++ set test_flag 0 ++ gdb_test_multiple "continue" "threaded watch loop" { ++ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads2.c:$init_line.*$gdb_prompt $" ++ { set args_2 1; set test_flag 1 } ++ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads2.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 .*watchthreads2.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 .*watchthreads2.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 ++ if { $test_flag == 0 } { ++ set i 30; ++ } ++} ++ ++# Print success message if loop succeeded. ++if { $test_flag == 1 } { ++ pass "threaded watch loop" ++} ++ ++# Verify that we hit first watchpoint in child thread. ++set message "watchpoint on args\[2\] hit in thread" ++if { $args_2 > 1 } { ++ pass $message ++} else { ++ fail $message ++} ++ ++# Verify that we hit second watchpoint in child thread. ++set message "watchpoint on args\[3\] hit in thread" ++if { $args_3 > 1 } { ++ pass $message ++} else { ++ 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 ++} else { ++ fail $message ++} diff --git a/gdb/patches/gdb-6.5-BEA-testsuite.patch b/gdb/patches/gdb-6.5-BEA-testsuite.patch new file mode 100644 index 000000000..76d75666e --- /dev/null +++ b/gdb/patches/gdb-6.5-BEA-testsuite.patch @@ -0,0 +1,938 @@ +Index: ./gdb/testsuite/gdb.threads/threadcrash.c +=================================================================== +RCS file: gdb/testsuite/gdb.threads/threadcrash.c +diff -N gdb/testsuite/gdb.threads/threadcrash.c +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threadcrash.c 31 Oct 2006 17:54:38 -0000 +@@ -0,0 +1,301 @@ ++/* ++ * The point of this program is to crash in a multi-threaded app. ++ * There are seven threads, doing the following things: ++ * * Spinning ++ * * Spinning inside a signal handler ++ * * Spinning inside a signal handler executing on the altstack ++ * * In a syscall ++ * * In a syscall inside a signal handler ++ * * In a syscall inside a signal handler executing on the altstack ++ * * Finally, the main thread crashes in main, with no frills. ++ * ++ * These are the things threads in JRockit tend to be doing. If gdb ++ * can handle those things, both in core files and during live ++ * debugging, that will help (at least) JRockit development. ++ * ++ * Let the program create a core file, then load the core file into ++ * gdb. Inside gdb, you should be able to do something like this: ++ * ++ * (gdb) t a a bt ++ * ++ * Thread 7 (process 4352): ++ * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 ++ * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 ++ * #2 0x080488a2 in makeSyscall (ignored=0x0) at threadcrash.c:118 ++ * #3 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #4 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 6 (process 4353): ++ * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 ++ * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 ++ * #2 0x0804898f in syscallingSighandler (signo=10, info=0xb6be76f0, context=0xb6be7770) ++ * at threadcrash.c:168 ++ * #3 ++ * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0 ++ * #5 0x08048a51 in makeSyscallFromSighandler (ignored=0x0) at threadcrash.c:204 ++ * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #7 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 5 (process 4354): ++ * #0 0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6 ++ * #1 0x001ba5ff in sleep () from /lib/tls/libc.so.6 ++ * #2 0x08048936 in syscallingAltSighandler (signo=3, info=0x959cd70, context=0x959cdf0) ++ * at threadcrash.c:144 ++ * #3 ++ * #4 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0 ++ * #5 0x080489e2 in makeSyscallFromAltSighandler (ignored=0x0) at threadcrash.c:190 ++ * #6 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #7 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 4 (process 4355): ++ * #0 spin (ignored=0x0) at threadcrash.c:242 ++ * #1 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #2 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 3 (process 4356): ++ * #0 spinningSighandler (signo=12, info=0xb4de46f0, context=0xb4de4770) at threadcrash.c:180 ++ * #1 ++ * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0 ++ * #3 0x08048b2f in spinFromSighandler (ignored=0x0) at threadcrash.c:232 ++ * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #5 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 2 (process 4357): ++ * #0 spinningAltSighandler (signo=14, info=0x959ee50, context=0x959eed0) at threadcrash.c:156 ++ * #1 ++ * #2 0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0 ++ * #3 0x08048ac0 in spinFromAltSighandler (ignored=0x0) at threadcrash.c:218 ++ * #4 0x006aadec in start_thread () from /lib/tls/libpthread.so.0 ++ * #5 0x001ed19a in clone () from /lib/tls/libc.so.6 ++ * ++ * Thread 1 (process 4351): ++ * #0 0x08048cf3 in main (argc=1, argv=0xbfff9d74) at threadcrash.c:273 ++ * (gdb) ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define SIGSYSCALL_ALT SIGQUIT ++#define SIGSYSCALL SIGUSR1 ++#define SIGSPIN_ALT SIGALRM ++#define SIGSPIN SIGUSR2 ++ ++typedef void (*sigaction_t)(int, siginfo_t *, void *); ++ ++static void installHandler(int signo, sigaction_t handler, int onAltstack) { ++ struct sigaction action; ++ sigset_t sigset; ++ int result; ++ stack_t altstack; ++ stack_t oldaltstack; ++ ++ memset(&action, 0, sizeof(action)); ++ memset(&altstack, 0, sizeof(altstack)); ++ memset(&oldaltstack, 0, sizeof(oldaltstack)); ++ ++ if (onAltstack) { ++ altstack.ss_sp = malloc(SIGSTKSZ); ++ assert(altstack.ss_sp != NULL); ++ altstack.ss_size = SIGSTKSZ; ++ altstack.ss_flags = 0; ++ result = sigaltstack(&altstack, &oldaltstack); ++ assert(result == 0); ++ assert(oldaltstack.ss_flags == SS_DISABLE); ++ } ++ ++ sigemptyset(&sigset); ++ ++ action.sa_handler = NULL; ++ action.sa_sigaction = handler; ++ action.sa_mask = sigset; ++ action.sa_flags = SA_SIGINFO; ++ if (onAltstack) { ++ action.sa_flags |= SA_ONSTACK; ++ } ++ ++ result = sigaction(signo, &action, NULL); ++ assert(result == 0); ++} ++ ++static void installNormalHandler(int signo, sigaction_t handler) { ++ installHandler(signo, handler, 0); ++} ++ ++static void installAlthandler(int signo, sigaction_t handler) { ++ installHandler(signo, handler, 1); ++} ++ ++static void *makeSyscall(void *ignored) { ++ (void)ignored; ++ ++ sleep(42); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++/* Return true if we're currently executing on the altstack */ ++static int onAltstack(void) { ++ stack_t stack; ++ int result; ++ ++ result = sigaltstack(NULL, &stack); ++ assert(result == 0); ++ ++ return stack.ss_flags & SS_ONSTACK; ++} ++ ++static void syscallingAltSighandler(int signo, siginfo_t *info, void *context) { ++ (void)signo; ++ (void)info; ++ (void)context; ++ ++ if (!onAltstack()) { ++ printf("%s() not running on altstack!\n", __FUNCTION__); ++ } ++ ++ sleep(42); ++} ++ ++static void spinningAltSighandler(int signo, siginfo_t *info, void *context) { ++ (void)signo; ++ (void)info; ++ (void)context; ++ ++ if (!onAltstack()) { ++ printf("%s() not running on altstack!\n", __FUNCTION__); ++ } ++ ++ while (1); ++} ++ ++static void syscallingSighandler(int signo, siginfo_t *info, void *context) { ++ (void)signo; ++ (void)info; ++ (void)context; ++ ++ if (onAltstack()) { ++ printf("%s() running on altstack!\n", __FUNCTION__); ++ } ++ ++ sleep(42); ++} ++ ++static void spinningSighandler(int signo, siginfo_t *info, void *context) { ++ (void)signo; ++ (void)info; ++ (void)context; ++ ++ if (onAltstack()) { ++ printf("%s() running on altstack!\n", __FUNCTION__); ++ } ++ ++ while (1); ++} ++ ++static void *makeSyscallFromAltSighandler(void *ignored) { ++ (void)ignored; ++ ++ int result; ++ ++ installAlthandler(SIGSYSCALL_ALT, syscallingAltSighandler); ++ ++ result = pthread_kill(pthread_self(), SIGSYSCALL_ALT); ++ assert(result == 0); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++static void *makeSyscallFromSighandler(void *ignored) { ++ (void)ignored; ++ ++ int result; ++ ++ installNormalHandler(SIGSYSCALL, syscallingSighandler); ++ ++ result = pthread_kill(pthread_self(), SIGSYSCALL); ++ assert(result == 0); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++static void *spinFromAltSighandler(void *ignored) { ++ (void)ignored; ++ ++ int result; ++ ++ installAlthandler(SIGSPIN_ALT, spinningAltSighandler); ++ ++ result = pthread_kill(pthread_self(), SIGSPIN_ALT); ++ assert(result == 0); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++static void *spinFromSighandler(void *ignored) { ++ (void)ignored; ++ ++ int result; ++ ++ installNormalHandler(SIGSPIN, spinningSighandler); ++ ++ result = pthread_kill(pthread_self(), SIGSPIN); ++ assert(result == 0); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++static void *spin(void *ignored) { ++ (void)ignored; ++ ++ while (1); ++ ++ fprintf(stderr, "%s: returning\n", __FUNCTION__); ++ return NULL; ++} ++ ++int main(int argc, char *argv[]) { ++ int result; ++ pthread_t thread; ++ volatile int bad; ++ ++ result = pthread_create(&thread, NULL, makeSyscall, NULL); ++ assert(result == 0); ++ result = pthread_create(&thread, NULL, makeSyscallFromSighandler, NULL); ++ assert(result == 0); ++ result = pthread_create(&thread, NULL, makeSyscallFromAltSighandler, NULL); ++ assert(result == 0); ++ result = pthread_create(&thread, NULL, spin, NULL); ++ assert(result == 0); ++ result = pthread_create(&thread, NULL, spinFromSighandler, NULL); ++ assert(result == 0); ++ result = pthread_create(&thread, NULL, spinFromAltSighandler, NULL); ++ assert(result == 0); ++ ++ // Give threads some time to get going ++ sleep(3); ++ ++ // Crash ++ bad = *(int*)7; ++ ++ /* Workaround: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29628 ++ Simulate use to ensure `DW_AT_location' for them: ++ readelf -a --debug threadcrash|grep -A5 -w argc ++ --> DW_AT_location : 2 byte block: 71 0 (DW_OP_breg1: 0) ++ This case verified on: gcc-4.1.1-30.i386 ++ Keep it late to ensure persistency in the registers. */ ++ bad = (int) argc; ++ bad = (unsigned long) argv; ++ ++ return 0; ++} +Index: ./gdb/testsuite/gdb.threads/threadcrash.exp +=================================================================== +RCS file: gdb/testsuite/gdb.threads/threadcrash.exp +diff -N gdb/testsuite/gdb.threads/threadcrash.exp +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threadcrash.exp 31 Oct 2006 17:54:38 -0000 +@@ -0,0 +1,37 @@ ++# threadcrash.exp - The point of this program is to crash in a multi-threaded app. ++ ++ ++set testfile threadcrash ++set srcfile ${testfile}.c ++set shellfile ${srcdir}/${subdir}/${testfile}.sh ++set binfile ${objdir}/${subdir}/${testfile} ++ ++set GDB_abs ${GDB} ++if [regexp "^\[^/\]" ${GDB_abs}] { ++ set GDB_abs $env(PWD)/${GDB_abs} ++} ++ ++if [istarget "*-*-linux"] then { ++ set target_cflags "-D_MIT_POSIX_THREADS" ++} else { ++ set target_cflags "" ++} ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ return -1 ++} ++ ++# ${shellfile} argument must not contain any directories. ++set fd [open "|bash ${shellfile} ${binfile} $GDB -nw $GDBFLAGS" r] ++while { [gets $fd line] >= 0 } { ++ if [regexp " PASS: (.*)$" $line trash message] { ++ pass $message ++ } elseif [regexp " FAIL: (.*)$" $line trash message] { ++ fail $message ++ } ++} ++catch { ++ close $fd ++} ++ ++return 0 +Index: ./gdb/testsuite/gdb.threads/threadcrash.sh +=================================================================== +RCS file: gdb/testsuite/gdb.threads/threadcrash.sh +diff -N gdb/testsuite/gdb.threads/threadcrash.sh +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threadcrash.sh 31 Oct 2006 17:54:38 -0000 +@@ -0,0 +1,324 @@ ++#! /bin/bash ++ ++# NOTE: threadcrash.c *must* be built with debugging symbols ++# ++# The point of this shell script is to crash treadcrash.c, load the ++# resulting core file into gdb and verify that gdb can extract enough ++# information from the core file. ++# ++# The return code from this script is the number of failed tests. ++ ++LOG=gdbresult.log ++ ++if [ $# = 0 ] ; then ++ echo >&2 Syntax: $0 \ [\ \] ++ exit 1 ++fi ++RUNME="$1" ++shift ++GDB="${*:-gdb}" ++ ++ ++pf_prefix="" ++function pf_prefix() { ++ pf_prefix="$*" ++} ++ ++set_test="" ++function set_test() { ++ if [ -n "$set_test" ] ; then ++ echo >&2 "DEJAGNU-BASH ERROR: set_test already set" ++ exit 1 ++ fi ++ set_test="$*" ++ if [ -n "$pf_prefix" ] ; then ++ set_test="$pf_prefix: $set_test" ++ fi ++} ++ ++# INTERNAL ++function record_test { ++ if [ -z "$set_test" ] ; then ++ echo >&2 "DEJAGNU-BASH ERROR: set_test not set" ++ exit 1 ++ fi ++ # Provide the leading whitespace delimiter: ++ echo " $1: $set_test" ++ set_test="" ++} ++ ++function pass() { ++ record_test PASS ++} ++function fail() { ++ record_test FAIL ++} ++ ++ ++# Verify that the gdb output doesn't contain $1. ++function mustNotHave() { ++ local BADWORD=$1 ++ set_test gdb output contains "$BADWORD" ++ if grep -q "$BADWORD" $LOG ; then ++ fail ++ return 1 ++ fi ++ pass ++ return 0 ++} ++ ++# Verify that the gdb output contains exactly $1 $2s. ++function mustHaveCorrectAmount() { ++ local WANTEDNUMBER=$1 ++ local GOODWORD=$2 ++ local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l) ++ set_test gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected ++ if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then ++ fail ++ return 1 ++ fi ++ pass ++ return 0 ++} ++ ++# Verify that the gdb output contains seven threads ++function mustHaveSevenThreads() { ++ NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l) ++ set_test gdb output contains $NTHREADS threads, not 7 as expected ++ if [ $NTHREADS != 7 ] ; then ++ fail ++ return 1 ++ fi ++ pass ++ return 0 ++} ++ ++# Verify that the gdb output has all parameters on consecutive lines ++function mustHaveSequence() { ++ SEQUENCE="$*" ++ NPARTS=$# ++ grep "$1" -A$((NPARTS - 1)) $LOG > matches.log ++ ++ while [ $# -gt 1 ] ; do ++ shift ++ ((NPARTS--)) ++ grep "$1" -A$((NPARTS - 1)) matches.log > temp.log ++ mv temp.log matches.log ++ done ++ LASTPART=$1 ++ ++ set_test gdb output does not contain the sequence: $SEQUENCE ++ if ! grep -q "$LASTPART" matches.log ; then ++ fail ++ return 1 ++ fi ++ pass ++ return 0 ++} ++ ++# Verify that $LOG contains all information we want ++function verifyLog() { ++ local FAILURES=0 ++ ++ mustNotHave '??' || ((FAILURES++)) ++ mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++)) ++ ++ mustHaveSevenThreads || ((FAILURES++)) ++ mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence Thread "spin (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++)) ++ ++ return $FAILURES ++} ++ ++# Put result of debugging a core file in $LOG ++function getLogFromCore() { ++ # Make sure we get a core file ++ set_test Make sure we get a core file ++ if ! ulimit -c unlimited ; then ++ fail ++ exit 1 ++ fi ++ pass ++ ++ # Run the crasher ++ ./$(basename "$RUNME") ++ EXITCODE=$? ++ ++ # Verify that we actually crashed ++ set_test $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE ++ if [ $EXITCODE -lt 128 ] ; then ++ fail ++ exit 1 ++ fi ++ pass ++ ++ # Verify that we got a core file ++ set_test $RUNME did not create a core file ++ if [ ! -r core* ] ; then ++ fail ++ exit 1 ++ fi ++ pass ++ ++ # Run gdb ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ set_test gdb exited with error code ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >&2 gdb exited with error code $EXITCODE ++ fail ++ fi ++ pass ++} ++ ++# Put result of debugging a gcore file in $LOG ++function getLogFromGcore() { ++ # Create the core file ++ rm -f core* ++ cat > gdbscript.gdb < /dev/null ++ EXITCODE=$? ++ ++ set_test gdb exited with error code when creating gcore file ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >&2 gdb exited with error code $EXITCODE when creating gcore file ++ fail ++ fi ++ pass ++ ++ # Verify that we got a core file from gcore ++ set_test gdb gcore did not create a core file ++ if [ ! -r core* ] ; then ++ fail ++ exit 1 ++ fi ++ pass ++ ++ # Run gdb on the gcore file ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ set_test gdb exited with error code when examining gcore file ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >&2 gdb exited with error code $EXITCODE when examining gcore file ++ fail ++ fi ++ pass ++} ++ ++# Put result of debugging a core file in $LOG ++function getLogFromLiveProcess() { ++ # Run gdb ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ set_test gdb exited with error code ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >&2 gdb exited with error code $EXITCODE ++ fail ++ fi ++ pass ++} ++ ++####### Main program follows ##################### ++ ++# Make sure we don't clobber anybody else's (core) file(s) ++WORKDIR=/tmp/$PPID ++mkdir -p $WORKDIR ++cp "$RUNME" $WORKDIR ++cd $WORKDIR ++ ++# Count problems ++FAILURES=0 ++ ++echo === Testing gdb vs core file... ++pf_prefix core file ++getLogFromCore ++verifyLog ++((FAILURES+=$?)) ++pf_prefix ++echo === Core file tests done. ++ ++echo ++ ++echo === Testing gdb vs gcore file... ++pf_prefix gcore file ++getLogFromGcore ++verifyLog ++((FAILURES+=$?)) ++pf_prefix ++echo === Gcore file tests done. ++ ++echo ++ ++echo === Testing gdb vs live process... ++pf_prefix live process ++getLogFromLiveProcess ++verifyLog ++((FAILURES+=$?)) ++pf_prefix ++echo === Live process tests done. ++ ++# Executive summary ++echo ++if [ $FAILURES == 0 ] ; then ++ echo All tests passed! ++else ++ echo $FAILURES tests failed! ++ echo ++ echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\). ++fi ++ ++# Clean up ++cd / ++rm -rf $WORKDIR ++ ++exit $FAILURES +Index: ./gdb/testsuite/gdb.threads/threadcrash.sh-orig +=================================================================== +RCS file: gdb/testsuite/gdb.threads/threadcrash.sh-orig +diff -N gdb/testsuite/gdb.threads/threadcrash.sh-orig +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/threadcrash.sh-orig 31 Oct 2006 17:54:38 -0000 +@@ -0,0 +1,248 @@ ++#! /bin/bash ++ ++# NOTE: threadcrash.c *must* be built with debugging symbols ++# ++# The point of this shell script is to crash treadcrash.c, load the ++# resulting core file into gdb and verify that gdb can extract enough ++# information from the core file. ++# ++# The return code from this script is the number of failed tests. ++ ++LOG=gdbresult.log ++ ++if [ $# != 1 ] ; then ++ echo > /dev/stderr Syntax: $0 \ ++ exit 1 ++fi ++RUNME="$1" ++ ++# Verify that the gdb output doesn't contain $1. ++function mustNotHave() { ++ local BADWORD=$1 ++ if grep -q "$BADWORD" $LOG ; then ++ echo >> /dev/stderr WARNING: gdb output contains "$BADWORD" ++ return 1 ++ fi ++ return 0 ++} ++ ++# Verify that the gdb output contains exactly $1 $2s. ++function mustHaveCorrectAmount() { ++ local WANTEDNUMBER=$1 ++ local GOODWORD=$2 ++ local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l) ++ if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then ++ echo >> /dev/stderr WARNING: gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected ++ return 1 ++ fi ++ return 0 ++} ++ ++# Verify that the gdb output contains seven threads ++function mustHaveSevenThreads() { ++ NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l) ++ if [ $NTHREADS != 7 ] ; then ++ echo >> /dev/stderr WARNING: gdb output contains $NTHREADS threads, not 7 as expected ++ return 1 ++ fi ++ return 0 ++} ++ ++# Verify that the gdb output has all parameters on consecutive lines ++function mustHaveSequence() { ++ SEQUENCE="$*" ++ NPARTS=$# ++ grep "$1" -A$((NPARTS - 1)) $LOG > matches.log ++ ++ while [ $# -gt 1 ] ; do ++ shift ++ ((NPARTS--)) ++ grep "$1" -A$((NPARTS - 1)) matches.log > temp.log ++ mv temp.log matches.log ++ done ++ LASTPART=$1 ++ ++ if ! grep -q "$LASTPART" matches.log ; then ++ echo >> /dev/stderr WARNING: gdb output does not contain the sequence: $SEQUENCE ++ return 1 ++ fi ++ return 0 ++} ++ ++# Verify that $LOG contains all information we want ++function verifyLog() { ++ local FAILURES=0 ++ ++ mustNotHave '??' || ((FAILURES++)) ++ mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++)) ++ ++ mustHaveSevenThreads || ((FAILURES++)) ++ mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence Thread "spin (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++)) ++ mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++)) ++ ++ mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++)) ++ ++ return $FAILURES ++} ++ ++# Put result of debugging a core file in $LOG ++function getLogFromCore() { ++ # Make sure we get a core file ++ ulimit -c unlimited || exit 1 ++ ++ # Run the crasher ++ ./$(basename "$RUNME") ++ EXITCODE=$? ++ ++ # Verify that we actually crashed ++ if [ $EXITCODE -lt 128 ] ; then ++ echo >> /dev/stderr ERROR: $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE ++ exit 1 ++ fi ++ ++ # Verify that we got a core file ++ if [ ! -r core* ] ; then ++ echo >> /dev/stderr ERROR: $RUNME did not create a core file ++ exit 1 ++ fi ++ ++ # Run gdb ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE ++ fi ++} ++ ++# Put result of debugging a gcore file in $LOG ++function getLogFromGcore() { ++ # Create the core file ++ rm -f core* ++ cat > gdbscript.gdb < /dev/null ++ EXITCODE=$? ++ ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when creating gcore file ++ fi ++ ++ # Verify that we got a core file from gcore ++ if [ ! -r core* ] ; then ++ echo >> /dev/stderr ERROR: gdb gcore did not create a core file ++ exit 1 ++ fi ++ ++ # Run gdb on the gcore file ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when examining gcore file ++ fi ++} ++ ++# Put result of debugging a core file in $LOG ++function getLogFromLiveProcess() { ++ # Run gdb ++ cat > gdbscript.gdb < $LOG ++ EXITCODE=$? ++ ++ if [ $EXITCODE != 0 ] ; then ++ ((FAILURES++)) ++ echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE ++ fi ++} ++ ++####### Main program follows ##################### ++ ++# Make sure we don't clobber anybody else's (core) file(s) ++WORKDIR=/tmp/$PPID ++mkdir -p $WORKDIR ++cp "$RUNME" $WORKDIR ++cd $WORKDIR ++ ++# Count problems ++FAILURES=0 ++ ++echo === Testing gdb vs core file... ++getLogFromCore ++verifyLog ++((FAILURES+=$?)) ++echo === Core file tests done. ++ ++echo ++ ++echo === Testing gdb vs gcore file... ++getLogFromGcore ++verifyLog ++((FAILURES+=$?)) ++echo === Gcore file tests done. ++ ++echo ++ ++echo === Testing gdb vs live process... ++getLogFromLiveProcess ++verifyLog ++((FAILURES+=$?)) ++echo === Live process tests done. ++ ++# Executive summary ++echo ++if [ $FAILURES == 0 ] ; then ++ echo All tests passed! ++else ++ echo $FAILURES tests failed! ++ echo ++ echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\). ++fi ++ ++# Clean up ++cd / ++rm -rf $WORKDIR ++ ++exit $FAILURES diff --git a/gdb/patches/gdb-6.5-bz109921-DW_AT_decl_file-test.patch b/gdb/patches/gdb-6.5-bz109921-DW_AT_decl_file-test.patch new file mode 100644 index 000000000..70be87570 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz109921-DW_AT_decl_file-test.patch @@ -0,0 +1,120 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=109921 + +It is duplicite to its upstream variant: +http://sourceware.org/ml/gdb-cvs/2007-01/msg00157.html +http://sourceware.org/ml/gdb-patches/2007-01/msg00434.html +2007-01-21 Jan Kratochvil + Daniel Jacobowitz + + * gdb.base/included.c, gdb.base/included.exp, + gdb.base/included.h: New files. + +------------------------------------------------------------------------------ + +2007-01-09 Jan Kratochvil + + * gdb.dwarf2/dw2-included.exp, gdb.dwarf2/dw2-included.c, + gdb.dwarf2/dw2-included.h: New files. + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.dwarf2/dw2-included.c 2 Jan 2007 00:20:27 -0000 +@@ -0,0 +1,26 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. */ ++ ++#include "dw2-included.h" ++ ++int ++main() ++{ ++ return 0; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.dwarf2/dw2-included.exp 2 Jan 2007 00:20:27 -0000 +@@ -0,0 +1,47 @@ ++# 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. ++ ++# Minimal DWARF-2 unit test ++ ++# This test can only be run on targets which support DWARF-2. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-included" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "set listsize 1" "" ++gdb_test "list integer" "int integer;\r" ++gdb_test "ptype integer" "type = int\r" ++# Path varies depending on the build location. ++gdb_test "info variables integer" "\r\nFile \[^\r\n\]*/gdb.dwarf2/dw2-included.h:\r\nint integer;\r" +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.dwarf2/dw2-included.h 2 Jan 2007 00:20:27 -0000 +@@ -0,0 +1,20 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. */ ++ ++int integer; diff --git a/gdb/patches/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb/patches/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch new file mode 100644 index 000000000..fa2f4ed15 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch @@ -0,0 +1,143 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337 + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. + +currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you +will get: + (gdb) p errno + [some error] + +* with -ggdb2 and less "errno" in fact does not exist anywhere as it was + compiled to "(*__errno_location ())" and the macro definition is not present. + Unfortunately gdb will find the TLS symbol and it will try to access it but + as the program has been compiled without -lpthread the TLS base register + (%gs on i386) is not setup and it will result in: + Cannot access memory at address 0x8 + +Attached suggestion patch how to deal with the most common "errno" symbol +for the most common under-ggdb3 compiled programs. + +Original patch hooked into target_translate_tls_address. But its inferior +call invalidates `struct frame *' in the callers - RH BZ 690908. + + +2007-11-03 Jan Kratochvil + + * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer + DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C. + +glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: + <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location + <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location + +--- a/gdb/printcmd.c ++++ b/gdb/printcmd.c +@@ -967,6 +967,8 @@ print_command_1 (char *exp, int inspect, int voidprint) + + if (exp && *exp) + { ++ if (strcmp (exp, "errno") == 0) ++ exp = "*((int *(*) (void)) __errno_location) ()"; + expr = parse_expression (exp); + old_chain = make_cleanup (free_current_contents, &expr); + cleanup = 1; +Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2011-03-29 10:55:35.000000000 +0200 +@@ -0,0 +1,28 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 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 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++#include ++ ++int main() ++{ ++ errno = 42; ++ ++ return 0; /* breakpoint */ ++} +Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2011-03-29 10:55:35.000000000 +0200 +@@ -0,0 +1,60 @@ ++# 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 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 . ++ ++set testfile dw2-errno ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++proc prep {} { ++ global srcdir subdir binfile ++ gdb_exit ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ runto_main ++ ++ gdb_breakpoint [gdb_get_line_number "breakpoint"] ++ gdb_continue_to_breakpoint "breakpoint" ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=N threads=N" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N" ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y" ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y" ++ ++# TODO: Test the error on resolving ERRNO with only libc loaded. ++# Just how to find the current libc filename? diff --git a/gdb/patches/gdb-6.5-bz190810-gdbserver-arch-advice.patch b/gdb/patches/gdb-6.5-bz190810-gdbserver-arch-advice.patch new file mode 100644 index 000000000..c702327c1 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz190810-gdbserver-arch-advice.patch @@ -0,0 +1,28 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=190810 + + +2006-09-26 Jan Kratochvil + + * remote.c (remote_wait): Suggestion on crash due to nonmatching target. + (remote_async_wait): Likewise. + + +Index: gdb-6.8.50.20090818/gdb/remote.c +=================================================================== +--- gdb-6.8.50.20090818.orig/gdb/remote.c 2009-08-18 21:00:35.000000000 +0200 ++++ gdb-6.8.50.20090818/gdb/remote.c 2009-08-18 21:04:46.000000000 +0200 +@@ -4408,8 +4408,13 @@ Packet: '%s'\n"), + VEC_safe_push (cached_reg_t, event->regcache, &cached_reg); + } + ++ /* It may also occur on amd64 which defaults to 32-bit i386 ++ target. gdbserver(1) is not aware of the `set architecture' ++ name itself as it is not using libbfd. */ + if (*p != ';') +- error (_("Remote register badly formatted: %s\nhere: %s"), ++ error (_("Remote register badly formatted: %s\nhere: %s" ++ "\nTry to load the executable by `file' first," ++ "\nyou may also check `set/show architecture'."), + buf, p); + ++p; + } diff --git a/gdb/patches/gdb-6.5-bz203661-emit-relocs.patch b/gdb/patches/gdb-6.5-bz203661-emit-relocs.patch new file mode 100644 index 000000000..61e0d56b6 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz203661-emit-relocs.patch @@ -0,0 +1,17 @@ +Index: gdb-7.0.90.20100306/gdb/symfile.c +=================================================================== +--- gdb-7.0.90.20100306.orig/gdb/symfile.c 2010-03-06 23:20:35.000000000 +0100 ++++ gdb-7.0.90.20100306/gdb/symfile.c 2010-03-06 23:26:25.000000000 +0100 +@@ -3642,6 +3642,12 @@ default_symfile_relocate (struct objfile + { + bfd *abfd = objfile->obfd; + ++ /* Executable files have all the relocations already resolved. ++ * Handle files linked with --emit-relocs. ++ * http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */ ++ if ((abfd->flags & EXEC_P) != 0) ++ return NULL; ++ + /* We're only interested in sections with relocation + information. */ + if ((sectp->flags & SEC_RELOC) == 0) diff --git a/gdb/patches/gdb-6.5-bz216711-clone-is-outermost.patch b/gdb/patches/gdb-6.5-bz216711-clone-is-outermost.patch new file mode 100644 index 000000000..bb7038f9a --- /dev/null +++ b/gdb/patches/gdb-6.5-bz216711-clone-is-outermost.patch @@ -0,0 +1,133 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=216711 + +FIXME: This workaround should be dropped and +glibc/sysdeps/unix/sysv/linux/x86_64/clone.S should get CFI for the child +instead. + +2006-12-17 Jan Kratochvil + + * gdb/amd64-linux-tdep.c (linux_clone_code): New variable. + (LINUX_CLONE_LEN): New definition. + (amd64_linux_clone_running, amd64_linux_outermost_frame): New function. + (amd64_linux_init_abi): Initialize `outermost_frame_p'. + * gdb/i386-tdep.c (i386_gdbarch_init): Likewise. + * gdb/i386-tdep.h (gdbarch_tdep): Add `outermost_frame_p' member. + * gdb/amd64-tdep.c (amd64_frame_this_id): Call `outermost_frame_p'. + +2006-12-17 Jan Kratochvil + + * gdb.threads/bt-clone-stop.exp, gdb.threads/bt-clone-stop.c: + New file. + +2007-10-16 Jan Kratochvil + + Port to GDB-6.7. + +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090802/gdb/testsuite/gdb.threads/bt-clone-stop.c 2009-08-03 15:50:08.000000000 +0200 +@@ -0,0 +1,39 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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., 51 Franklin Street, Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++ ++#include ++#include ++#include ++ ++ ++void *threader (void *arg) ++{ ++ assert (0); ++ return NULL; ++} ++ ++int main (void) ++{ ++ pthread_t t1; ++ ++ pthread_create (&t1, NULL, threader, (void *) NULL); ++ for (;;) ++ pause(); ++} +Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.threads/bt-clone-stop.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090802/gdb/testsuite/gdb.threads/bt-clone-stop.exp 2009-08-03 15:50:08.000000000 +0200 +@@ -0,0 +1,61 @@ ++# 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. ++ ++# Backtraced `clone' must not have `PC == 0' as its previous frame. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile bt-clone-stop ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile_pthreads "${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} ++ ++# threader: threader.c:8: threader: Assertion `0' failed. ++# Program received signal SIGABRT, Aborted. ++ ++gdb_test "run" \ ++ "Program received signal SIGABRT.*" \ ++ "run" ++ ++# Former gdb unwind (the first function is `clone'): ++# #5 0x0000003421ecd62d in ?? () from /lib64/libc.so.6 ++# #6 0x0000000000000000 in ?? () ++# (gdb) ++# Tested `amd64_linux_outermost_frame' functionality should omit the line `#6'. ++# ++# Two `-re' cases below must be in this order (1st is a subset of the 2nd one). ++# Unhandled case below should not happen and it is fortunately handled by ++# `amd64_linux_outermost_frame' as FAIL (and result `0x0 entry output invalid'). ++gdb_test_multiple "bt" "0x0 entry output invalid" { ++ -re "in threader \\(.*\n#\[0-9\]* *0x0* in .*$gdb_prompt $" { ++ fail "0x0 entry found" ++ } ++ -re "in threader \\(.*$gdb_prompt $" { ++ pass "0x0 entry not found" ++ } ++} diff --git a/gdb/patches/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch b/gdb/patches/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch new file mode 100644 index 000000000..bb6f3f16c --- /dev/null +++ b/gdb/patches/gdb-6.5-bz218379-ppc-solib-trampoline-test.patch @@ -0,0 +1,91 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 + + +--- /dev/null 2006-12-17 14:18:21.881669220 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/step-over-trampoline.exp 2006-12-17 16:52:51.000000000 -0500 +@@ -0,0 +1,54 @@ ++# 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. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile step-over-trampoline ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${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} ++ ++# For C programs, "start" should stop in main(). ++ ++gdb_test "start" \ ++ "main \\(\\) at .*$srcfile.*" \ ++ "start" ++ ++# main () at hello2.c:5 ++# 5 puts("hello world\n"); ++# (gdb) next ++# 0x100007e0 in call___do_global_ctors_aux () ++ ++gdb_test_multiple "next" "invalid `next' output" { ++ -re "\nhello world.*return 0;.*" { ++ pass "stepped over" ++ } ++ -re " in call___do_global_ctors_aux \\(\\).*" { ++ fail "stepped into trampoline" ++ } ++} +--- /dev/null 2006-12-17 14:18:21.881669220 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/step-over-trampoline.c 2006-12-17 16:18:12.000000000 -0500 +@@ -0,0 +1,28 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++#include ++ ++int main (void) ++{ ++ puts ("hello world"); ++ return 0; ++} diff --git a/gdb/patches/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/gdb/patches/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch new file mode 100644 index 000000000..082b9a084 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch @@ -0,0 +1,21 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 + + +Index: gdb-7.2.50.20110117/gdb/symtab.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/symtab.c 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/symtab.c 2011-01-17 15:51:48.000000000 +0100 +@@ -2015,6 +2015,13 @@ find_pc_sect_line (CORE_ADDR pc, struct + SYMBOL_LINKAGE_NAME (msymbol)); */ + ; + /* fall through */ ++ /* `msymbol' trampoline may be located before its .text symbol ++ but this text symbol may be the address we were looking for. ++ Avoid `find_pc_sect_line'<->`find_pc_line' infinite loop. ++ Red Hat Bug 218379. */ ++ else if (SYMBOL_VALUE (mfunsym) == pc) ++ warning ("In stub for %s (0x%s); interlocked, please submit the binary to http://bugzilla.redhat.com", SYMBOL_LINKAGE_NAME (msymbol), paddress (target_gdbarch, pc)); ++ /* fall through */ + else + return find_pc_line (SYMBOL_VALUE_ADDRESS (mfunsym), 0); + } diff --git a/gdb/patches/gdb-6.5-bz243845-stale-testing-zombie-test.patch b/gdb/patches/gdb-6.5-bz243845-stale-testing-zombie-test.patch new file mode 100644 index 000000000..1c9b1f2b6 --- /dev/null +++ b/gdb/patches/gdb-6.5-bz243845-stale-testing-zombie-test.patch @@ -0,0 +1,79 @@ +diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp +--- gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp 2007-07-31 13:04:12.000000000 -0400 +@@ -0,0 +1,75 @@ ++# 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 ++} ++ ++# Start the program running and then wait for a bit, to be sure ++# that it can be attached to. ++ ++gdb_exit ++gdb_start ++gdb_load sleep ++ ++set gdb_pid [exp_pid -i [board_info host fileid]] ++set test "identified the child GDB" ++if {$gdb_pid != "" && $gdb_pid > 0} { ++ pass $test ++ verbose -log "Child GDB PID $gdb_pid" ++} else { ++ fail $test ++} ++ ++set testpid [eval exec sleep 10 &] ++exec sleep 2 ++ ++set test "attach" ++gdb_test_multiple "attach $testpid" "$test" { ++ -re "Attaching to program.*`?.*'?, process $testpid..*$gdb_prompt $" { ++ pass "$test" ++ } ++ -re "Attaching to program.*`?.*\.exe'?, process $testpid.*\[Switching to thread $testpid\..*\].*$gdb_prompt $" { ++ # Response expected on Cygwin ++ pass "$test" ++ } ++} ++ ++# Some time to let GDB spawn its testing child. ++exec sleep 2 ++ ++set found none ++foreach procpid [glob -directory /proc -type d {[0-9]*}] { ++ if {[catch {open $procpid/status} statusfi]} { ++ continue ++ } ++ set status [read $statusfi] ++ close $statusfi ++ if {1 ++ && [regexp -line {^Name:\tgdb$} $status] ++ && [regexp -line {^PPid:\t1$} $status] ++ && [regexp -line "^TracerPid:\t$gdb_pid$" $status]} { ++ set found $procpid ++ verbose -log "Found linux_test_for_tracefork zombie PID $procpid" ++ } ++} ++set test "linux_test_for_tracefork leaves no zombie" ++if {$found eq {none}} { ++ pass $test ++} else { ++ fail $test ++} diff --git a/gdb/patches/gdb-6.5-gcore-buffer-limit-test.patch b/gdb/patches/gdb-6.5-gcore-buffer-limit-test.patch new file mode 100644 index 000000000..dad48339c --- /dev/null +++ b/gdb/patches/gdb-6.5-gcore-buffer-limit-test.patch @@ -0,0 +1,139 @@ +diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c +--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c 1970-01-01 01:00:00.000000000 +0100 ++++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c 2008-01-08 11:25:45.000000000 +0100 +@@ -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 ++#include ++ ++#define MEGS 64 ++ ++int main() ++{ ++ void *mem; ++ ++ mem = malloc (MEGS * 1024ULL * 1024ULL); ++ ++ for (;;) ++ sleep (1); ++ ++ return 0; ++} +diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp +--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 1970-01-01 01:00:00.000000000 +0100 ++++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 2008-01-08 11:47:32.000000000 +0100 +@@ -0,0 +1,94 @@ ++# 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. ++ ++set testfile gcore-excessive-memory ++set srcfile ${testfile}.c ++set shfile ${objdir}/${subdir}/${testfile}-gdb.sh ++set corefile ${objdir}/${subdir}/${testfile}.core ++set binfile ${objdir}/${subdir}/${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 diff --git a/gdb/patches/gdb-6.5-ia64-libunwind-leak-test.patch b/gdb/patches/gdb-6.5-ia64-libunwind-leak-test.patch new file mode 100644 index 000000000..c77c67769 --- /dev/null +++ b/gdb/patches/gdb-6.5-ia64-libunwind-leak-test.patch @@ -0,0 +1,120 @@ +diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c +--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c 2007-12-19 15:12:55.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c 2007-12-19 13:55:22.000000000 -0500 +@@ -0,0 +1,29 @@ ++/* 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 */ ++ ++#include ++ ++int main() ++{ ++ for (;;) ++ alarm (0); ++ return 0; ++} +diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp +--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:12:53.000000000 -0500 ++++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:11:35.000000000 -0500 +@@ -0,0 +1,83 @@ ++# 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 unwind-leak ++set srcfile ${testfile}.c ++set shfile ${objdir}/${subdir}/${testfile}-gdb.sh ++set binfile ${objdir}/${subdir}/${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} ++ ++set pid [exp_pid -i [board_info host fileid]] ++ ++# For C programs, "start" should stop in main(). ++ ++gdb_test "start" \ ++ "main \\(\\) at .*$srcfile.*" \ ++ "start" ++ ++set loc [gdb_get_line_number "alarm"] ++gdb_breakpoint $loc ++ ++proc memory_get {} { ++ global pid ++ set fd [open "/proc/$pid/statm"] ++ gets $fd line ++ close $fd ++ # number of pages of data/stack ++ scan $line "%*d%*d%*d%*d%*d%d" drs ++ return $drs ++} ++ ++set cycles 100 ++# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB ++set permit_kb 100 ++verbose -log "cycles = $cycles, permit_kb = $permit_kb" ++ ++set fail 0 ++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} $" { ++ } ++ -re "Segmentation fault" { ++ fail $test ++ set i 0 ++ set fail 1 ++ } ++ } ++ if ![info exists from] { ++ set from [memory_get] ++ } ++} ++set to [memory_get] ++if {!$fail} { ++ verbose -log "from = $from KB, to = $to KB" ++ if {$from > 0 && $to > 10 && $to < $from + $permit_kb} { ++ pass $test ++ } else { ++ fail $test ++ } ++} diff --git a/gdb/patches/gdb-6.5-last-address-space-byte-test.patch b/gdb/patches/gdb-6.5-last-address-space-byte-test.patch new file mode 100644 index 000000000..8bdbb2bc0 --- /dev/null +++ b/gdb/patches/gdb-6.5-last-address-space-byte-test.patch @@ -0,0 +1,56 @@ +Index: ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp +=================================================================== +RCS file: ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp +diff -N ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp 15 Nov 2006 21:43:24 -0000 +@@ -0,0 +1,49 @@ ++# 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. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++# Get things started. ++ ++gdb_exit ++gdb_start ++ ++# i386 (32-bit) only: gdb with Red Hat largecore patch did lock up: ++# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=103263 ++# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=210614 ++ ++# i386: Bug exists when the `target_xfer_memory' condition ++# `(memaddr + len < region->hi)' operates on 64-bit operands on ++# largecore-patched with 32-bit addresses and so it can get `false' with ++# arbitrary `len'. ++ ++# x86_64: The bug is not present as the operands and calculations have the same ++# bit size. Would would still need to pass there the highest address ++# (`memaddr == 0xffffffffffffffff') but we would need to pass `len == 0' ++# to make the condition `(memaddr + len < region->hi)' false. ++# `len == 0' would get caught eariler. ++ ++# Error in the success case is immediate. ++set timeoutold ${timeout} ++set timeout 10 ++ ++gdb_test "x/xb 0xffffffff" \ ++ "Cannot access memory at address 0xffffffff" \ ++ "Read the last address space byte" ++ ++set timeout ${timeoutold} diff --git a/gdb/patches/gdb-6.5-missed-trap-on-step-test.patch b/gdb/patches/gdb-6.5-missed-trap-on-step-test.patch new file mode 100644 index 000000000..2f4436d1d --- /dev/null +++ b/gdb/patches/gdb-6.5-missed-trap-on-step-test.patch @@ -0,0 +1,83 @@ +Fix has been committed to: + gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch + +--- /dev/null 2007-12-14 20:45:09.113039517 +0100 ++++ gdb-6.5/gdb/testsuite/gdb.base/watchpoint-during-step.exp 2007-12-24 19:42:00.000000000 +0100 +@@ -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 ${objdir}/${subdir}/${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" +--- /dev/null 2007-12-14 20:45:09.113039517 +0100 ++++ gdb-6.5/gdb/testsuite/gdb.base/watchpoint-during-step.c 2007-12-24 19:38:10.000000000 +0100 +@@ -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/patches/gdb-6.5-readline-long-line-crash-test.patch b/gdb/patches/gdb-6.5-readline-long-line-crash-test.patch new file mode 100644 index 000000000..86a82a412 --- /dev/null +++ b/gdb/patches/gdb-6.5-readline-long-line-crash-test.patch @@ -0,0 +1,136 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196 + + +Index: ./gdb/testsuite/gdb.base/readline-overflow.exp +=================================================================== +RCS file: ./gdb/testsuite/gdb.base/readline-overflow.exp +diff -N ./gdb/testsuite/gdb.base/readline-overflow.exp +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/readline-overflow.exp 13 Nov 2006 23:42:50 -0000 +@@ -0,0 +1,125 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Jan Kratochvil ++ ++# This file is part of the gdb testsuite. ++ ++# ++# Tests for readline buffer overflow. ++# ++ ++if $tracelevel { ++ strace $tracelevel ++} ++ ++# 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. ++global env ++if [info exists env(INPUTRC)] { ++ set old_inputrc $env(INPUTRC) ++} ++set env(INPUTRC) "/dev/null" ++ ++set oldtimeout1 $timeout ++set timeout 600 ++ ++if [info exists env(GDBHISTFILE)] { ++ set old_gdbhistfile $env(GDBHISTFILE) ++} ++if [info exists env(HISTSIZE)] { ++ set old_histsize $env(HISTSIZE) ++} ++set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history" ++set env(HISTSIZE) "10" ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++ ++set width 11 ++gdb_test "set width $width" \ ++ "" \ ++ "Setting width to $width." ++#gdb_test "set height 1" \ ++# "" \ ++# "Setting height to 1." ++send_gdb "run X" ++set i 0 ++# It crashes using `set width 7' on `set total 3560'. ++# Sometimes it corrupts screen on `set width 7'. ++# Bugreport used `set total 130001': ++# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196 ++# Check also `timeout' above. ++set total 4200 ++gdb_expect { ++ -re X { ++ incr i ++ if {$i <= $total} { ++ send_gdb "X" ++ exp_continue ++ } ++ } ++ -re "\[ \b\r\n\]" { ++ exp_continue ++ } ++ eof { ++ fail "gdb sending total $total characters" ++ note "Failed after sending $i characters, reason: EOF" ++ gdb_clear_suppressed ++ } ++ timeout { ++ fail "gdb sending total $total characters" ++ note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT" ++ gdb_clear_suppressed ++ } ++ default { ++ fail "gdb sending total $total characters" ++ note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]" ++ gdb_clear_suppressed ++ } ++} ++gdb_test "\r" \ ++ "No executable file specified..*" \ ++ "All the characters transferred" ++ ++ ++# Restore globals modified in this test... ++if [info exists old_inputrc] { ++ set env(INPUTRC) $old_inputrc ++} else { ++ unset env(INPUTRC) ++} ++if [info exists old_gdbhistfile] { ++ set env(GDBHISTFILE) $old_gdbhistfile ++} else { ++ unset env(GDBHISTFILE) ++} ++if [info exists old_histsize] { ++ set env(HISTSIZE) $old_histsize ++} else { ++ unset env(HISTSIZE) ++} ++set timeout $oldtimeout1 ++ ++return 0 diff --git a/gdb/patches/gdb-6.5-section-num-fixup-test.patch b/gdb/patches/gdb-6.5-section-num-fixup-test.patch new file mode 100644 index 000000000..53f7fec72 --- /dev/null +++ b/gdb/patches/gdb-6.5-section-num-fixup-test.patch @@ -0,0 +1,111 @@ +diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-lib.c gdb-6.5/gdb/testsuite/gdb.base/datalib-lib.c +--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-lib.c 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/datalib-lib.c 2008-05-29 13:51:50.000000000 -0400 +@@ -0,0 +1,22 @@ ++/* 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 */ ++ ++int var; +diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-main.c gdb-6.5/gdb/testsuite/gdb.base/datalib-main.c +--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-main.c 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/datalib-main.c 2008-05-29 13:51:39.000000000 -0400 +@@ -0,0 +1,26 @@ ++/* 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 */ ++ ++int ++main (void) ++{ ++ return 0; ++} +diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib.exp gdb-6.5/gdb/testsuite/gdb.base/datalib.exp +--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib.exp 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/datalib.exp 2008-05-29 14:58:33.000000000 -0400 +@@ -0,0 +1,51 @@ ++# 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. ++ ++set testfile datalib ++set srcfilemain ${testfile}-main.c ++set srcfilelib ${testfile}-lib.c ++set libfile ${objdir}/${subdir}/${testfile}-lib.so ++set binfile ${objdir}/${subdir}/${testfile}-main ++if { [gdb_compile "${srcdir}/${subdir}/${srcfilelib}" "${libfile}" executable [list debug {additional_flags=-shared -nostdlib}]] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfilemain}" "${binfile} ${libfile}" 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} ++ ++# We must use a separate library as the main executable is compiled to the ++# address 0 by default and it would get fixed up already at the end of ++# INIT_OBJFILE_SECT_INDICES. We also cannot PRELINK it as PRELINK is missing ++# on ia64. The library must be NOSTDLIB as otherwise some stub code would ++# create the `.text' section there. Also DEBUG option is useful as some of ++# the crashes occur in dwarf2read.c. ++ ++# FAIL case: ++# ../../gdb/ia64-tdep.c:2838: internal-error: sect_index_text not initialized ++# A problem internal to GDB has been detected, ++ ++gdb_test "start" \ ++ "main \\(\\) at .*${srcfilemain}.*" \ ++ "start" diff --git a/gdb/patches/gdb-6.5-sharedlibrary-path.patch b/gdb/patches/gdb-6.5-sharedlibrary-path.patch new file mode 100644 index 000000000..3e0c10134 --- /dev/null +++ b/gdb/patches/gdb-6.5-sharedlibrary-path.patch @@ -0,0 +1,171 @@ +If you provided some relative path to the shared library, such as with + export LD_LIBRARY_PATH=. +then gdb would fail to match the shared library name during the TLS lookup. + + +Dropped the workaround/fix for gdb-6.8.50.20081128 - is it still needed? + + +The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'. +The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'. + + +2006-09-01 Jan Kratochvil + + * solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute + requested pathnames to the internal loaded relative pathnames. + +2007-10-16 Jan Kratochvil + + Port to GDB-6.7. + +2008-02-27 Jan Kratochvil + + Port to gdb-6.7.50.20080227. + +Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-main.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-main.c 2008-02-27 09:00:15.000000000 +0100 +@@ -0,0 +1,25 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++int main() ++{ ++ return 0; ++} +Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c 2008-02-27 09:00:15.000000000 +0100 +@@ -0,0 +1,22 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ 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. ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++__thread int var = 42; +--- /dev/null 2009-02-10 00:19:00.494289687 +0100 ++++ gdb-6.8.50.20090209-x/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2009-02-10 00:49:38.000000000 +0100 +@@ -0,0 +1,86 @@ ++# 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. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile tls-sepdebug ++set srcmainfile ${testfile}-main.c ++set srcsharedfile ${testfile}-shared.c ++ ++set binmainfile ${objdir}/${subdir}/${testfile}-main ++set binsharedbase ${testfile}-shared.so ++set binsharedfile ${objdir}/${subdir}/${binsharedbase} ++set binshareddebugfile ${objdir}/${subdir}/${binsharedbase}.debug ++ ++# Use explicit -soname as otherwise the full path to the library would get ++# encoded into ${binmainfile} making LD_LIBRARY_PATH tests useless. ++ ++# FIXME: gcc dependency (-Wl,-soname). ++ ++if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } { ++ untested "Couldn't compile test library" ++ return -1 ++} ++ ++# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'. ++if 0 then { ++ remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}" ++} else { ++ remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}" ++ remote_exec build "objcopy --strip-debug ${binsharedfile}" ++ remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}" ++} ++ ++# Do not use `shlib=' as it will automatically add also -rpath for gcc. ++ ++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" "${binmainfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++# Get things started. ++ ++# Test also the proper resolving of relative library names to absolute ones. ++# \$PWD is easy - it is the absolute way ++# ${subdir} would fail on "print var" ++ ++foreach ld_library_path [list [pwd]/${subdir} ./${subdir}] name { absolute relative } { ++ ++ 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" ++} diff --git a/gdb/patches/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb/patches/gdb-6.6-buildid-locate-core-as-arg.patch new file mode 100644 index 000000000..b9d113402 --- /dev/null +++ b/gdb/patches/gdb-6.6-buildid-locate-core-as-arg.patch @@ -0,0 +1,196 @@ +http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html +Subject: Re: [patch] print a more useful error message for "gdb core" + +[ Fixed up since the mail. ] + +On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote: +> Not an exhaustive list, but if we go down the path of converting "gdb +> corefile" to "gdb -c corefile", then we also need to think about "file +> corefile" being converted to "core corefile" [or "target core +> corefile", "core" is apparently deprecated in favor of "target core"] +> and "target exec corefile" -> "target core corefile". Presumably +> "file corefile" (and "target exec corefile") would discard the +> currently selected executable. But maybe not. Will that be confusing +> for users? I don't know. + +While thinking about it overriding some GDB _commands_ was not my intention. + +There is a general assumption if I have a shell COMMAND and some FILE I can do +$ COMMAND FILE +and COMMAND will appropriately load the FILE. + +FSF GDB currently needs to specify also the executable file for core files +which already inhibits this intuitive expectation. OTOH with the build-id +locating patch which could allow such intuitive start notneeding the +executable file. Still it currently did not work due to the required "-c": +$ COMMAND -c COREFILE + +Entering "file", "core-file" or "attach" commands is already explicit enough +so that it IMO should do what the command name says without any +autodetections. The second command line argument +(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but +neither "attach" accepts a core file nor "core-file" accepts a PID. + + +The patch makes sense only with the build-id patchset so this is not submit +for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending +bfd_check_format_matches) as the patch below is its natural extension. + + +Sorry for the delay, +Jan + + +2010-01-25 Jan Kratochvil + + * exceptions.h (enum errors ): New. + * exec.c: Include exceptions.h. + (exec_file_attach ): Call throw_error (IS_CORE_ERROR, ...). + * main.c (exec_or_core_file_attach): New. + (captured_main ): Set also corearg. + (captured_main ): New variable func. + Call exec_or_core_file_attach if COREARG matches EXECARG. Call + symbol_file_add_main only if CORE_BFD remained NULL. + +Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html +2010-01-20 Doug Evans + + * exec.c (exec_file_attach): Print a more useful error message if the + user did "gdb core". + +Index: gdb-7.2.50.20110218/gdb/exceptions.h +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/exceptions.h 2011-02-14 12:35:44.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/exceptions.h 2011-02-18 10:45:31.000000000 +0100 +@@ -85,6 +85,9 @@ enum errors { + traceframe. */ + NOT_AVAILABLE_ERROR, + ++ /* Attempt to load a core file as executable. */ ++ IS_CORE_ERROR, ++ + /* Add more errors here. */ + NR_ERRORS + }; +Index: gdb-7.2.50.20110218/gdb/exec.c +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/exec.c 2011-02-14 23:08:48.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/exec.c 2011-02-18 10:45:16.000000000 +0100 +@@ -34,6 +34,7 @@ + #include "arch-utils.h" + #include "gdbthread.h" + #include "progspace.h" ++#include "exceptions.h" + + #include + #include "readline/readline.h" +@@ -253,12 +254,27 @@ exec_file_attach (char *filename, int fr + + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + { ++ int is_core; ++ ++ /* If the user accidentally did "gdb core", print a useful ++ error message. Check it only after bfd_object has been checked as ++ a valid executable may get recognized for example also as ++ "trad-core". */ ++ is_core = bfd_check_format (exec_bfd, bfd_core); ++ + /* Make sure to close exec_bfd, or else "run" might try to use + it. */ + exec_close (); +- error (_("\"%s\": not in executable format: %s"), +- scratch_pathname, +- gdb_bfd_errmsg (bfd_get_error (), matching)); ++ ++ if (is_core != 0) ++ throw_error (IS_CORE_ERROR, ++ _("\"%s\" is a core file.\n" ++ "Please specify an executable to debug."), ++ scratch_pathname); ++ else ++ error (_("\"%s\": not in executable format: %s"), ++ scratch_pathname, ++ gdb_bfd_errmsg (bfd_get_error (), matching)); + } + + /* FIXME - This should only be run for RS6000, but the ifdef is a poor +Index: gdb-7.2.50.20110218/gdb/main.c +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/main.c 2011-02-18 10:44:17.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/main.c 2011-02-18 10:45:16.000000000 +0100 +@@ -243,6 +243,36 @@ captured_command_loop (void *data) + return 1; + } + ++/* Call exec_file_attach. If it detected FILENAME is a core file call ++ core_file_command. Print the original exec_file_attach error only if ++ core_file_command failed to find a matching executable. */ ++ ++static void ++exec_or_core_file_attach (char *filename, int from_tty) ++{ ++ volatile struct gdb_exception e; ++ ++ gdb_assert (exec_bfd == NULL); ++ ++ TRY_CATCH (e, RETURN_MASK_ALL) ++ { ++ exec_file_attach (filename, from_tty); ++ } ++ if (e.reason < 0) ++ { ++ if (e.error == IS_CORE_ERROR) ++ { ++ core_file_command (filename, from_tty); ++ ++ /* Iff the core file found its executable suppress the error message ++ from exec_file_attach. */ ++ if (exec_bfd != NULL) ++ return; ++ } ++ throw_exception (e); ++ } ++} ++ + static int + captured_main (void *data) + { +@@ -727,6 +757,8 @@ captured_main (void *data) + { + symarg = argv[optind]; + execarg = argv[optind]; ++ if (optind + 1 == argc && corearg == NULL) ++ corearg = argv[optind]; + optind++; + } + +@@ -868,11 +900,25 @@ captured_main (void *data) + && symarg != NULL + && strcmp (execarg, symarg) == 0) + { ++ catch_command_errors_ftype *func; ++ ++ /* Call exec_or_core_file_attach only if the file was specified as ++ a command line argument (and not an a command line option). */ ++ if (corearg != NULL && strcmp (corearg, execarg) == 0) ++ { ++ func = exec_or_core_file_attach; ++ corearg = NULL; ++ } ++ else ++ func = exec_file_attach; ++ + /* The exec file and the symbol-file are the same. If we can't + open it, better only print one error message. +- catch_command_errors returns non-zero on success! */ +- if (catch_command_errors (exec_file_attach, execarg, +- !batch_flag, RETURN_MASK_ALL)) ++ catch_command_errors returns non-zero on success! ++ Do not load EXECARG as a symbol file if it has been already processed ++ as a core file. */ ++ if (catch_command_errors (func, execarg, !batch_flag, RETURN_MASK_ALL) ++ && core_bfd == NULL) + catch_command_errors (symbol_file_add_main, symarg, + !batch_flag, RETURN_MASK_ALL); + } diff --git a/gdb/patches/gdb-6.6-buildid-locate.patch b/gdb/patches/gdb-6.6-buildid-locate.patch new file mode 100644 index 000000000..022d0ca94 --- /dev/null +++ b/gdb/patches/gdb-6.6-buildid-locate.patch @@ -0,0 +1,1034 @@ +Index: gdb-7.3.50.20110722/gdb/corelow.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/corelow.c 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/corelow.c 2011-07-22 20:13:00.000000000 +0200 +@@ -48,6 +48,9 @@ + #include "progspace.h" + #include "objfiles.h" + #include "wrapper.h" ++#include "auxv.h" ++#include "elf/common.h" ++#include "gdbcmd.h" + + + #ifndef O_LARGEFILE +@@ -279,6 +282,52 @@ add_to_thread_list (bfd *abfd, asection + inferior_ptid = ptid; /* Yes, make it current. */ + } + ++static int build_id_core_loads = 1; ++ ++static void ++build_id_locate_exec (int from_tty) ++{ ++ CORE_ADDR at_entry; ++ struct build_id *build_id; ++ char *exec_filename, *debug_filename; ++ char *build_id_filename; ++ struct cleanup *back_to; ++ ++ if (exec_bfd != NULL || symfile_objfile != NULL) ++ return; ++ ++ if (target_auxv_search (¤t_target, AT_ENTRY, &at_entry) <= 0) ++ return; ++ ++ build_id = build_id_addr_get (at_entry); ++ if (build_id == NULL) ++ return; ++ ++ /* SYMFILE_OBJFILE should refer to the main executable (not only to its ++ separate debug info file). gcc44+ keeps .eh_frame only in the main ++ executable without its duplicate .debug_frame in the separate debug info ++ file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer ++ directly to the separate debug info file. */ ++ ++ exec_filename = build_id_to_filename (build_id, &build_id_filename, 0); ++ back_to = make_cleanup (xfree, build_id_filename); ++ ++ if (exec_filename != NULL) ++ { ++ make_cleanup (xfree, exec_filename); ++ exec_file_attach (exec_filename, from_tty); ++ symbol_file_add_main (exec_filename, from_tty); ++ if (symfile_objfile != NULL) ++ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; ++ } ++ else ++ debug_print_missing (_("the main executable file"), build_id_filename); ++ ++ do_cleanups (back_to); ++ ++ /* No automatic SOLIB_ADD as the libraries would get read twice. */ ++} ++ + /* This routine opens and sets up the core file bfd. */ + + static void +@@ -380,6 +429,12 @@ core_open (char *filename, int from_tty) + push_target (&core_ops); + discard_cleanups (old_chain); + ++ /* Find the build_id identifiers. If it gets executed after ++ POST_CREATE_INFERIOR we would clash with asking to discard the already ++ loaded VDSO symbols. */ ++ if (build_id_core_loads != 0) ++ build_id_locate_exec (from_tty); ++ + /* Do this before acknowledging the inferior, so if + post_create_inferior throws (can happen easilly if you're loading + a core file with the wrong exec), we aren't left with threads +@@ -933,4 +988,11 @@ _initialize_corelow (void) + init_core_ops (); + + add_target (&core_ops); ++ ++ add_setshow_boolean_cmd ("build-id-core-loads", class_files, ++ &build_id_core_loads, _("\ ++Set whether CORE-FILE loads the build-id associated files automatically."), _("\ ++Show whether CORE-FILE loads the build-id associated files automatically.."), ++ NULL, NULL, NULL, ++ &setlist, &showlist); + } +Index: gdb-7.3.50.20110722/gdb/doc/gdb.texinfo +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/doc/gdb.texinfo 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/doc/gdb.texinfo 2011-07-22 20:13:00.000000000 +0200 +@@ -15402,6 +15402,27 @@ information files. + + @end table + ++You can also adjust the current verbosity of the @dfn{build id} locating. ++ ++@table @code ++ ++@kindex set build-id-verbose ++@item set build-id-verbose 0 ++No additional messages are printed. ++ ++@item set build-id-verbose 1 ++Missing separate debug filenames are printed. ++ ++@item set build-id-verbose 2 ++Missing separate debug filenames are printed and also all the parsing of the ++binaries to find their @dfn{build id} content is printed. ++ ++@kindex show build-id-verbose ++@item show build-id-verbose ++Show the current verbosity value for the @dfn{build id} content locating. ++ ++@end table ++ + @cindex @code{.gnu_debuglink} sections + @cindex debug link sections + A debug link is a special section of the executable file named +Index: gdb-7.3.50.20110722/gdb/solib-svr4.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/solib-svr4.c 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/solib-svr4.c 2011-07-22 20:16:10.000000000 +0200 +@@ -1201,9 +1201,49 @@ svr4_current_sos (void) + safe_strerror (errcode)); + else + { +- strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1); +- new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; +- strcpy (new->so_original_name, new->so_name); ++ struct build_id *build_id; ++ ++ strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1); ++ new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ /* May get overwritten below. */ ++ strcpy (new->so_name, new->so_original_name); ++ ++ build_id = build_id_addr_get (lm_dynamic_from_link_map (new)); ++ if (build_id != NULL) ++ { ++ char *name, *build_id_filename; ++ ++ /* Missing the build-id matching separate debug info file ++ would be handled while SO_NAME gets loaded. */ ++ name = build_id_to_filename (build_id, &build_id_filename, 0); ++ if (name != NULL) ++ { ++ strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1); ++ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ xfree (name); ++ } ++ else ++ { ++ debug_print_missing (new->so_name, build_id_filename); ++ ++ /* In the case the main executable was found according to ++ its build-id (from a core file) prevent loading ++ a different build of a library with accidentally the ++ same SO_NAME. ++ ++ It suppresses bogus backtraces (and prints "??" there ++ instead) if the on-disk files no longer match the ++ running program version. */ ++ ++ if (symfile_objfile != NULL ++ && (symfile_objfile->flags ++ & OBJF_BUILD_ID_CORE_LOADED) != 0) ++ new->so_name[0] = 0; ++ } ++ ++ xfree (build_id_filename); ++ xfree (build_id); ++ } + } + xfree (buffer); + +Index: gdb-7.3.50.20110722/gdb/elfread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/elfread.c 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/elfread.c 2011-07-22 20:13:00.000000000 +0200 +@@ -45,6 +45,11 @@ + #include "infcall.h" + #include "gdbthread.h" + #include "regcache.h" ++#include "libbfd.h" ++#include "gdbcore.h" ++#include "gdbcmd.h" ++#include "observer.h" ++#include + + extern void _initialize_elfread (void); + +@@ -1074,16 +1079,65 @@ elf_gnu_ifunc_resolver_return_stop (stru + update_breakpoint_locations (b, sals, sals_end); + } + ++#define BUILD_ID_VERBOSE_NONE 0 ++#define BUILD_ID_VERBOSE_FILENAMES 1 ++#define BUILD_ID_VERBOSE_BINARY_PARSE 2 ++static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES; ++static void ++show_build_id_verbose (struct ui_file *file, int from_tty, ++ struct cmd_list_element *c, const char *value) ++{ ++ fprintf_filtered (file, _("Verbosity level of the build-id locator is %s.\n"), ++ value); ++} ++ + struct build_id + { + size_t size; + gdb_byte data[1]; + }; + +-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */ ++/* Locate NT_GNU_BUILD_ID and return its matching debug filename. ++ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ ++ ++struct build_id * ++build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size) ++{ ++ bfd_byte *p; ++ ++ p = buf; ++ while (p < buf + size) ++ { ++ /* FIXME: bad alignment assumption. */ ++ Elf_External_Note *xnp = (Elf_External_Note *) p; ++ size_t namesz = H_GET_32 (templ, xnp->namesz); ++ size_t descsz = H_GET_32 (templ, xnp->descsz); ++ bfd_byte *descdata = xnp->name + BFD_ALIGN (namesz, 4); ++ ++ if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID ++ && namesz == sizeof "GNU" ++ && memcmp (xnp->name, "GNU", sizeof "GNU") == 0) ++ { ++ size_t size = descsz; ++ gdb_byte *data = (void *) descdata; ++ struct build_id *retval; ++ ++ retval = xmalloc (sizeof *retval - 1 + size); ++ retval->size = size; ++ memcpy (retval->data, data, size); ++ ++ return retval; ++ } ++ p = descdata + BFD_ALIGN (descsz, 4); ++ } ++ return NULL; ++} ++ ++/* Separate debuginfo files have corrupted PHDR but SHDR is correct there. ++ Locate NT_GNU_BUILD_ID from ABFD and return its content. */ + + static struct build_id * +-build_id_bfd_get (bfd *abfd) ++build_id_bfd_shdr_get (bfd *abfd) + { + struct build_id *retval; + +@@ -1099,6 +1153,348 @@ build_id_bfd_get (bfd *abfd) + return retval; + } + ++/* Core files may have missing (corrupt) SHDR but PDHR is correct there. ++ bfd_elf_bfd_from_remote_memory () has too much overhead by ++ allocating/reading all the available ELF PT_LOADs. */ ++ ++static struct build_id * ++build_id_phdr_get (bfd *templ, bfd_vma loadbase, unsigned e_phnum, ++ Elf_Internal_Phdr *i_phdr) ++{ ++ int i; ++ struct build_id *retval = NULL; ++ ++ for (i = 0; i < e_phnum; i++) ++ if (i_phdr[i].p_type == PT_NOTE && i_phdr[i].p_filesz > 0) ++ { ++ Elf_Internal_Phdr *hdr = &i_phdr[i]; ++ gdb_byte *buf; ++ int err; ++ ++ buf = xmalloc (hdr->p_filesz); ++ err = target_read_memory (loadbase + i_phdr[i].p_vaddr, buf, ++ hdr->p_filesz); ++ if (err == 0) ++ retval = build_id_buf_get (templ, buf, hdr->p_filesz); ++ else ++ retval = NULL; ++ xfree (buf); ++ if (retval != NULL) ++ break; ++ } ++ return retval; ++} ++ ++/* First we validate the file by reading in the ELF header and checking ++ the magic number. */ ++ ++static inline bfd_boolean ++elf_file_p (Elf64_External_Ehdr *x_ehdrp64) ++{ ++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); ++ gdb_assert (offsetof (Elf64_External_Ehdr, e_ident) ++ == offsetof (Elf32_External_Ehdr, e_ident)); ++ gdb_assert (sizeof (((Elf64_External_Ehdr *) 0)->e_ident) ++ == sizeof (((Elf32_External_Ehdr *) 0)->e_ident)); ++ ++ return ((x_ehdrp64->e_ident[EI_MAG0] == ELFMAG0) ++ && (x_ehdrp64->e_ident[EI_MAG1] == ELFMAG1) ++ && (x_ehdrp64->e_ident[EI_MAG2] == ELFMAG2) ++ && (x_ehdrp64->e_ident[EI_MAG3] == ELFMAG3)); ++} ++ ++/* Translate an ELF file header in external format into an ELF file header in ++ internal format. */ ++ ++#define H_GET_WORD(bfd, ptr) (is64 ? H_GET_64 (bfd, (ptr)) \ ++ : H_GET_32 (bfd, (ptr))) ++#define H_GET_SIGNED_WORD(bfd, ptr) (is64 ? H_GET_S64 (bfd, (ptr)) \ ++ : H_GET_S32 (bfd, (ptr))) ++ ++static void ++elf_swap_ehdr_in (bfd *abfd, ++ const Elf64_External_Ehdr *src64, ++ Elf_Internal_Ehdr *dst) ++{ ++ int is64 = bfd_get_arch_size (abfd) == 64; ++#define SRC(field) (is64 ? src64->field \ ++ : ((const Elf32_External_Ehdr *) src64)->field) ++ ++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; ++ memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT); ++ dst->e_type = H_GET_16 (abfd, SRC (e_type)); ++ dst->e_machine = H_GET_16 (abfd, SRC (e_machine)); ++ dst->e_version = H_GET_32 (abfd, SRC (e_version)); ++ if (signed_vma) ++ dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry)); ++ else ++ dst->e_entry = H_GET_WORD (abfd, SRC (e_entry)); ++ dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff)); ++ dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff)); ++ dst->e_flags = H_GET_32 (abfd, SRC (e_flags)); ++ dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize)); ++ dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize)); ++ dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum)); ++ dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize)); ++ dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum)); ++ dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx)); ++ ++#undef SRC ++} ++ ++/* Translate an ELF program header table entry in external format into an ++ ELF program header table entry in internal format. */ ++ ++void ++elf_swap_phdr_in (bfd *abfd, ++ const Elf64_External_Phdr *src64, ++ Elf_Internal_Phdr *dst) ++{ ++ int is64 = bfd_get_arch_size (abfd) == 64; ++#define SRC(field) (is64 ? src64->field \ ++ : ((const Elf32_External_Phdr *) src64)->field) ++ ++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; ++ ++ dst->p_type = H_GET_32 (abfd, SRC (p_type)); ++ dst->p_flags = H_GET_32 (abfd, SRC (p_flags)); ++ dst->p_offset = H_GET_WORD (abfd, SRC (p_offset)); ++ if (signed_vma) ++ { ++ dst->p_vaddr = H_GET_SIGNED_WORD (abfd, SRC (p_vaddr)); ++ dst->p_paddr = H_GET_SIGNED_WORD (abfd, SRC (p_paddr)); ++ } ++ else ++ { ++ dst->p_vaddr = H_GET_WORD (abfd, SRC (p_vaddr)); ++ dst->p_paddr = H_GET_WORD (abfd, SRC (p_paddr)); ++ } ++ dst->p_filesz = H_GET_WORD (abfd, SRC (p_filesz)); ++ dst->p_memsz = H_GET_WORD (abfd, SRC (p_memsz)); ++ dst->p_align = H_GET_WORD (abfd, SRC (p_align)); ++ ++#undef SRC ++} ++ ++#undef H_GET_SIGNED_WORD ++#undef H_GET_WORD ++ ++static Elf_Internal_Phdr * ++elf_get_phdr (bfd *templ, bfd_vma ehdr_vma, unsigned *e_phnum_pointer, ++ bfd_vma *loadbase_pointer) ++{ ++ /* sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr) */ ++ Elf64_External_Ehdr x_ehdr64; /* Elf file header, external form */ ++ Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ ++ bfd_size_type x_phdrs_size; ++ gdb_byte *x_phdrs_ptr; ++ Elf_Internal_Phdr *i_phdrs; ++ int err; ++ unsigned int i; ++ bfd_vma loadbase; ++ int loadbase_set; ++ ++ gdb_assert (templ != NULL); ++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); ++ ++ /* Read in the ELF header in external format. */ ++ err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr64, sizeof x_ehdr64); ++ if (err) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Error reading ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ /* Now check to see if we have a valid ELF file, and one that BFD can ++ make use of. The magic number must match, the address size ('class') ++ and byte-swapping must match our XVEC entry. */ ++ ++ if (! elf_file_p (&x_ehdr64) ++ || x_ehdr64.e_ident[EI_VERSION] != EV_CURRENT ++ || !((bfd_get_arch_size (templ) == 64 ++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS64) ++ || (bfd_get_arch_size (templ) == 32 ++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS32))) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ /* Check that file's byte order matches xvec's */ ++ switch (x_ehdr64.e_ident[EI_DATA]) ++ { ++ case ELFDATA2MSB: /* Big-endian */ ++ if (! bfd_header_big_endian (templ)) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "big-endian ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ break; ++ case ELFDATA2LSB: /* Little-endian */ ++ if (! bfd_header_little_endian (templ)) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "little-endian ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ break; ++ case ELFDATANONE: /* No data encoding specified */ ++ default: /* Unknown data encoding specified */ ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "ELF header endianity at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ elf_swap_ehdr_in (templ, &x_ehdr64, &i_ehdr); ++ ++ /* The file header tells where to find the program headers. ++ These are what we use to actually choose what to read. */ ++ ++ if (i_ehdr.e_phentsize != (bfd_get_arch_size (templ) == 64 ++ ? sizeof (Elf64_External_Phdr) ++ : sizeof (Elf32_External_Phdr)) ++ || i_ehdr.e_phnum == 0) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Invalid ELF program headers from the ELF header " ++ "at address 0x%lx"), (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ x_phdrs_size = (bfd_get_arch_size (templ) == 64 ? sizeof (Elf64_External_Phdr) ++ : sizeof (Elf32_External_Phdr)); ++ ++ i_phdrs = xmalloc (i_ehdr.e_phnum * (sizeof *i_phdrs + x_phdrs_size)); ++ x_phdrs_ptr = (void *) &i_phdrs[i_ehdr.e_phnum]; ++ err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs_ptr, ++ i_ehdr.e_phnum * x_phdrs_size); ++ if (err) ++ { ++ free (i_phdrs); ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Error reading " ++ "ELF program headers at address 0x%lx"), ++ (unsigned long) (ehdr_vma + i_ehdr.e_phoff)); ++ return NULL; ++ } ++ ++ loadbase = ehdr_vma; ++ loadbase_set = 0; ++ for (i = 0; i < i_ehdr.e_phnum; ++i) ++ { ++ elf_swap_phdr_in (templ, (Elf64_External_Phdr *) ++ (x_phdrs_ptr + i * x_phdrs_size), &i_phdrs[i]); ++ /* IA-64 vDSO may have two mappings for one segment, where one mapping ++ is executable only, and one is read only. We must not use the ++ executable one (PF_R is the first one, PF_X the second one). */ ++ if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) ++ { ++ /* Only the first PT_LOAD segment indicates the file bias. ++ Next segments may have P_VADDR arbitrarily higher. ++ If the first segment has P_VADDR zero any next segment must not ++ confuse us, the first one sets LOADBASE certainly enough. */ ++ if (!loadbase_set && i_phdrs[i].p_offset == 0) ++ { ++ loadbase = ehdr_vma - i_phdrs[i].p_vaddr; ++ loadbase_set = 1; ++ } ++ } ++ } ++ ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Found ELF header at address 0x%lx, loadbase 0x%lx"), ++ (unsigned long) ehdr_vma, (unsigned long) loadbase); ++ ++ *e_phnum_pointer = i_ehdr.e_phnum; ++ *loadbase_pointer = loadbase; ++ return i_phdrs; ++} ++ ++/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object. ++ Find the first section before ADDR containing an ELF header. ++ We rely on the fact the sections from multiple files do not mix. ++ FIXME: We should check ADDR is contained _inside_ the section with possibly ++ missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently ++ hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */ ++ ++static CORE_ADDR build_id_addr; ++struct build_id_addr_sect ++ { ++ struct build_id_addr_sect *next; ++ asection *sect; ++ }; ++static struct build_id_addr_sect *build_id_addr_sect; ++ ++static void build_id_addr_candidate (bfd *abfd, asection *sect, void *obj) ++{ ++ if (build_id_addr >= bfd_section_vma (abfd, sect)) ++ { ++ struct build_id_addr_sect *candidate; ++ ++ candidate = xmalloc (sizeof *candidate); ++ candidate->next = build_id_addr_sect; ++ build_id_addr_sect = candidate; ++ candidate->sect = sect; ++ } ++} ++ ++struct build_id * ++build_id_addr_get (CORE_ADDR addr) ++{ ++ struct build_id_addr_sect *candidate; ++ struct build_id *retval = NULL; ++ Elf_Internal_Phdr *i_phdr = NULL; ++ bfd_vma loadbase = 0; ++ unsigned e_phnum = 0; ++ ++ if (core_bfd == NULL) ++ return NULL; ++ ++ build_id_addr = addr; ++ gdb_assert (build_id_addr_sect == NULL); ++ bfd_map_over_sections (core_bfd, build_id_addr_candidate, NULL); ++ ++ /* Sections are sorted in the high-to-low VMAs order. ++ Stop the search on the first ELF header we find. ++ Do not continue the search even if it does not contain NT_GNU_BUILD_ID. */ ++ ++ for (candidate = build_id_addr_sect; candidate != NULL; ++ candidate = candidate->next) ++ { ++ i_phdr = elf_get_phdr (core_bfd, ++ bfd_section_vma (core_bfd, candidate->sect), ++ &e_phnum, &loadbase); ++ if (i_phdr != NULL) ++ break; ++ } ++ ++ if (i_phdr != NULL) ++ { ++ retval = build_id_phdr_get (core_bfd, loadbase, e_phnum, i_phdr); ++ xfree (i_phdr); ++ } ++ ++ while (build_id_addr_sect != NULL) ++ { ++ candidate = build_id_addr_sect; ++ build_id_addr_sect = candidate->next; ++ xfree (candidate); ++ } ++ ++ return retval; ++} ++ + /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ + + static int +@@ -1113,7 +1509,7 @@ build_id_verify (const char *filename, s + if (abfd == NULL) + return 0; + +- found = build_id_bfd_get (abfd); ++ found = build_id_bfd_shdr_get (abfd); + + if (found == NULL) + warning (_("File \"%s\" has no build-id, file skipped"), filename); +@@ -1131,14 +1527,15 @@ build_id_verify (const char *filename, s + return retval; + } + +-static char * +-build_id_to_debug_filename (struct build_id *build_id) ++char * ++build_id_to_filename (struct build_id *build_id, char **link_return, ++ int add_debug_suffix) + { + char *link, *debugdir, *retval = NULL; ++ char *link_all = NULL; + + /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ +- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 +- + 2 * build_id->size + (sizeof ".debug" - 1) + 1); ++ link = xmalloc (strlen (debug_file_directory) + 2 * build_id->size + 50); + + /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will + cause "/.build-id/..." lookups. */ +@@ -1149,6 +1546,8 @@ build_id_to_debug_filename (struct build + char *s, *debugdir_end; + gdb_byte *data = build_id->data; + size_t size = build_id->size; ++ unsigned seqno; ++ struct stat statbuf_trash; + + while (*debugdir == DIRNAME_SEPARATOR) + debugdir++; +@@ -1169,39 +1568,242 @@ build_id_to_debug_filename (struct build + *s++ = '/'; + while (size-- > 0) + s += sprintf (s, "%02x", (unsigned) *data++); +- strcpy (s, ".debug"); +- +- /* lrealpath() is expensive even for the usually non-existent files. */ +- if (access (link, F_OK) == 0) +- retval = lrealpath (link); + +- if (retval != NULL && !build_id_verify (retval, build_id)) ++ for (seqno = 0;; seqno++) + { +- xfree (retval); +- retval = NULL; ++ char *s2; ++ ++ if (seqno) ++ { ++ /* 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. */ ++ ++ s2 = s + sprintf (s, ".%u", seqno); ++ } ++ else ++ s2 = s; ++ ++ if (add_debug_suffix) ++ strcpy (s2, ".debug"); ++ else ++ *s2 = 0; ++ ++ /* `access' automatically dereferences LINK. */ ++ if (lstat (link, &statbuf_trash) != 0) ++ { ++ /* Stop increasing SEQNO. */ ++ break; ++ } ++ ++ retval = lrealpath (link); ++ ++ if (retval != NULL && !build_id_verify (retval, build_id)) ++ { ++ xfree (retval); ++ retval = NULL; ++ } ++ ++ if (retval) ++ break; + } + + if (retval != NULL) +- break; ++ { ++ /* LINK_ALL is not used below in this non-NULL RETVAL case. */ ++ break; ++ } ++ ++ if (link_all == NULL) ++ link_all = xstrdup (link); ++ else ++ { ++ size_t len_orig = strlen (link_all); ++ ++ link_all = xrealloc (link_all, len_orig + 1 + strlen (link) + 1); ++ ++ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with ++ its possible use as an argument for installation command. */ ++ link_all[len_orig] = ' '; ++ ++ strcpy (&link_all[len_orig + 1], link); ++ } + + debugdir = debugdir_end; + } + while (*debugdir != 0); + ++ if (link_return != NULL) ++ { ++ if (retval != NULL) ++ { ++ *link_return = link; ++ link = NULL; ++ } ++ else ++ { ++ *link_return = link_all; ++ link_all = NULL; ++ } ++ } ++ xfree (link); ++ xfree (link_all); ++ ++ return retval; ++} ++ ++/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages ++ Try to install the hash file ... ++ avoidance. */ ++ ++struct missing_filepair ++ { ++ char *binary; ++ char *debug; ++ char data[1]; ++ }; ++ ++static struct htab *missing_filepair_hash; ++static struct obstack missing_filepair_obstack; ++ ++static void * ++missing_filepair_xcalloc (size_t nmemb, size_t nmemb_size) ++{ ++ void *retval; ++ size_t size = nmemb * nmemb_size; ++ ++ retval = obstack_alloc (&missing_filepair_obstack, size); ++ memset (retval, 0, size); + return retval; + } + ++static hashval_t ++missing_filepair_hash_func (const struct missing_filepair *elem) ++{ ++ hashval_t retval = 0; ++ ++ retval ^= htab_hash_string (elem->binary); ++ if (elem->debug != NULL) ++ retval ^= htab_hash_string (elem->debug); ++ ++ return retval; ++} ++ ++static int ++missing_filepair_eq (const struct missing_filepair *elem1, ++ const struct missing_filepair *elem2) ++{ ++ return strcmp (elem1->binary, elem2->binary) == 0 ++ && ((elem1->debug == NULL) == (elem2->debug == NULL)) ++ && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0); ++} ++ ++static void ++missing_filepair_change (void) ++{ ++ if (missing_filepair_hash != NULL) ++ { ++ obstack_free (&missing_filepair_obstack, NULL); ++ /* All their memory came just from missing_filepair_OBSTACK. */ ++ missing_filepair_hash = NULL; ++ } ++} ++ ++static void ++debug_print_executable_changed (void) ++{ ++ missing_filepair_change (); ++} ++ ++/* Notify user the file BINARY with (possibly NULL) associated separate debug ++ information file DEBUG is missing. DEBUG may or may not be the build-id ++ file such as would be: ++ /usr/lib/debug/.build-id/dd/b1d2ce632721c47bb9e8679f369e2295ce71be.debug ++ */ ++ ++void ++debug_print_missing (const char *binary, const char *debug) ++{ ++ size_t binary_len0 = strlen (binary) + 1; ++ size_t debug_len0 = debug ? strlen (debug) + 1 : 0; ++ struct missing_filepair missing_filepair_find; ++ struct missing_filepair *missing_filepair; ++ struct missing_filepair **slot; ++ ++ if (build_id_verbose < BUILD_ID_VERBOSE_FILENAMES) ++ return; ++ ++ if (missing_filepair_hash == NULL) ++ { ++ obstack_init (&missing_filepair_obstack); ++ missing_filepair_hash = htab_create_alloc (64, ++ (hashval_t (*) (const void *)) missing_filepair_hash_func, ++ (int (*) (const void *, const void *)) missing_filepair_eq, NULL, ++ missing_filepair_xcalloc, NULL); ++ } ++ ++ /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with ++ obstack_free in the case of a (rare) match. The problem is ALLOC_F for ++ MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance ++ structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly ++ not to free only MISSING_FILEPAIR but also some such structures (allocated ++ during the htab_find_slot call). */ ++ ++ missing_filepair_find.binary = (char *) binary; ++ missing_filepair_find.debug = (char *) debug; ++ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash, ++ &missing_filepair_find, ++ INSERT); ++ ++ /* While it may be still printed duplicitely with the missing debuginfo file ++ * it is due to once printing about the binary file build-id link and once ++ * about the .debug file build-id link as both the build-id symlinks are ++ * located in the debuginfo package. */ ++ ++ if (*slot != NULL) ++ return; ++ ++ missing_filepair = obstack_alloc (&missing_filepair_obstack, ++ sizeof (*missing_filepair) - 1 ++ + binary_len0 + debug_len0); ++ missing_filepair->binary = missing_filepair->data; ++ memcpy (missing_filepair->binary, binary, binary_len0); ++ if (debug != NULL) ++ { ++ missing_filepair->debug = missing_filepair->binary + binary_len0; ++ memcpy (missing_filepair->debug, debug, debug_len0); ++ } ++ else ++ missing_filepair->debug = NULL; ++ ++ *slot = missing_filepair; ++ ++ /* We do not collect and flush these messages as each such message ++ already requires its own separate lines. */ ++ ++ fprintf_unfiltered (gdb_stdlog, ++ _("Missing separate debuginfo for %s\n"), binary); ++ if (debug != NULL) ++ fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), ++ debug); ++} ++ + static char * +-find_separate_debug_file_by_buildid (struct objfile *objfile) ++find_separate_debug_file_by_buildid (struct objfile *objfile, ++ char **build_id_filename_return) + { + struct build_id *build_id; + +- build_id = build_id_bfd_get (objfile->obfd); ++ if (build_id_filename_return) ++ *build_id_filename_return = NULL; ++ ++ build_id = build_id_bfd_shdr_get (objfile->obfd); + if (build_id != NULL) + { + char *build_id_name; + +- build_id_name = build_id_to_debug_filename (build_id); ++ build_id_name = build_id_to_filename (build_id, build_id_filename_return, ++ 1); + xfree (build_id); + /* Prevent looping on a stripped .debug file. */ + if (build_id_name != NULL +@@ -1212,7 +1814,7 @@ find_separate_debug_file_by_buildid (str + xfree (build_id_name); + } + else if (build_id_name != NULL) +- return build_id_name; ++ return build_id_name; + } + return NULL; + } +@@ -1432,9 +2034,10 @@ elf_symfile_read (struct objfile *objfil + `.note.gnu.build-id'. */ + else if (!objfile_has_partial_symbols (objfile)) + { +- char *debugfile; ++ char *debugfile, *build_id_filename; + +- debugfile = find_separate_debug_file_by_buildid (objfile); ++ debugfile = find_separate_debug_file_by_buildid (objfile, ++ &build_id_filename); + + if (debugfile == NULL) + debugfile = find_separate_debug_file_by_debuglink (objfile); +@@ -1446,6 +2049,12 @@ elf_symfile_read (struct objfile *objfil + symbol_file_add_separate (abfd, symfile_flags, objfile); + xfree (debugfile); + } ++ /* Check if any separate debug info has been extracted out. */ ++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") ++ != NULL) ++ debug_print_missing (objfile->name, build_id_filename); ++ ++ xfree (build_id_filename); + } + } + +@@ -1925,4 +2534,16 @@ _initialize_elfread (void) + + elf_objfile_gnu_ifunc_cache_data = register_objfile_data (); + gnu_ifunc_fns_p = &elf_gnu_ifunc_fns; ++ ++ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, ++ _("\ ++Set debugging level of the build-id locator."), _("\ ++Show debugging level of the build-id locator."), _("\ ++Level 1 (default) enables printing the missing debug filenames,\n\ ++level 2 also prints the parsing of binaries to find the identificators."), ++ NULL, ++ show_build_id_verbose, ++ &setlist, &showlist); ++ ++ observer_attach_executable_changed (debug_print_executable_changed); + } +Index: gdb-7.3.50.20110722/gdb/symfile.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symfile.h 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symfile.h 2011-07-22 20:13:00.000000000 +0200 +@@ -609,6 +609,13 @@ void free_symfile_segment_data (struct s + + extern struct cleanup *increment_reading_symtab (void); + ++/* build-id support. */ ++struct build_id; ++extern struct build_id *build_id_addr_get (CORE_ADDR addr); ++extern char *build_id_to_filename (struct build_id *build_id, ++ char **link_return, int add_debug_suffix); ++extern void debug_print_missing (const char *binary, const char *debug); ++ + /* From dwarf2read.c */ + + /* Names for a dwarf2 debugging section. The field NORMAL is the normal +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/gdb.exp 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp 2011-07-22 20:13:00.000000000 +0200 +@@ -1390,6 +1390,16 @@ proc default_gdb_start { } { + warning "Couldn't set the width to 0." + } + } ++ # Turn off the missing warnings as the testsuite does not expect it. ++ send_gdb "set build-id-verbose 0\n" ++ gdb_expect 10 { ++ -re "$gdb_prompt $" { ++ verbose "Disabled the missing debug infos warnings." 2 ++ } ++ timeout { ++ warning "Could not disable the missing debug infos warnings.." ++ } ++ } + return 0; + } + +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/mi-support.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/mi-support.exp 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/mi-support.exp 2011-07-22 20:13:00.000000000 +0200 +@@ -222,6 +222,16 @@ proc default_mi_gdb_start { args } { + } + } + } ++ # Turn off the missing warnings as the testsuite does not expect it. ++ send_gdb "190-gdb-set build-id-verbose 0\n" ++ gdb_expect 10 { ++ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { ++ verbose "Disabled the missing debug infos warnings." 2 ++ } ++ timeout { ++ warning "Could not disable the missing debug infos warnings.." ++ } ++ } + + detect_async + +Index: gdb-7.3.50.20110722/gdb/objfiles.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/objfiles.h 2011-07-22 20:12:40.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/objfiles.h 2011-07-22 20:13:00.000000000 +0200 +@@ -434,6 +434,10 @@ struct objfile + + #define OBJF_PSYMTABS_READ (1 << 4) + ++/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ ++ ++#define OBJF_BUILD_ID_CORE_LOADED (1 << 12) ++ + /* The object file that contains the runtime common minimal symbols + for SunOS4. Note that this objfile has no associated BFD. */ + diff --git a/gdb/patches/gdb-6.6-bz229517-gcore-without-terminal.patch b/gdb/patches/gdb-6.6-bz229517-gcore-without-terminal.patch new file mode 100644 index 000000000..c2d01806e --- /dev/null +++ b/gdb/patches/gdb-6.6-bz229517-gcore-without-terminal.patch @@ -0,0 +1,171 @@ +2007-04-22 Jan Kratochvil + + * gdb_gcore.sh: Redirect GDB from ` + + * gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files. + + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/gcorebg.c 25 Feb 2007 12:21:20 -0000 +@@ -0,0 +1,43 @@ ++#include ++#include ++#include ++#include ++#include ++ ++int main (int argc, char **argv) ++{ ++ pid_t pid = 0; ++ pid_t ppid; ++ char buf[256]; ++ ++ if (argc != 4) ++ { ++ fprintf (stderr, "Syntax: %s {standard|detached} \n", ++ argv[0]); ++ exit (1); ++ } ++ ++ pid = fork (); ++ ++ switch (pid) ++ { ++ case 0: ++ if (strcmp (argv[1], "detached") == 0) ++ setpgrp (); ++ ppid = getppid (); ++ sprintf (buf, "sh %s -o %s %d", argv[2], argv[3], (int) ppid); ++ system (buf); ++ kill (ppid, SIGTERM); ++ break; ++ ++ case -1: ++ perror ("fork err\n"); ++ exit (1); ++ break; ++ ++ default: ++ sleep (60); ++ } ++ ++ return 0; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/gcorebg.exp 25 Feb 2007 12:21:20 -0000 +@@ -0,0 +1,113 @@ ++# 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 ++ ++# This file was written by Jan Kratochvil . ++# This is a test for `gdb_gcore.sh' functionality. ++# It also tests a regression with `gdb_gcore.sh' being run without its ++# accessible terminal. ++ ++if ![info exists GCORE] { ++ set GCORE "${srcdir}/../gdb_gcore.sh" ++} ++verbose "using GCORE = $GCORE" 2 ++ ++set testfile "gcorebg" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set corefile ${objdir}/${subdir}/${testfile}.test ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested gcorebg.exp ++ return -1 ++} ++ ++# Cleanup. ++ ++proc core_clean {} { ++ global corefile ++ ++ foreach file [glob -nocomplain [join [list $corefile *] ""]] { ++ verbose "Delete file $file" 1 ++ remote_file target delete $file ++ } ++} ++core_clean ++remote_file target delete "./gdb" ++ ++# Generate the core file. ++ ++# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command. ++# Setup also `$PATH' appropriately. ++# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'. ++if {$GDB != "gdb"} { ++ file link ./gdb $GDB ++} ++global env ++set oldpath $env(PATH) ++set env(PATH) [join [list . $env(PATH)] ":"] ++verbose "PATH = $env(PATH)" 2 ++ ++# Test file body. ++# $detached == "standard" || $detached == "detached" ++ ++proc test_body { detached } { ++ global binfile ++ global GCORE ++ global corefile ++ ++ set res [remote_spawn target "$binfile $detached $GCORE $corefile"] ++ if { $res < 0 || $res == "" } { ++ fail "Spawning $detached gcore" ++ return 1 ++ } ++ pass "Spawning $detached gcore" ++ remote_expect target 20 { ++ timeout { ++ fail "Spawned $detached gcore finished" ++ remote_exec target "kill -9 -[exp_pid -i $res]" ++ return 1 ++ } ++ eof { ++ pass "Spawned $detached gcore finished" ++ remote_wait target 20 ++ } ++ } ++ ++ if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} { ++ pass "Core file generated by $detached gcore" ++ } else { ++ fail "Core file generated by $detached gcore" ++ } ++ core_clean ++} ++ ++# First a general `gdb_gcore.sh' spawn with its controlling terminal available. ++ ++test_body standard ++ ++# And now `gdb_gcore.sh' spawn without its controlling terminal available. ++# It is spawned through `gcorebg.c' using setpgrp (). ++ ++test_body detached ++ ++ ++# Cleanup. ++ ++set env(PATH) $oldpath ++remote_file target delete "./gdb" diff --git a/gdb/patches/gdb-6.6-bz230000-power6-disassembly-test.patch b/gdb/patches/gdb-6.6-bz230000-power6-disassembly-test.patch new file mode 100644 index 000000000..1ebf31bb0 --- /dev/null +++ b/gdb/patches/gdb-6.6-bz230000-power6-disassembly-test.patch @@ -0,0 +1,83 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=230000 + +The original testcase + https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=230000#c1 +requires too recent GCC. + + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/powerpc-power6.exp 25 Feb 2007 18:27:39 -0000 +@@ -0,0 +1,54 @@ ++# 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. ++ ++# Test PowerPC Power6 instructions disassembly. ++ ++if {![istarget "powerpc*-*-*"]} then { ++ verbose "Skipping PowerPC Power6 instructions disassembly." ++ return ++} ++ ++set testfile "powerpc-power6" ++set srcfile ${testfile}.s ++set objfile ${objdir}/${subdir}/${testfile}.o ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } { ++ untested "PowerPC prologue tests" ++ return -1 ++} ++ ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${objfile} ++ ++# Disassemble the function. ++ ++gdb_test "disass func" ":\tblr\r\n.*" "Basic disassembly" ++ ++gdb_test "disass func" ":\tdcbzl *r8,r9\r\n.*" "Power5 disassembly dcbzl" ++gdb_test "disass func" ":\tfrsqrtes *f10,f11\r\n.*" "Power5 disassembly frsqrtes" ++gdb_test "disass func" ":\tdadd *f1,f2,f1\r\n.*" "Power6 disassembly dadd" ++gdb_test "disass func" ":\tdaddq *f1,f2,f1\r\n.*" "Power6 disassembly daddq" ++gdb_test "disass func" ":\tdsub *f1,f2,f1\r\n.*" "Power6 disassembly dsub" ++gdb_test "disass func" ":\tdsubq *f1,f2,f1\r\n.*" "Power6 disassembly dsubq" ++gdb_test "disass func" ":\tdmul *f1,f2,f1\r\n.*" "Power6 disassembly dmul" ++gdb_test "disass func" ":\tdmulq *f1,f2,f1\r\n.*" "Power6 disassembly dmulq" ++gdb_test "disass func" ":\tddiv *f1,f2,f1\r\n.*" "Power6 disassembly ddiv" ++gdb_test "disass func" ":\tddivq *f1,f2,f1\r\n.*" "Power6 disassembly ddivq" ++gdb_test "disass func" ":\tdcmpu *cr1,f2,f1\r\n.*" "Power6 disassembly dcmpu" ++gdb_test "disass func" ":\tdcmpuq *cr1,f2,f1\r\n.*" "Power6 disassembly dcmpuq" +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/powerpc-power6.s 25 Feb 2007 18:27:39 -0000 +@@ -0,0 +1,16 @@ ++ .text ++ .globl func ++func: ++ blr ++ .long 0x7c284fec /* dcbzl r8,r9 */ ++ .long 0xed405834 /* frsqrtes f10,f11 */ ++ .long 0xec220804 /* dadd f1,f2,f1 */ ++ .long 0xfc220804 /* daddq f1,f2,f1 */ ++ .long 0xec220c04 /* dsub f1,f2,f1 */ ++ .long 0xfc220c04 /* dsubq f1,f2,f1 */ ++ .long 0xec220844 /* dmul f1,f2,f1 */ ++ .long 0xfc220844 /* dmulq f1,f2,f1 */ ++ .long 0xec220c44 /* ddiv f1,f2,f1 */ ++ .long 0xfc220c44 /* ddivq f1,f2,f1 */ ++ .long 0xec820d04 /* dcmpu cr1,f2,f1 */ ++ .long 0xfc820d04 /* dcmpuq cr1,f2,f1 */ diff --git a/gdb/patches/gdb-6.6-bz235197-fork-detach-info.patch b/gdb/patches/gdb-6.6-bz235197-fork-detach-info.patch new file mode 100644 index 000000000..d7263ff27 --- /dev/null +++ b/gdb/patches/gdb-6.6-bz235197-fork-detach-info.patch @@ -0,0 +1,121 @@ +2008-03-01 Jan Kratochvil + + Port to GDB-6.8pre. + Remove the `[' character from the GDB-6.8 default message. + +Index: gdb-7.2.50.20110320/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.50.20110320.orig/gdb/linux-nat.c 2011-03-20 16:59:51.000000000 +0100 ++++ gdb-7.2.50.20110320/gdb/linux-nat.c 2011-03-20 16:59:51.000000000 +0100 +@@ -716,7 +716,7 @@ holding the child stopped. Try \"set de + remove_breakpoints_pid (GET_PID (inferior_ptid)); + } + +- if (info_verbose || debug_linux_nat) ++ if (1 /* Fedora Bug 235197 */ || info_verbose || debug_linux_nat) + { + target_terminal_ours (); + fprintf_filtered (gdb_stdlog, +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.c 2011-03-20 16:59:51.000000000 +0100 +@@ -0,0 +1,57 @@ ++/* 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 */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++static void func (void) ++{ ++} ++ ++int main (void) ++{ ++ pid_t child; ++ ++ child = fork (); ++ switch (child) ++ { ++ case -1: ++ abort (); ++ case 0: ++ func (); ++ break; ++ default: ++ { ++/* We do not test the switching to the other fork by GDB `fork 1'. */ ++#if 0 ++ pid_t got; ++ ++ got = waitpid (child, NULL, 0); ++ assert (got == child); ++#endif ++ break; ++ } ++ } ++ return 0; ++} +Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.exp 2011-03-20 17:12:22.000000000 +0100 +@@ -0,0 +1,36 @@ ++# 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 fork-detach ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${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} ++ ++gdb_run_cmd ++# `Starting program: .*' prefix is available since gdb-6.7. ++gdb_test "" \ ++ "Detaching after fork from child process.*\\\[Inferior .* exited normally\\\]" \ ++ "Info message caught" diff --git a/gdb/patches/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch b/gdb/patches/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch new file mode 100644 index 000000000..928c7fbf1 --- /dev/null +++ b/gdb/patches/gdb-6.6-bz237572-ppc-atomic-sequence-test.patch @@ -0,0 +1,270 @@ +2007-06-25 Jan Kratochvil + + * gdb.threads/atomic-seq-threaded.c, + gdb.threads/atomic-seq-threaded.exp: New files. + +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c 2008-12-08 22:27:01.000000000 +0100 +@@ -0,0 +1,171 @@ ++/* 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., 51 Franklin Street, Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++/* Test stepping over RISC atomic sequences. ++ This variant testcases the code for stepping another thread while skipping ++ over the atomic sequence in the former thread ++ (STEPPING_PAST_SINGLESTEP_BREAKPOINT). ++ Code comes from gcc/testsuite/gcc.dg/sync-2.c */ ++ ++/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ ++/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ ++ ++/* Test functionality of the intrinsics for 'short' and 'char'. */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define LOOPS 2 ++ ++static int unused; ++ ++static char AI[18]; ++static char init_qi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; ++static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; ++ ++static void ++do_qi (void) ++{ ++ if (__sync_fetch_and_add(AI+4, 1) != 0) ++ abort (); ++ if (__sync_fetch_and_add(AI+5, 4) != 0) ++ abort (); ++ if (__sync_fetch_and_add(AI+6, 22) != 0) ++ abort (); ++ if (__sync_fetch_and_sub(AI+7, 12) != 0) ++ abort (); ++ if (__sync_fetch_and_and(AI+8, 7) != (char)-1) ++ abort (); ++ if (__sync_fetch_and_or(AI+9, 8) != 0) ++ abort (); ++ if (__sync_fetch_and_xor(AI+10, 9) != 0) ++ abort (); ++ if (__sync_fetch_and_nand(AI+11, 7) != 0) ++ abort (); ++ ++ if (__sync_add_and_fetch(AI+12, 1) != 1) ++ abort (); ++ if (__sync_sub_and_fetch(AI+13, 12) != (char)-12) ++ abort (); ++ if (__sync_and_and_fetch(AI+14, 7) != 7) ++ abort (); ++ if (__sync_or_and_fetch(AI+15, 8) != 8) ++ abort (); ++ if (__sync_xor_and_fetch(AI+16, 9) != 9) ++ abort (); ++ if (__sync_nand_and_fetch(AI+17, 7) != 7) ++ abort (); ++} ++ ++static short AL[18]; ++static short init_hi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; ++static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; ++ ++static void ++do_hi (void) ++{ ++ if (__sync_fetch_and_add(AL+4, 1) != 0) ++ abort (); ++ if (__sync_fetch_and_add(AL+5, 4) != 0) ++ abort (); ++ if (__sync_fetch_and_add(AL+6, 22) != 0) ++ abort (); ++ if (__sync_fetch_and_sub(AL+7, 12) != 0) ++ abort (); ++ if (__sync_fetch_and_and(AL+8, 7) != -1) ++ abort (); ++ if (__sync_fetch_and_or(AL+9, 8) != 0) ++ abort (); ++ if (__sync_fetch_and_xor(AL+10, 9) != 0) ++ abort (); ++ if (__sync_fetch_and_nand(AL+11, 7) != 0) ++ abort (); ++ ++ if (__sync_add_and_fetch(AL+12, 1) != 1) ++ abort (); ++ if (__sync_sub_and_fetch(AL+13, 12) != -12) ++ abort (); ++ if (__sync_and_and_fetch(AL+14, 7) != 7) ++ abort (); ++ if (__sync_or_and_fetch(AL+15, 8) != 8) ++ abort (); ++ if (__sync_xor_and_fetch(AL+16, 9) != 9) ++ abort (); ++ if (__sync_nand_and_fetch(AL+17, 7) != 7) ++ abort (); ++} ++ ++static void * ++start1 (void *arg) ++{ ++ unsigned loop; ++ sleep(1); ++ ++ for (loop = 0; loop < LOOPS; loop++) ++ { ++ memcpy(AI, init_qi, sizeof(init_qi)); ++ ++ do_qi (); ++ ++ if (memcmp (AI, test_qi, sizeof(test_qi))) ++ abort (); ++ } ++ ++ return arg; /* _delete1_ */ ++} ++ ++static void * ++start2 (void *arg) ++{ ++ unsigned loop; ++ ++ for (loop = 0; loop < LOOPS; loop++) ++ { ++ memcpy(AL, init_hi, sizeof(init_hi)); ++ ++ do_hi (); ++ ++ if (memcmp (AL, test_hi, sizeof(test_hi))) ++ abort (); ++ } ++ ++ return arg; /* _delete2_ */ ++} ++ ++int ++main (int argc, char **argv) ++{ ++ pthread_t thread; ++ int i; ++ ++ i = pthread_create (&thread, NULL, start1, NULL); /* _create_ */ ++ assert (i == 0); /* _create_after_ */ ++ ++ sleep (1); ++ ++ start2 (NULL); ++ ++ i = pthread_join (thread, NULL); /* _delete_ */ ++ assert (i == 0); ++ ++ return 0; /* _exit_ */ ++} +Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp 2008-12-08 22:31:01.000000000 +0100 +@@ -0,0 +1,84 @@ ++# atomic-seq-threaded.exp -- Test case for stepping over RISC atomic code seqs. ++# This variant testcases the code for stepping another thread while skipping ++# over the atomic sequence in the former thread ++# (STEPPING_PAST_SINGLESTEP_BREAKPOINT). ++# Copyright (C) 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 ++ ++set testfile atomic-seq-threaded ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++foreach opts {{} {compiler=gcc4} {FAIL}} { ++ if {$opts eq "FAIL"} { ++ return -1 ++ } ++ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $opts]] eq "" } { ++ break ++ } ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++gdb_load ${binfile} ++if ![runto_main] then { ++ fail "Can't run to main" ++ return 0 ++} ++ ++# pthread_create () will not pass even on x86_64 with software watchpoint. ++# Pass after pthread_create () without any watchpoint active. ++set line [gdb_get_line_number "_create_after_"] ++gdb_test "tbreak $line" \ ++ "reakpoint (\[0-9\]+) at .*$srcfile, line $line\..*" \ ++ "set breakpoint after pthread_create ()" ++gdb_test "c" \ ++ ".*/\\* _create_after_ \\*/.*" \ ++ "run till after pthread_create ()" ++ ++# Without a watchpoint being software no single-stepping would be used. ++set test "Start (software) watchpoint" ++gdb_test_multiple "watch unused" $test { ++ -re "Watchpoint \[0-9\]+: unused.*$gdb_prompt $" { ++ pass $test ++ } ++ -re "Hardware watchpoint \[0-9\]+: unused.*$gdb_prompt $" { ++ # We do not test the goal but still the whole testcase should pass. ++ unsupported $test ++ } ++} ++ ++# More thorough testing of the scheduling logic. ++gdb_test "set scheduler-locking step" "" ++ ++# Critical code path is stepped through at this point. ++set line [gdb_get_line_number "_exit_"] ++gdb_test "tbreak $line" \ ++ "reakpoint \[0-9\]+ at .*$srcfile, line $line\..*" \ ++ "set breakpoint at _exit_" ++gdb_test "c" \ ++ ".*/\\* _exit_ \\*/.*" \ ++ "run till _exit_" ++ ++# Just a nonproblematic program exit. ++gdb_test "c" \ ++ ".*Program exited normally\\..*" \ ++ "run till program exit" diff --git a/gdb/patches/gdb-6.6-scheduler_locking-step-is-default.patch b/gdb/patches/gdb-6.6-scheduler_locking-step-is-default.patch new file mode 100644 index 000000000..50af796f1 --- /dev/null +++ b/gdb/patches/gdb-6.6-scheduler_locking-step-is-default.patch @@ -0,0 +1,54 @@ +Index: gdb-7.3.50.20110722/gdb/infrun.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/infrun.c 2011-07-22 19:12:56.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/infrun.c 2011-07-22 19:17:06.000000000 +0200 +@@ -1549,7 +1549,7 @@ static const char *scheduler_enums[] = { + schedlock_step, + NULL + }; +-static const char *scheduler_mode = schedlock_off; ++static const char *scheduler_mode = schedlock_step; + static void + show_scheduler_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-console.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi-console.exp 2011-01-01 16:33:47.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-console.exp 2011-07-22 19:17:06.000000000 +0200 +@@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ + + mi_run_to_main + ++# thread-id=\"all\" vs. thread-id=\"1\" below: ++mi_gdb_test "210-gdb-set scheduler-locking off" "210\\^done" "set scheduler-locking off" ++ + # Next over the hello() call which will produce lots of output + mi_gdb_test "220-exec-next" \ + "220\\^running(\r\n\\*running,thread-id=\"all\")?" \ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-console.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi2-console.exp 2011-06-23 11:40:50.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-console.exp 2011-07-22 19:17:27.000000000 +0200 +@@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ + + mi_run_to_main + ++# thread-id=\"all\" vs. thread-id=\"1\" below: ++mi_gdb_test "210-gdb-set scheduler-locking off" "210\\^done" "set scheduler-locking off" ++ + # Next over the hello() call which will produce lots of output + mi_gdb_test "220-exec-next" "220\\^running(\r\n)?(\\*running,thread-id=\"all\")?" \ + "Started step over hello" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-cli.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.mi/mi-cli.exp 2011-04-27 12:17:38.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi-cli.exp 2011-07-22 19:17:06.000000000 +0200 +@@ -176,7 +176,7 @@ mi_execute_to "exec-continue" "breakpoin + # Test that the token is output even for CLI commands + # Also test that *stopped includes frame information. + mi_gdb_test "34 next" \ +- ".*34\\\^running.*\\*running,thread-id=\"all\"" \ ++ ".*34\\\^running.*\\*running,thread-id=\"1\"" \ + "34 next: run" + + if {!$async} { diff --git a/gdb/patches/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch b/gdb/patches/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch new file mode 100644 index 000000000..671b457f3 --- /dev/null +++ b/gdb/patches/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch @@ -0,0 +1,205 @@ +2007-06-25 Jan Kratochvil + + * inferior.h (enum resume_step): New definition. + (resume): Change STEP parameter type to ENUM RESUME_STEP. + * infrun.c (resume): Likewise. Extend debug printing of the STEP + parameter. Lock the scheduler only for intentional stepping. + (proceed): Replace the variable ONESTEP with tristate RESUME_STEP. + Set the third RESUME_STEP state according to BPSTAT_SHOULD_STEP. + (currently_stepping): Change the return type to ENUM RESUME_STEP. + Return RESUME_STEP_NEEDED if it is just due to BPSTAT_SHOULD_STEP. + * linux-nat.c (select_singlestep_lwp_callback): Do not focus on + the software watchpoint events. + * linux-nat.h (struct lwp_info): Redeclare STEP as ENUM RESUME_STEP. + +2007-10-19 Jan Kratochvil + + * infrun.c (proceed): RESUME_STEP initialized for non-stepping. + RESUME_STEP set according to STEP only at the end of the function. + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. + +Index: gdb-7.3.50.20110722/gdb/inferior.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/inferior.h 2011-07-22 01:46:08.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/inferior.h 2011-07-22 19:13:30.000000000 +0200 +@@ -158,7 +158,15 @@ extern void reopen_exec_file (void); + /* The `resume' routine should only be called in special circumstances. + Normally, use `proceed', which handles a lot of bookkeeping. */ + +-extern void resume (int, enum target_signal); ++enum resume_step ++ { ++ /* currently_stepping () should return non-zero for non-continue. */ ++ RESUME_STEP_CONTINUE = 0, ++ RESUME_STEP_USER, /* Stepping is intentional by the user. */ ++ RESUME_STEP_NEEDED /* Stepping only for software watchpoints. */ ++ }; ++ ++extern void resume (enum resume_step, enum target_signal); + + extern ptid_t user_visible_resume_ptid (int step); + +Index: gdb-7.3.50.20110722/gdb/infrun.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/infrun.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/infrun.c 2011-07-22 19:12:56.000000000 +0200 +@@ -79,7 +79,7 @@ static int follow_fork (void); + static void set_schedlock_func (char *args, int from_tty, + struct cmd_list_element *c); + +-static int currently_stepping (struct thread_info *tp); ++static enum resume_step currently_stepping (struct thread_info *tp); + + static int currently_stepping_or_nexting_callback (struct thread_info *tp, + void *data); +@@ -1630,7 +1630,8 @@ user_visible_resume_ptid (int step) + } + else if ((scheduler_mode == schedlock_on) + || (scheduler_mode == schedlock_step +- && (step || singlestep_breakpoints_inserted_p))) ++ && (step == RESUME_STEP_USER ++ || singlestep_breakpoints_inserted_p))) + { + /* User-settable 'scheduler' mode requires solo thread resume. */ + resume_ptid = inferior_ptid; +@@ -1648,7 +1649,7 @@ user_visible_resume_ptid (int step) + STEP nonzero if we should step (zero to continue instead). + SIG is the signal to give the inferior (zero for none). */ + void +-resume (int step, enum target_signal sig) ++resume (enum resume_step step, enum target_signal sig) + { + int should_resume = 1; + struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); +@@ -1681,9 +1682,13 @@ resume (int step, enum target_signal sig + + if (debug_infrun) + fprintf_unfiltered (gdb_stdlog, +- "infrun: resume (step=%d, signal=%d), " ++ "infrun: resume (step=%s, signal=%d), " + "trap_expected=%d, current thread [%s] at %s\n", +- step, sig, tp->control.trap_expected, ++ (step == RESUME_STEP_CONTINUE ++ ? "RESUME_STEP_CONTINUE" ++ : (step == RESUME_STEP_USER ? "RESUME_STEP_USER" ++ : "RESUME_STEP_NEEDED")), ++ sig, tp->control.trap_expected, + target_pid_to_str (inferior_ptid), + paddress (gdbarch, pc)); + +@@ -2056,7 +2061,7 @@ proceed (CORE_ADDR addr, enum target_sig + struct thread_info *tp; + CORE_ADDR pc; + struct address_space *aspace; +- int oneproc = 0; ++ enum resume_step resume_step = RESUME_STEP_CONTINUE; + + /* If we're stopped at a fork/vfork, follow the branch set by the + "set follow-fork-mode" command; otherwise, we'll just proceed +@@ -2096,13 +2101,13 @@ proceed (CORE_ADDR addr, enum target_sig + actually be executing the breakpoint insn anyway. + We'll be (un-)executing the previous instruction. */ + +- oneproc = 1; ++ resume_step = RESUME_STEP_USER; + else if (gdbarch_single_step_through_delay_p (gdbarch) + && gdbarch_single_step_through_delay (gdbarch, + get_current_frame ())) + /* We stepped onto an instruction that needs to be stepped + again before re-inserting the breakpoint, do so. */ +- oneproc = 1; ++ resume_step = RESUME_STEP_USER; + } + else + { +@@ -2133,13 +2138,13 @@ proceed (CORE_ADDR addr, enum target_sig + is required it returns TRUE and sets the current thread to + the old thread. */ + if (prepare_to_proceed (step)) +- oneproc = 1; ++ resume_step = RESUME_STEP_USER; + } + + /* prepare_to_proceed may change the current thread. */ + tp = inferior_thread (); + +- if (oneproc) ++ if (resume_step == RESUME_STEP_USER) + { + tp->control.trap_expected = 1; + /* If displaced stepping is enabled, we can step over the +@@ -2226,8 +2231,13 @@ proceed (CORE_ADDR addr, enum target_sig + /* Reset to normal state. */ + init_infwait_state (); + ++ if (step) ++ resume_step = RESUME_STEP_USER; ++ if (resume_step == RESUME_STEP_CONTINUE && bpstat_should_step ()) ++ resume_step = RESUME_STEP_NEEDED; ++ + /* Resume inferior. */ +- resume (oneproc || step || bpstat_should_step (), tp->suspend.stop_signal); ++ resume (resume_step, tp->suspend.stop_signal); + + /* Wait for it to stop (if not standalone) + and in any case decode why it stopped, and act accordingly. */ +@@ -5123,14 +5133,19 @@ process_event_stop_test: + + /* Is thread TP in the middle of single-stepping? */ + +-static int ++static enum resume_step + currently_stepping (struct thread_info *tp) + { +- return ((tp->control.step_range_end +- && tp->control.step_resume_breakpoint == NULL) +- || tp->control.trap_expected +- || tp->stepping_through_solib_after_catch +- || bpstat_should_step ()); ++ if ((tp->control.step_range_end ++ && tp->control.step_resume_breakpoint == NULL) ++ || tp->control.trap_expected ++ || tp->stepping_through_solib_after_catch) ++ return RESUME_STEP_USER; ++ ++ if (bpstat_should_step ()) ++ return RESUME_STEP_NEEDED; ++ ++ return RESUME_STEP_CONTINUE; + } + + /* Returns true if any thread *but* the one passed in "data" is in the +Index: gdb-7.3.50.20110722/gdb/linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linux-nat.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linux-nat.c 2011-07-22 19:10:24.000000000 +0200 +@@ -2986,7 +2986,10 @@ count_events_callback (struct lwp_info * + static int + select_singlestep_lwp_callback (struct lwp_info *lp, void *data) + { +- if (lp->step && lp->status != 0) ++ /* We do not focus on software watchpoints as we would not catch ++ STEPPING_PAST_SINGLESTEP_BREAKPOINT breakpoints in some other thread ++ as they would remain pending due to `Push back breakpoint for %s'. */ ++ if (lp->step == RESUME_STEP_USER && lp->status != 0) + return 1; + else + return 0; +Index: gdb-7.3.50.20110722/gdb/linux-nat.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linux-nat.h 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linux-nat.h 2011-07-22 19:10:24.000000000 +0200 +@@ -55,8 +55,8 @@ struct lwp_info + /* If non-zero, a pending wait status. */ + int status; + +- /* Non-zero if we were stepping this LWP. */ +- int step; ++ /* The kind of stepping of this LWP. */ ++ enum resume_step step; + + /* Non-zero si_signo if this LWP stopped with a trap. si_addr may + be the address of a hardware watchpoint. */ diff --git a/gdb/patches/gdb-6.6-step-thread-exit.patch b/gdb/patches/gdb-6.6-step-thread-exit.patch new file mode 100644 index 000000000..22afbea0c --- /dev/null +++ b/gdb/patches/gdb-6.6-step-thread-exit.patch @@ -0,0 +1,60 @@ +Index: gdb-7.2.50.20101116/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/linux-nat.c 2010-11-16 07:58:15.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/linux-nat.c 2010-11-16 07:59:06.000000000 +0100 +@@ -1863,16 +1863,18 @@ resume_set_callback (struct lwp_info *lp + + static void + linux_nat_resume (struct target_ops *ops, +- ptid_t ptid, int step, enum target_signal signo) ++ ptid_t ptid, int step_int, enum target_signal signo) + { + sigset_t prev_mask; + struct lwp_info *lp; + int resume_many; ++ enum resume_step step = step_int; + + if (debug_linux_nat) + fprintf_unfiltered (gdb_stdlog, + "LLR: Preparing to %s %s, %s, inferior_ptid %s\n", +- step ? "step" : "resume", ++ (step == RESUME_STEP_NEEDED ++ ? "needed" : (step ? "step" : "resume")), + target_pid_to_str (ptid), + (signo != TARGET_SIGNAL_0 + ? strsignal (target_signal_to_host (signo)) : "0"), +@@ -3171,10 +3173,34 @@ linux_nat_filter_event (int lwpid, int s + + if (num_lwps (GET_PID (lp->ptid)) > 1) + { ++ enum resume_step step = lp->step; ++ pid_t pid = GET_PID (lp->ptid); ++ + /* If there is at least one more LWP, then the exit signal + was not the end of the debugged application and should be + ignored. */ + exit_lwp (lp); ++ ++ if (step == RESUME_STEP_USER) ++ { ++ /* Now stop the closest LWP's ... */ ++ lp = find_lwp_pid (pid_to_ptid (pid)); ++ if (!lp) ++ lp = lwp_list; ++ gdb_assert (lp != NULL); ++ errno = 0; ++ ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, ++ (void *) (unsigned long) SIGSTOP); ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "PTRACE_CONT %s, 0, 0 (%s)\n", ++ target_pid_to_str (lp->ptid), ++ errno ? safe_strerror (errno) ++ : "OK"); ++ /* Avoid the silent `delayed SIGSTOP' handling. */ ++ lp->signalled = 0; ++ } ++ + return NULL; + } + } diff --git a/gdb/patches/gdb-6.6-testsuite-timeouts.patch b/gdb/patches/gdb-6.6-testsuite-timeouts.patch new file mode 100644 index 000000000..1166ef0b1 --- /dev/null +++ b/gdb/patches/gdb-6.6-testsuite-timeouts.patch @@ -0,0 +1,42 @@ +--- ./gdb/testsuite/gdb.base/annota1.exp 10 Jan 2007 03:23:04 -0000 1.23 ++++ ./gdb/testsuite/gdb.base/annota1.exp 10 May 2007 12:54:11 -0000 +@@ -57,6 +57,8 @@ if [target_info exists gdb_stub] { + gdb_step_for_stub; + } + ++gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions" ++ + # + # the line at which break main will put the breakpoint + # +--- ./gdb/testsuite/gdb.base/annota3.exp 9 Jan 2007 17:59:09 -0000 1.12 ++++ ./gdb/testsuite/gdb.base/annota3.exp 10 May 2007 12:54:11 -0000 +@@ -56,6 +56,8 @@ if [target_info exists gdb_stub] { + gdb_step_for_stub; + } + ++gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions" ++ + # + # the line at which break main will put the breakpoint + # +--- gdb-6.6/gdb/testsuite/gdb.threads/step-thread-exit.exp-orig 2007-05-10 15:03:15.000000000 +0200 ++++ gdb-6.6/gdb/testsuite/gdb.threads/step-thread-exit.exp 2007-05-10 15:04:24.000000000 +0200 +@@ -58,6 +58,9 @@ gdb_test "continue" "Break.*thread_funct + # thread to be stopped and a message printed to tell us we have stepped + # over the thread exit. + set test "step over thread exit 1" ++# ppc64 is currently failing: ++set timeout_old $timeout ++set timeout 60 + gdb_test_multiple "next" "$test" { + -re "\}.*$gdb_prompt $" { + send_gdb "next\n" +@@ -71,6 +74,7 @@ gdb_test_multiple "next" "$test" { + exp_continue + } + } ++set timeout $timeout_old + + # Without this fixup we could end up in: + # #0 0x00110416 in __kernel_vsyscall () diff --git a/gdb/patches/gdb-6.6-threads-static-test.patch b/gdb/patches/gdb-6.6-threads-static-test.patch new file mode 100644 index 000000000..2bac72296 --- /dev/null +++ b/gdb/patches/gdb-6.6-threads-static-test.patch @@ -0,0 +1,23 @@ +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.threads/staticthreads.exp +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.threads/staticthreads.exp 2010-06-02 23:53:28.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.threads/staticthreads.exp 2010-07-12 11:43:26.000000000 +0200 +@@ -44,6 +44,18 @@ gdb_test_no_output "set print sevenbit-s + # See if the static multi-threaded program runs. + + runto_main ++ ++# See if we get excessive LWP there (patched glibc with unpatched GDB): ++# * 2 Thread 135661664 (LWP 3856) main () at threadloop.c:41 ++# 1 process 3856 main () at threadloop.c:41 ++ ++set test "info threads on start" ++gdb_test_multiple "info threads" "$test" { ++ -re "^info threads\r?\n\[^\r\n\]* Thread \[^\r\n\]*\r?\n$gdb_prompt" { ++ pass "$test" ++ } ++} ++ + gdb_test "break sem_post" + set test "Continue to main's call of sem_post" + gdb_test_multiple "continue" "$test" { diff --git a/gdb/patches/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch b/gdb/patches/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch new file mode 100644 index 000000000..9dc8a7ba2 --- /dev/null +++ b/gdb/patches/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch @@ -0,0 +1,703 @@ +http://sourceware.org/ml/gdb-patches/2007-12/msg00397.html + +2007-12-22 Jan Kratochvil + + * gdb.arch/i386-interface.S, gdb.arch/i386-interface.exp: New files. + +2008-03-02 Jan Kratochvil + + * gdb.arch/i386-interface.exp: Fix a testcase race. + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/i386-interface.S 22 Dec 2007 19:07:28 -0000 +@@ -0,0 +1,628 @@ ++/* 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 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@gnu.org ++ ++ This file is part of the gdb testsuite. ++ ++ This file was produced by: ++ $ gcj -S interface.java -ggdb2 -Wall -m32 ++ from the .java file: ++ interface Interface ++ { ++ } ++ class Class implements Interface ++ { ++ } ++*/ ++ ++ .file "cc28Pp2B.jar" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++ .local _MT_Interface ++ .comm _MT_Interface,0,4 ++ .data ++ .align 4 ++ .type _catch_classes_Interface, @object ++ .size _catch_classes_Interface, 24 ++_catch_classes_Interface: ++ .zero 24 ++ .section .rodata ++ .align 2 ++ .type _Utf1, @object ++ .size _Utf1, 4 ++_Utf1: ++ .value 36121 ++ .value 9 ++ .ascii "Interface" ++ .zero 1 ++.globl _ZN9Interface6class$E ++ .data ++ .align 32 ++ .type _ZN9Interface6class$E, @object ++ .size _ZN9Interface6class$E, 144 ++_ZN9Interface6class$E: ++ .long _ZTVN4java4lang5ClassE+8 ++ .long 403000 ++ .long _Utf1 ++ .value 1536 ++ .zero 2 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long _MT_Interface ++ .value 0 ++ .value 6 ++ .long 0 ++ .long 4 ++ .value 0 ++ .value 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long _catch_classes_Interface ++ .long 0 ++ .long 0 ++ .value 0 ++ .byte 1 ++ .zero 1 ++ .long 0 ++ .value 0 ++ .zero 2 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .hidden _ZN9Interface7class$$E ++.globl _ZN9Interface7class$$E ++ .section .rodata ++ .align 4 ++ .type _ZN9Interface7class$$E, @object ++ .size _ZN9Interface7class$$E, 4 ++_ZN9Interface7class$$E: ++ .long _ZN9Interface6class$E ++ .text ++ .align 2 ++.globl _ZN5ClassC1Ev ++ .type _ZN5ClassC1Ev, @function ++_ZN5ClassC1Ev: ++.LFB2: ++ pushl %ebp ++.LCFI0: ++ movl %esp, %ebp ++.LCFI1: ++ subl $24, %esp ++.LCFI2: ++.LBB2: ++#if 0 ++ .file 1 "interface.java" ++#else ++ .file "interface.java" ++#endif ++ .loc 1 4 0 ++ movl 8(%ebp), %eax ++ movl %eax, -4(%ebp) ++ movl -4(%ebp), %eax ++ movl %eax, (%esp) ++ call _ZN4java4lang6ObjectC1Ev ++.LBE2: ++ leave ++ ret ++.LFE2: ++ .size _ZN5ClassC1Ev, .-_ZN5ClassC1Ev ++ .hidden _ZTVN5ClassE ++.globl _ZTVN5ClassE ++ .data ++ .align 32 ++ .type _ZTVN5ClassE, @object ++ .size _ZTVN5ClassE, 40 ++_ZTVN5ClassE: ++ .long 0 ++ .long 0 ++ .long _ZN5Class6class$E ++ .long 4 ++ .long _ZN4java4lang6Object8finalizeEJvv ++ .long _ZN4java4lang6Object8hashCodeEJiv ++ .long _ZN4java4lang6Object6equalsEJbPS1_ ++ .long _ZN4java4lang6Object8toStringEJPNS0_6StringEv ++ .long _ZN4java4lang6Object5cloneEJPS1_v ++ .long _ZN4java4lang6Object22throwNoSuchMethodErrorEJvv ++ .set .L_ZN5ClassC1Ev0,_ZN5ClassC1Ev ++ .section .rodata ++ .align 2 ++ .type _Utf2, @object ++ .size _Utf2, 4 ++_Utf2: ++ .value 626 ++ .value 6 ++ .ascii "" ++ .zero 1 ++ .align 2 ++ .type _Utf3, @object ++ .size _Utf3, 4 ++_Utf3: ++ .value 39797 ++ .value 3 ++ .ascii "()V" ++ .zero 1 ++ .data ++ .align 4 ++ .type _MT_Class, @object ++ .size _MT_Class, 20 ++_MT_Class: ++ .long _Utf2 ++ .long _Utf3 ++ .value 16384 ++ .value -1 ++ .long .L_ZN5ClassC1Ev0 ++ .long 0 ++ .align 4 ++ .type _IF_Class, @object ++ .size _IF_Class, 4 ++_IF_Class: ++ .long _ZN9Interface6class$E ++ .align 4 ++ .type _catch_classes_Class, @object ++ .size _catch_classes_Class, 24 ++_catch_classes_Class: ++ .zero 24 ++ .section .rodata ++ .align 2 ++ .type _Utf4, @object ++ .size _Utf4, 4 ++_Utf4: ++ .value 47448 ++ .value 5 ++ .ascii "Class" ++ .zero 1 ++.globl _ZN5Class6class$E ++ .data ++ .align 32 ++ .type _ZN5Class6class$E, @object ++ .size _ZN5Class6class$E, 144 ++_ZN5Class6class$E: ++ .long _ZTVN4java4lang5ClassE+8 ++ .long 403000 ++ .long _Utf4 ++ .value 32 ++ .zero 2 ++ .long _ZN4java4lang6Object6class$E ++ .long 0 ++ .long 0 ++ .long 0 ++ .long _MT_Class ++ .value 1 ++ .value 6 ++ .long 0 ++ .long 4 ++ .value 0 ++ .value 0 ++ .long _ZTVN5ClassE+8 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long _catch_classes_Class ++ .long _IF_Class ++ .long 0 ++ .value 1 ++ .byte 1 ++ .zero 1 ++ .long 0 ++ .value 0 ++ .zero 2 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .long 0 ++ .hidden _ZN5Class7class$$E ++.globl _ZN5Class7class$$E ++ .section .rodata ++ .align 4 ++ .type _ZN5Class7class$$E, @object ++ .size _ZN5Class7class$$E, 4 ++_ZN5Class7class$$E: ++ .long _ZN5Class6class$E ++ .section .jcr,"aw",@progbits ++ .align 4 ++ .long _ZN9Interface6class$E ++ .long _ZN5Class6class$E ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -4 ++ .byte 0x8 ++ .byte 0xc ++ .uleb128 0x4 ++ .uleb128 0x4 ++ .byte 0x88 ++ .uleb128 0x1 ++ .align 4 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x8 ++ .byte 0x85 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x5 ++ .align 4 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++.globl __gcj_personality_v0 ++ .string "zP" ++ .uleb128 0x1 ++ .sleb128 -4 ++ .byte 0x8 ++ .uleb128 0x5 ++ .byte 0x0 ++ .long __gcj_personality_v0 ++ .byte 0xc ++ .uleb128 0x4 ++ .uleb128 0x4 ++ .byte 0x88 ++ .uleb128 0x1 ++ .align 4 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x8 ++ .byte 0x85 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x5 ++ .align 4 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .long .LFB2-.Ltext0 ++ .long .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x74 ++ .sleb128 4 ++ .long .LCFI0-.Ltext0 ++ .long .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x74 ++ .sleb128 8 ++ .long .LCFI1-.Ltext0 ++ .long .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x75 ++ .sleb128 8 ++ .long 0x0 ++ .long 0x0 ++ .section .debug_info ++ .long 0x117 ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x4 ++ .uleb128 0x1 ++ .string "GNU Java 4.3.0 20071221 (experimental)" ++ .byte 0xb ++ .string "interface.java" ++ .string "/home/jkratoch/redhat/bz371831" ++ .long .Ltext0 ++ .long .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .string "Interface" ++ .byte 0x4 ++ .byte 0x1 ++ .byte 0x0 ++ .long 0x8e ++ .long 0x8e ++ .uleb128 0x3 ++ .long 0x8e ++ .byte 0x2 ++ .byte 0x23 ++ .uleb128 0x0 ++ .byte 0x1 ++ .byte 0x0 ++ .uleb128 0x4 ++ .string "java.lang.Object" ++ .byte 0x1 ++ .uleb128 0x5 ++ .string "Class" ++ .byte 0x4 ++ .byte 0x1 ++ .byte 0x0 ++ .long 0x8e ++ .long 0xe8 ++ .uleb128 0x3 ++ .long 0x8e ++ .byte 0x2 ++ .byte 0x23 ++ .uleb128 0x0 ++ .byte 0x1 ++ .uleb128 0x6 ++ .long 0x6e ++ .byte 0x2 ++ .byte 0x23 ++ .uleb128 0x0 ++ .byte 0x1 ++ .byte 0x1 ++ .uleb128 0x7 ++ .byte 0x1 ++ .string "" ++ .byte 0x1 ++ .byte 0x0 ++ .string "_ZN5ClassC1Ev" ++ .byte 0x1 ++ .uleb128 0x8 ++ .long 0xe8 ++ .byte 0x1 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .byte 0x4 ++ .long 0xa1 ++ .uleb128 0xa ++ .long 0xc6 ++ .long .LFB2 ++ .long .LFE2 ++ .long .LLST0 ++ .long 0x114 ++ .uleb128 0xb ++ .long 0xe8 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 0 ++ .uleb128 0xc ++ .long 0x114 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -12 ++ .byte 0x0 ++ .uleb128 0x9 ++ .byte 0x4 ++ .long 0x8e ++ .byte 0x0 ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0x8 ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x1b ++ .uleb128 0x8 ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x38 ++ .byte 0x1 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x1d ++ .uleb128 0x13 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x1c ++ .byte 0x0 ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x38 ++ .uleb128 0xa ++ .uleb128 0x32 ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x2 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3c ++ .uleb128 0xc ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x2 ++ .byte 0x1 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x1d ++ .uleb128 0x13 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x1c ++ .byte 0x0 ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x38 ++ .uleb128 0xa ++ .uleb128 0x4c ++ .uleb128 0xb ++ .uleb128 0x32 ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x2007 ++ .uleb128 0x8 ++ .uleb128 0x3c ++ .uleb128 0xc ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x34 ++ .uleb128 0xc ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0xf ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x47 ++ .uleb128 0x13 ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xc ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x15 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0x11b ++ .long 0xee ++ .string "()" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x1c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x4 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .long .Ltext0 ++ .long .Letext0-.Ltext0 ++ .long 0x0 ++ .long 0x0 ++ .ident "GCC: (GNU) 4.3.0 20071221 (experimental)" ++ .section .note.GNU-stack,"",@progbits +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/i386-interface.exp 22 Dec 2007 19:07:28 -0000 +@@ -0,0 +1,59 @@ ++# 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 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 . ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@gnu.org ++ ++# This file is part of the gdb testsuite. ++ ++# Test basis recognization of DW_TAG_interface_type. ++# GCC java_classify_record() produces it if returns RECORD_IS_INTERFACE. ++ ++if {![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]} then { ++ verbose "Skipping i386 Java DW_TAG_interface_type test." ++ return ++} ++ ++set testfile "i386-interface" ++set srcfile ${testfile}.S ++set binfile ${objdir}/${subdir}/${testfile}.o ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug additional_flags=-m32}] != "" } { ++ untested i386-gnu-cfi.exp ++ return -1 ++} ++ ++# Get things started. ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "set language java" ++ ++set test "ptype Interface" ++gdb_test_multiple $test $test { ++ -re "type = class Interface *extends java.lang.Object \{.*$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++set test "ptype Class" ++gdb_test_multiple $test $test { ++ -re "type = class Class *extends java.lang.Object implements Interface \{.*$gdb_prompt $" { ++ pass $test ++ } ++} diff --git a/gdb/patches/gdb-6.7-charsign-test.patch b/gdb/patches/gdb-6.7-charsign-test.patch new file mode 100644 index 000000000..793ff8a28 --- /dev/null +++ b/gdb/patches/gdb-6.7-charsign-test.patch @@ -0,0 +1,118 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224128 + +2007-01-25 Jan Kratochvil + + * gdb.base/charsign.exp, gdb.base/charsign.c: New files. + [ stripped ] + +2007-10-19 Jan Kratochvil + + Port to GDB-6.7 - only the testcase left, patch has been reverted, + char-vectors restricted. + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/charsign.c 26 Jan 2007 10:32:00 -0000 +@@ -0,0 +1,37 @@ ++/* 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 */ ++ ++int main() ++{ ++ return 0; ++} ++ ++char n[]="A"; ++signed char s[]="A"; ++unsigned char u[]="A"; ++ ++typedef char char_n; ++typedef signed char char_s; ++typedef unsigned char char_u; ++ ++char_n n_typed[]="A"; ++char_s s_typed[]="A"; ++char_u u_typed[]="A"; +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/charsign.exp 26 Jan 2007 10:32:00 -0000 +@@ -0,0 +1,63 @@ ++# 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 charsign ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++proc do_test { cflags } { ++ global srcdir ++ global binfile ++ global subdir ++ global srcfile ++ global gdb_prompt ++ ++ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=$cflags]] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++ } ++ ++ # Get things started. ++ ++ gdb_exit ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ # For C programs, "start" should stop in main(). ++ ++ gdb_test "p n" \ ++ "= \"A\"" ++ gdb_test "p s" \ ++ "= \\{65 'A', 0 '\\\\0'\\}" ++ gdb_test "p u" \ ++ "= \\{65 'A', 0 '\\\\0'\\}" ++ gdb_test "p n_typed" \ ++ "= \"A\"" ++ gdb_test "p s_typed" \ ++ "= \\{65 'A', 0 '\\\\0'\\}" ++ gdb_test "p u_typed" \ ++ "= \\{65 'A', 0 '\\\\0'\\}" ++} ++ ++# The string identification works despite the compiler flags below due to ++# gdbtypes.c: ++# if (name && strcmp (name, "char") == 0) ++# TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN; ++ ++do_test {} ++do_test {-fsigned-char} ++do_test {-funsigned-char} diff --git a/gdb/patches/gdb-6.7-ppc-clobbered-registers-O2-test.patch b/gdb/patches/gdb-6.7-ppc-clobbered-registers-O2-test.patch new file mode 100644 index 000000000..761d10fc2 --- /dev/null +++ b/gdb/patches/gdb-6.7-ppc-clobbered-registers-O2-test.patch @@ -0,0 +1,96 @@ +2007-11-04 Jan Kratochvil + + * gdb.arch/ppc-clobbered-registers-O2.exp: `powerpc64' changed to + `powerpc*'. + +Testcase for: + +http://sourceware.org/ml/gdb-patches/2007-09/msg00228.html + +2007-10-21 Luis Machado + + * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): New function. + * (rs6000_gdbarch_init): Install ppc_dwarf2_frame_init_reg as + default dwarf2_frame_set_init_reg function. + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.c 3 Nov 2007 22:22:28 -0000 +@@ -0,0 +1,21 @@ ++ ++unsigned * __attribute__((noinline)) ++start_sequence (unsigned * x, unsigned * y) ++{ ++ return (unsigned *)0xdeadbeef; ++}; ++ ++unsigned __attribute__((noinline)) ++gen_movsd (unsigned * operand0, unsigned * operand1) ++{ ++ return *start_sequence(operand0, operand1); ++} ++ ++int main(void) ++{ ++ unsigned x, y; ++ ++ x = 13; ++ y = 14; ++ return (int)gen_movsd (&x, &y); ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.exp 3 Nov 2007 22:22:28 -0000 +@@ -0,0 +1,54 @@ ++# 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. ++# ++# This file is part of the gdb testsuite. ++ ++# Test displaying call clobbered registers in optimized binaries for ppc. ++# GDB should not show incorrect values. ++ ++if ![istarget "powerpc*-*"] then { ++ verbose "Skipping powerpc* call clobbered registers testing." ++ return ++} ++ ++set testfile "ppc-clobbered-registers-O2" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set compile_flags "debug additional_flags=-O2" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${compile_flags}] != "" } { ++ unsupported "Testcase compile failed." ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] then { ++ perror "Couldn't run to breakpoint" ++ continue ++} ++ ++gdb_test "b start_sequence" ".*Breakpoint 2 at.*line 6.*" \ ++ "Insert breakpoint at problematic function" ++ ++gdb_test continue ".*Breakpoint 2.*in start_sequence.*" \ ++ "Run until problematic function" ++ ++gdb_test backtrace ".*operand0=.*operand1=.*" \ ++ "Check value of call clobbered registers" diff --git a/gdb/patches/gdb-6.7-testsuite-stable-results.patch b/gdb/patches/gdb-6.7-testsuite-stable-results.patch new file mode 100644 index 000000000..a4c195c6a --- /dev/null +++ b/gdb/patches/gdb-6.7-testsuite-stable-results.patch @@ -0,0 +1,108 @@ +gdb/testsuite/gdb.base/fileio.c: +gdb/testsuite/gdb.base/fileio.exp: +2007-12-08 Jan Kratochvil + + * gdb.base/fileio.c (ROOTSUBDIR): New macro. + (main): CHDIR into ROOTSUBDIR. CHOWN ROOTSUBDIR and CHDIR into + ROOTSUBDIR if we are being run as root. + * gdb.base/fileio.exp: Change the startup and finish cleanup. + Change the test file reference to be into the `fileio.dir' directory. + + +sources/gdb/testsuite/gdb.base/dump.exp: +Found on RHEL-5.s390x. + + +gdb-6.8.50.20090209/gdb/testsuite/gdb.base/auxv.exp: +random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore + + +gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp: +frames-invalid can happen asynchronously. + +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.base/fileio.c 2009-10-01 17:39:13.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.c 2010-07-12 11:41:43.000000000 +0200 +@@ -58,6 +58,8 @@ system (const char * string); + 1) Invalid string/command. - returns 127. */ + static const char *strerrno (int err); + ++#define ROOTSUBDIR "fileio.dir" ++ + #define FILENAME "foo.fileio.test" + #define RENAMED "bar.fileio.test" + #define NONEXISTANT "nofoo.fileio.test" +@@ -542,6 +544,37 @@ strerrno (int err) + int + main () + { ++ /* ROOTSUBDIR is already prepared by fileio.exp. We use it for easy cleanup ++ (by fileio.exp) if we are run by multiple users in the same directory. */ ++ ++ if (chdir (ROOTSUBDIR) != 0) ++ { ++ printf ("chdir " ROOTSUBDIR ": %s\n", strerror (errno)); ++ exit (1); ++ } ++ ++ /* These tests ++ Open for write but no write permission returns EACCES ++ Unlinking a file in a directory w/o write access returns EACCES ++ fail if we are being run as root - drop the privileges here. */ ++ ++ if (geteuid () == 0) ++ { ++ uid_t uid = 99; ++ ++ if (chown (".", uid, uid) != 0) ++ { ++ printf ("chown %d.%d " ROOTSUBDIR ": %s\n", (int) uid, (int) uid, ++ strerror (errno)); ++ exit (1); ++ } ++ if (setuid (uid) || geteuid () == 0) ++ { ++ printf ("setuid %d: %s\n", (int) uid, strerror (errno)); ++ exit (1); ++ } ++ } ++ + /* Don't change the order of the calls. They partly depend on each other */ + test_open (); + test_write (); +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.exp +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.base/fileio.exp 2010-06-09 00:58:03.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.exp 2010-07-12 11:42:07.000000000 +0200 +@@ -42,8 +42,8 @@ if [get_compiler_info ${binfile}] { + return -1; + } + +-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test} +-remote_exec build {sh -xc rm\ -rf\ *.fileio.test} ++remote_exec build {sh -xc rm\ -rf\ fileio.dir} ++remote_exec build {sh -xc mkdir\ -m777\ fileio.dir} + + set oldtimeout $timeout + set timeout [expr "$timeout + 60"] +@@ -85,7 +85,7 @@ gdb_test continue \ + + gdb_test "continue" ".*" "" + +-catch "system \"chmod -f -w nowrt.fileio.test\"" ++catch "system \"chmod -f -w fileio.dir/nowrt.fileio.test\"" + + gdb_test continue \ + "Continuing\\..*open 5:.*EACCES$stop_msg" \ +@@ -250,8 +250,8 @@ gdb_test continue \ + send_gdb "quit\n" + send_gdb "y\n" + +-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test} +-remote_exec build {sh -xc rm\ -rf\ *.fileio.test} ++remote_exec build {sh -xc test\ -r\ fileio.dir/dir2.fileio.test\ &&\ chmod\ -f\ +w\ fileio.dir/dir2.fileio.test} ++remote_exec build {sh -xc rm\ -rf\ fileio.dir} + + set timeout $oldtimeout + return 0 diff --git a/gdb/patches/gdb-6.8-attach-signalled-detach-stopped.patch b/gdb/patches/gdb-6.8-attach-signalled-detach-stopped.patch new file mode 100644 index 000000000..a5181220e --- /dev/null +++ b/gdb/patches/gdb-6.8-attach-signalled-detach-stopped.patch @@ -0,0 +1,183 @@ +Index: gdb-7.0.50.20100115/gdb/linux-nat.c +=================================================================== +--- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 11:53:34.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 12:13:53.000000000 +0100 +@@ -208,6 +208,9 @@ blocked. */ + static struct target_ops *linux_ops; + static struct target_ops linux_ops_saved; + ++/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */ ++static pid_t pid_was_stopped; ++ + /* The method to call, if any, when a new thread is attached. */ + static void (*linux_nat_new_thread) (ptid_t); + +@@ -933,7 +936,14 @@ Attaching after process %d fork to child + parent_inf->waiting_for_vfork_done = 0; + } + else if (detach_fork) +- target_detach (NULL, 0); ++ { ++ /* We should check PID_WAS_STOPPED and detach it stopped accordingly. ++ In this point of code it cannot be 1 as we would not get FORK ++ executed without CONTINUE first which resets PID_WAS_STOPPED. ++ We would have to first TARGET_STOP and WAITPID it as with running ++ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */ ++ target_detach (NULL, 0); ++ } + + /* Note that the detach above makes PARENT_INF dangling. */ + +@@ -1427,6 +1437,7 @@ linux_nat_post_attach_wait (ptid_t ptid, + if (debug_linux_nat) + fprintf_unfiltered (gdb_stdlog, + "LNPAW: Attaching to a stopped process\n"); ++ pid_was_stopped = GET_PID (ptid); + + /* The process is definitely stopped. It is in a job control + stop, unless the kernel predates the TASK_STOPPED / +@@ -1757,6 +1768,9 @@ GPT: lwp %s had signal %s, but it is in + target_signal_to_string (signo)); + } + ++ if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped) ++ *status = W_STOPCODE (SIGSTOP); ++ + return 0; + } + +@@ -1866,6 +1880,8 @@ linux_nat_detach (struct target_ops *ops + } + else + linux_ops->to_detach (ops, args, from_tty); ++ ++ pid_was_stopped = 0; + } + + /* Resume LP. */ +@@ -2031,6 +2047,14 @@ linux_nat_resume (struct target_ops *ops + resume_callback. */ + lp->stopped = 0; + ++ /* At this point, we are going to resume the inferior and if we ++ have attached to a stopped process, we no longer should leave ++ it as stopped if the user detaches. PTID variable has PID set to LWP ++ while we need to check the real PID here. */ ++ ++ if (!step && lp && pid_was_stopped == GET_PID (lp->ptid)) ++ pid_was_stopped = 0; ++ + if (resume_many) + iterate_over_lwps (ptid, resume_callback, NULL); + +@@ -3923,6 +3947,8 @@ linux_nat_mourn_inferior (struct target_ + there are other viable forks to debug. Delete the exiting + one and context-switch to the first available. */ + linux_fork_mourn_inferior (); ++ ++ pid_was_stopped = 0; + } + + /* Convert a native/host siginfo object, into/from the siginfo in the +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp +=================================================================== +--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-01 08:32:06.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-15 11:54:57.000000000 +0100 +@@ -62,7 +62,65 @@ proc corefunc { threadtype } { + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + +- # Verify that we can attach to the stopped process. ++ # Verify that we can attach to the process by first giving its ++ # executable name via the file command, and using attach with the ++ # process ID. ++ ++ set test "$threadtype: set file, before attach1 to stopped process" ++ gdb_test_multiple "file $binfile" "$test" { ++ -re "Load new symbol table from.*y or n. $" { ++ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \ ++ "$test (re-read)" ++ } ++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" { ++ pass "$test" ++ } ++ } ++ ++ set test "$threadtype: attach1 to stopped, after setting file" ++ gdb_test_multiple "attach $testpid" "$test" { ++ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" { ++ pass "$test" ++ } ++ } ++ ++ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there. ++ if {[string equal $threadtype threaded]} { ++ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt" ++ } else { ++ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt" ++ } ++ ++ # Exit and detach the process. ++ ++ gdb_exit ++ ++ # Avoid some race: ++ sleep 2 ++ ++ if [catch {open /proc/${testpid}/status r} fileid] { ++ set line2 "NOTFOUND" ++ } else { ++ gets $fileid line1; ++ gets $fileid line2; ++ close $fileid; ++ } ++ ++ set test "$threadtype: attach1, exit leaves process stopped" ++ if {[string match "*(stopped)*" $line2]} { ++ pass $test ++ } else { ++ fail $test ++ } ++ ++ # At this point, the process should still be stopped ++ ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ # Verify that we can attach to the process just by giving the ++ # process ID. + + set test "$threadtype: attach2 to stopped, after setting file" + gdb_test_multiple "attach $testpid" "$test" { +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attachstop-mt.exp +=================================================================== +--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/attachstop-mt.exp 2010-01-01 08:32:06.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attachstop-mt.exp 2010-01-15 11:54:57.000000000 +0100 +@@ -176,12 +176,23 @@ gdb_test "bt" ".*sleep.*(func|main).*" " + # Exit and detach the process. + gdb_exit + +-# Stop the program +-remote_exec build "kill -s STOP ${testpid}" +- + # No race + sleep 2 + ++set fileid3 [open $status2 r]; ++gets $fileid3 line1; ++gets $fileid3 line2; ++close $fileid3; ++ ++set test "attach3, exit leaves process stopped" ++if {[string match "*(stopped)*" $line2]} { ++ pass $test ++} else { ++ fail $test ++} ++ ++# At this point, the process should still be stopped ++ + # Continue the test as we would hit another expected bug regarding + # Program received signal SIGSTOP, Stopped (signal). + # across NPTL threads. diff --git a/gdb/patches/gdb-6.8-bz254229-gcore-prpsinfo.patch b/gdb/patches/gdb-6.8-bz254229-gcore-prpsinfo.patch new file mode 100644 index 000000000..b5eb51400 --- /dev/null +++ b/gdb/patches/gdb-6.8-bz254229-gcore-prpsinfo.patch @@ -0,0 +1,289 @@ +Index: gdb-7.2.50.20110320/bfd/elf-bfd.h +=================================================================== +--- gdb-7.2.50.20110320.orig/bfd/elf-bfd.h 2011-03-20 15:17:42.000000000 +0100 ++++ gdb-7.2.50.20110320/bfd/elf-bfd.h 2011-03-20 15:24:02.000000000 +0100 +@@ -2193,8 +2193,10 @@ extern Elf_Internal_Phdr * _bfd_elf_find + /* Exported interface for writing elf corefile notes. */ + extern char *elfcore_write_note + (bfd *, char *, int *, const char *, int, const void *, int); ++struct elf_prpsinfo; ++typedef struct elf_prpsinfo prpsinfo_t; + extern char *elfcore_write_prpsinfo +- (bfd *, char *, int *, const char *, const char *); ++ (bfd *, char *, int *, const prpsinfo_t *); + extern char *elfcore_write_prstatus + (bfd *, char *, int *, long, int, const void *); + extern char * elfcore_write_pstatus +Index: gdb-7.2.50.20110320/bfd/elf.c +=================================================================== +--- gdb-7.2.50.20110320.orig/bfd/elf.c 2011-03-20 15:17:42.000000000 +0100 ++++ gdb-7.2.50.20110320/bfd/elf.c 2011-03-20 15:24:02.000000000 +0100 +@@ -8814,13 +8814,12 @@ elfcore_write_note (bfd *abfd, + return buf; + } + +-#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) ++#if defined (HAVE_PRPSINFO_T) + char * + elfcore_write_prpsinfo (bfd *abfd, + char *buf, + int *bufsiz, +- const char *fname, +- const char *psargs) ++ const prpsinfo_t *input) + { + const char *note_name = "CORE"; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); +@@ -8828,48 +8827,55 @@ elfcore_write_prpsinfo (bfd *abfd, + if (bed->elf_backend_write_core_note != NULL) + { + char *ret; ++ char fname[sizeof (input->pr_fname) + 1]; ++ char psargs[sizeof (input->pr_psargs) + 1]; ++ ++ strncpy (fname, input->pr_fname, sizeof (input->pr_fname)); ++ fname[sizeof (input->pr_fname)] = 0; ++ strncpy (psargs, input->pr_psargs, sizeof (input->pr_psargs)); ++ psargs[sizeof (input->pr_psargs)] = 0; ++ + ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz, + NT_PRPSINFO, fname, psargs); + if (ret != NULL) + return ret; + } + +-#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T) ++#if defined (HAVE_PRPSINFO32_T) + if (bed->s->elfclass == ELFCLASS32) + { +-#if defined (HAVE_PSINFO32_T) +- psinfo32_t data; +- int note_type = NT_PSINFO; +-#else + prpsinfo32_t data; + int note_type = NT_PRPSINFO; +-#endif + + memset (&data, 0, sizeof (data)); +- strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); +- strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); ++ data.pr_state = input->pr_state; ++ data.pr_sname = input->pr_sname; ++ data.pr_zomb = input->pr_zomb; ++ data.pr_nice = input->pr_nice; ++ data.pr_flag = input->pr_flag; ++ data.pr_uid = input->pr_uid; ++ data.pr_gid = input->pr_gid; ++ data.pr_pid = input->pr_pid; ++ data.pr_ppid = input->pr_ppid; ++ data.pr_pgrp = input->pr_pgrp; ++ data.pr_sid = input->pr_sid; ++ BFD_ASSERT (sizeof (data.pr_fname) == sizeof (input->pr_fname)); ++ memcpy (data.pr_fname, input->pr_fname, sizeof (data.pr_fname)); ++ BFD_ASSERT (sizeof (data.pr_psargs) == sizeof (input->pr_psargs)); ++ memcpy (data.pr_psargs, input->pr_psargs, sizeof (data.pr_psargs)); + return elfcore_write_note (abfd, buf, bufsiz, + note_name, note_type, &data, sizeof (data)); + } + else + #endif + { +-#if defined (HAVE_PSINFO_T) +- psinfo_t data; +- int note_type = NT_PSINFO; +-#else +- prpsinfo_t data; + int note_type = NT_PRPSINFO; +-#endif + +- memset (&data, 0, sizeof (data)); +- strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); +- strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); + return elfcore_write_note (abfd, buf, bufsiz, +- note_name, note_type, &data, sizeof (data)); ++ note_name, note_type, input, sizeof (*input)); + } + } +-#endif /* PSINFO_T or PRPSINFO_T */ ++#endif /* PRPSINFO_T */ + + #if defined (HAVE_PRSTATUS_T) + char * +Index: gdb-7.2.50.20110320/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.50.20110320.orig/gdb/linux-nat.c 2011-03-20 15:17:46.000000000 +0100 ++++ gdb-7.2.50.20110320/gdb/linux-nat.c 2011-03-20 15:25:36.000000000 +0100 +@@ -4603,6 +4603,131 @@ linux_spu_make_corefile_notes (bfd *obfd + return args.note_data; + } + ++/* Should be always true for Linux */ ++#define HAVE_PRPSINFO_T 1 ++ ++#if defined (HAVE_PRPSINFO_T) ++ ++/* Fills struct elf_prpsinfo{32,64} as much as possible, imitate Linux kernel ++ binfmt_elf.c. Unknown values are filled with zeroes. The structure is ++ malloced. */ ++ ++static const prpsinfo_t * ++fill_prpsinfo (void) ++{ ++ struct stat sb; ++ char filename[sizeof ("/proc//cmdline") + sizeof (int) * 3 + 2]; ++ char buf[1024]; ++ char proc_state[5]; ++ char proc_cmdline[sizeof (((struct elf_prpsinfo*)0)->pr_psargs) + 1]; ++ unsigned flags; ++ long proc_nice; ++ unsigned proc_ppid; ++ unsigned proc_pgid; ++ unsigned proc_sid; ++ pid_t pid; ++ int fd, n; ++ char *cp, *proc_comm, *state_s; ++ /* String comes from Linux kernel binfmt_elf.c FILL_PSINFO but it is already ++ obsolete there to TASK_* constants. */ ++ const char state_string[] = "RSDTZW"; ++ int state_num; ++ static prpsinfo_t retval; ++ ++ /* Get /proc/$PID/stat. */ ++ pid = ptid_get_pid (inferior_ptid); ++ sprintf (filename, "/proc/%u/stat", (unsigned)pid); ++ fd = open (filename, O_RDONLY); ++ if (fd < 0) ++ return NULL; ++ fstat (fd, &sb); /* No error checking (can it ever happen?). */ ++ n = read (fd, buf, sizeof (buf) - 1); ++ close (fd); ++ if (n < 0) ++ return NULL; ++ buf[n] = 0; ++ ++ cp = strrchr (buf, ')'); /* Split into "PID (COMM" and "". */ ++ if (!cp) ++ return NULL; ++ *cp = 0; ++ ++ /* Grab COMM. */ ++ proc_comm = strchr (buf, '('); ++ if (!proc_comm) ++ return NULL; ++ proc_comm++; ++ ++ /* Read /proc/$PID/cmdline. */ ++ proc_cmdline[0] = 0; ++ strcpy (strrchr (filename, '/'), "/cmdline"); ++ fd = open (filename, O_RDONLY); ++ if (fd >= 0) ++ { ++ int n; ++ ++ n = read (fd, proc_cmdline, sizeof (proc_cmdline) - 1); ++ if (n < 0) ++ n = 0; ++ proc_cmdline[n] = 0; ++ while (n--) /* Replace NULs with spaces. */ ++ if (proc_cmdline[n] == 0) ++ proc_cmdline[n] = ' '; ++ close (fd); ++ } ++ ++ /* Parse /proc/$PID/stat. */ ++ n = sscanf (cp + 2, /* skip ") " */ ++ "%4s %u " /* state, ppid */ ++ "%u %u %*s %*s " /* pgid, sid, tty, tpgid */ ++ "%u %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt */ ++ "%*s " /* cmaj_flt */ ++ "%*s %*s " /* utime, stime */ ++ "%*s %*s %*s " /* cutime, cstime, priority */ ++ "%ld " /* nice */ ++ /*"%*s %*s " timeout, it_real_value */ ++ /*"%lu " start_time */ ++ /*"%lu " vsize */ ++ /*"%lu " rss */ ++ /*"%lu %lu %lu " rss_rlim, start_code, end_code */ ++ /*"%lu %lu %lu " start_stack, kstk_esp, kstk_eip */ ++ /*"%u %u %u %u " signal, blocked, sigignore, sigcatch */ ++ /*"%lu %lu %lu" wchan, nswap, cnswap */ ++ , proc_state, &proc_ppid, ++ &proc_pgid, &proc_sid, ++ &flags, ++ &proc_nice); ++ if (n != 6) ++ return NULL; ++ ++ state_s = strchr (state_string, proc_state[0]); ++ if (state_s != NULL) ++ state_num = state_s - state_string; ++ else ++ { ++ /* 0 means Running, some more unusal state would be better. */ ++ state_num = 0; ++ } ++ ++ memset (&retval, 0, sizeof (retval)); ++ retval.pr_state = state_num; ++ retval.pr_sname = proc_state[0]; ++ retval.pr_zomb = (proc_state[0] == 'Z'); ++ retval.pr_nice = proc_nice; ++ retval.pr_flag = flags; ++ retval.pr_uid = sb.st_uid; ++ retval.pr_gid = sb.st_gid; ++ retval.pr_pid = pid; ++ retval.pr_ppid = proc_ppid; ++ retval.pr_pgrp = proc_pgid; ++ retval.pr_sid = proc_sid; ++ strncpy (retval.pr_fname, proc_comm, sizeof (retval.pr_fname)); ++ strncpy (retval.pr_psargs, proc_cmdline, sizeof (retval.pr_psargs)); ++ ++ return &retval; ++} ++#endif ++ + /* Fills the "to_make_corefile_note" target vector. Builds the note + section for a corefile, and returns it in a malloc buffer. */ + +@@ -4621,26 +4746,11 @@ linux_nat_make_corefile_notes (bfd *obfd + + if (get_exec_file (0)) + { +- strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname)); +- strncpy (psargs, get_exec_file (0), sizeof (psargs)); +- if (get_inferior_args ()) +- { +- char *string_end; +- char *psargs_end = psargs + sizeof (psargs); +- +- /* linux_elfcore_write_prpsinfo () handles zero unterminated +- strings fine. */ +- string_end = memchr (psargs, 0, sizeof (psargs)); +- if (string_end != NULL) +- { +- *string_end++ = ' '; +- strncpy (string_end, get_inferior_args (), +- psargs_end - string_end); +- } +- } ++ const prpsinfo_t *data = fill_prpsinfo (); ++ + note_data = (char *) elfcore_write_prpsinfo (obfd, + note_data, +- note_size, fname, psargs); ++ note_size, data); + } + + /* Dump information for threads. */ +Index: gdb-7.2.50.20110320/gdb/procfs.c +=================================================================== +--- gdb-7.2.50.20110320.orig/gdb/procfs.c 2011-03-09 13:48:55.000000000 +0100 ++++ gdb-7.2.50.20110320/gdb/procfs.c 2011-03-20 15:24:02.000000000 +0100 +@@ -5752,6 +5752,7 @@ procfs_make_note_section (bfd *obfd, int + note_data = (char *) elfcore_write_prpsinfo (obfd, + note_data, + note_size, ++ NULL, + fname, + psargs); + diff --git a/gdb/patches/gdb-6.8-bz436037-reg-no-longer-active.patch b/gdb/patches/gdb-6.8-bz436037-reg-no-longer-active.patch new file mode 100644 index 000000000..49877147c --- /dev/null +++ b/gdb/patches/gdb-6.8-bz436037-reg-no-longer-active.patch @@ -0,0 +1,25 @@ +Index: gdb-6.8.50.20090803/gdb/valops.c +=================================================================== +--- gdb-6.8.50.20090803.orig/gdb/valops.c 2009-08-04 06:30:45.000000000 +0200 ++++ gdb-6.8.50.20090803/gdb/valops.c 2009-08-04 06:33:05.000000000 +0200 +@@ -926,10 +926,18 @@ value_assign (struct value *toval, struc + struct gdbarch *gdbarch; + int value_reg; + +- /* Figure out which frame this is in currently. */ +- frame = frame_find_by_id (VALUE_FRAME_ID (toval)); + value_reg = VALUE_REGNUM (toval); + ++ /* Figure out which frame this is in currently. */ ++ frame = frame_find_by_id (VALUE_FRAME_ID (toval)); ++ /* "set $reg+=1" should work on programs with no debug info, ++ but frame_find_by_id returns NULL here (RH bug 436037). ++ Use current frame, it represents CPU state in this case. ++ If frame_find_by_id is changed to do it internally ++ (it is contemplated there), remove this. */ ++ if (!frame) ++ frame = get_current_frame (); ++ /* Probably never happens. */ + if (!frame) + error (_("Value being assigned to is no longer active.")); + diff --git a/gdb/patches/gdb-6.8-bz442765-threaded-exec-test.patch b/gdb/patches/gdb-6.8-bz442765-threaded-exec-test.patch new file mode 100644 index 000000000..100658805 --- /dev/null +++ b/gdb/patches/gdb-6.8-bz442765-threaded-exec-test.patch @@ -0,0 +1,173 @@ +Test various forms of threads tracking across exec(2). + +diff -up -u -X /root/jkratoch/.diffi.list -rup gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.c gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.c +--- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.c 2008-04-16 17:05:19.000000000 -0400 ++++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.c 2008-04-16 14:43:50.000000000 -0400 +@@ -18,21 +18,95 @@ + Boston, MA 02111-1307, USA. */ + + #include +-#include + #include + #include + #include ++#include + ++#ifdef THREADS ++ ++# include + + static void * + threader (void *arg) + { +- return NULL; ++ return NULL; + } + ++#endif ++ + int +-main (void) ++main (int argc, char **argv) + { ++ char *exec_nothreads, *exec_threads, *cmd; ++ int phase; ++ char phase_s[8]; ++ ++ setbuf (stdout, NULL); ++ ++ if (argc != 4) ++ { ++ fprintf (stderr, "%s \n", argv[0]); ++ return 1; ++ } ++ ++#ifdef THREADS ++ puts ("THREADS: Y"); ++#else ++ puts ("THREADS: N"); ++#endif ++ exec_nothreads = argv[1]; ++ printf ("exec_nothreads: %s\n", exec_nothreads); ++ exec_threads = argv[2]; ++ printf ("exec_threads: %s\n", exec_threads); ++ phase = atoi (argv[3]); ++ printf ("phase: %d\n", phase); ++ ++ /* Phases: threading ++ 0: N -> N ++ 1: N -> Y ++ 2: Y -> Y ++ 3: Y -> N ++ 4: N -> exit */ ++ ++ cmd = NULL; ++ ++#ifndef THREADS ++ switch (phase) ++ { ++ case 0: ++ cmd = exec_nothreads; ++ break; ++ case 1: ++ cmd = exec_threads; ++ break; ++ case 2: ++ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0], ++ phase); ++ return 1; ++ case 3: ++ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0], ++ phase); ++ return 1; ++ case 4: ++ return 0; ++ default: ++ assert (0); ++ } ++#else /* THREADS */ ++ switch (phase) ++ { ++ case 0: ++ fprintf (stderr, "%s: We should not have threads for phase %d!\n", ++ argv[0], phase); ++ return 1; ++ case 1: ++ fprintf (stderr, "%s: We should not have threads for phase %d!\n", ++ argv[0], phase); ++ return 1; ++ case 2: ++ cmd = exec_threads; ++ { + pthread_t t1; + int i; + +@@ -40,7 +114,34 @@ main (void) + assert (i == 0); + i = pthread_join (t1, NULL); + assert (i == 0); ++ } ++ break; ++ case 3: ++ cmd = exec_nothreads; ++ { ++ pthread_t t1; ++ int i; ++ ++ i = pthread_create (&t1, NULL, threader, (void *) NULL); ++ assert (i == 0); ++ i = pthread_join (t1, NULL); ++ assert (i == 0); ++ } ++ break; ++ case 4: ++ fprintf (stderr, "%s: We should not have threads for phase %d!\n", ++ argv[0], phase); ++ return 1; ++ default: ++ assert (0); ++ } ++#endif /* THREADS */ ++ ++ assert (cmd != NULL); ++ ++ phase++; ++ snprintf (phase_s, sizeof phase_s, "%d", phase); + +- execl ("/bin/true", "/bin/true", NULL); +- abort (); ++ execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL); ++ assert (0); + } +diff -up -u -X /root/jkratoch/.diffi.list -rup gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.exp gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.exp +--- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.exp 2008-04-16 17:05:19.000000000 -0400 ++++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.exp 2008-04-16 14:42:49.000000000 -0400 +@@ -20,9 +20,14 @@ + + set testfile threaded-exec + set srcfile ${testfile}.c +-set binfile ${objdir}/${subdir}/${testfile} ++set binfile_nothreads ${objdir}/${subdir}/${testfile}N ++set binfile_threads ${objdir}/${subdir}/${testfile}Y + +-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } { ++if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } { ++ return -1 ++} ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } { + return -1 + } + +@@ -30,9 +35,9 @@ gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + +-gdb_load ${binfile} ++gdb_load ${binfile_nothreads} + +-gdb_run_cmd ++gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0 + + gdb_test_multiple {} "Program exited" { + -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" { diff --git a/gdb/patches/gdb-6.8-bz457187-largefile-test.patch b/gdb/patches/gdb-6.8-bz457187-largefile-test.patch new file mode 100644 index 000000000..d2d6cf827 --- /dev/null +++ b/gdb/patches/gdb-6.8-bz457187-largefile-test.patch @@ -0,0 +1,105 @@ +--- /dev/null 2009-04-19 14:49:00.974648389 +0200 ++++ gdb-6.8/gdb/testsuite/gdb.arch/i386-biarch-core.exp 2009-04-19 16:30:12.000000000 +0200 +@@ -0,0 +1,61 @@ ++# This testcase is part of GDB, the GNU debugger. ++ ++# Copyright 2009 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. ++ ++# Test ability to load an elf64-i386 core file. The provided core file was ++# elf64-x8664 one but it got binary patched to i386: ++# Elf32_Ehdr.e_machine @0x12..0x13 ++# Elf64_Ehdr.e_machine @0x12..0x13 ++# #define EM_386 3 /* Intel 80386 */ ++# #define EM_X86_64 62 /* AMD x86-64 architecture */ ++# patch @0x12: 0x3E -> 0x03 ++ ++if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then { ++ verbose "Skipping i386-biarch-core test." ++ return ++} ++ ++set testfile "i386-biarch-core" ++set corebz2uufile ${srcdir}/${subdir}/${testfile}.core.bz2.uu ++set corefile ${objdir}/${subdir}/${testfile}.core ++# Entry point of the original executable. ++set address 0x400078 ++ ++if {[catch "system \"uudecode -o - ${corebz2uufile} | bzip2 -dc >${corefile}\""] != 0} { ++ untested "failed uudecode or bzip2" ++ return -1 ++} ++file stat ${corefile} corestat ++if {$corestat(size) != 102400} { ++ untested "uudecode or bzip2 produce invalid result" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++# Wrongly built GDB complains by: ++# "..." is not a core dump: File format not recognized ++# As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it. ++# This is just a problem of the test care, real-world elf64-i386 file will have ++# 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by ++# objcopy as it corrupts the core file beyond all recognition. ++# "\r\nCore was generated by `\[^\r\n\]*'\\.\r\nProgram terminated with signal 11, Segmentation fault\\.\r\n.*" ++gdb_test "core-file ${corefile}" ++ ++gdb_test "x/i $address" "\r\n\[ \t\]*$address:\[ \t\]*hlt\[ \t\]*" ".text is readable" +--- /dev/null 2009-04-19 14:49:00.974648389 +0200 ++++ gdb-6.8/gdb/testsuite/gdb.arch/i386-biarch-core.S 2009-04-19 14:52:28.000000000 +0200 +@@ -0,0 +1,22 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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. ++ */ ++ ++ .globl _start ++_start: ++ hlt +--- /dev/null 2009-04-19 14:49:00.974648389 +0200 ++++ gdb-6.8/gdb/testsuite/gdb.arch/i386-biarch-core.core.bz2.uu 2009-04-19 15:02:12.000000000 +0200 +@@ -0,0 +1,13 @@ ++begin 600 i386-biarch-core.core.bz2 ++M0EIH.3%!629361`P1\P`!)?_____\9'@"8Q)6P380'9@'&#`0D@``"``%(`` ++M@`#`"!<(L`%F"(:$GH13::F-)M&D&U,AD:`--#)M0&FT0XR9--,)D9`P(Q-& ++M",(-&F``02)%38HT]0T`&AH```'H@``T^>9T*(,("&)SE`>`9@+GP=[,N)KB ++M'I8BL(L]N5TCY\%V]/?DB.BN*UZ'U@]TN7-]UJ5\_%0QTT<*086#%MHT7XVJ ++M9D"+C!"2*L:8D1XPD!`--M@*XT1H5RFYN&)(!0P0#:`I:;2;$5M&\*9"0@%: ++MK@X[T()M)9N7`D$VA!^63)%,;@8LT`(7\K&[7G;U:"B6'!GG+46ALOZF.2F- ++M!@>C*%86X$-]C2`KE;HG)UL(913VR2G]0BD:J=Z_`G@S,`W%.8RMS-#5P:J0 ++MAJ2\8&X?@DE;UF68QHM<,D`('::J65/S:PAG*R-09["8DBI)'V]Y.[(/AM*L ++M"X_O^V;%FY.S6Q]FM=D37>5F,%4-F1ZF#,CFJVU;H*^IT<(%. */ ++ ++/* dw2-loclist-prelinked-func.S */ ++extern void func (void); ++ ++int ++main (void) ++{ ++ func (); ++ return 0; ++} +Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S 2009-09-09 20:10:35.000000000 +0200 +@@ -0,0 +1,328 @@ ++/* 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 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 . */ ++ ++/* ++#include ++ ++void ++func (void) ++{ ++ int i; ++ ++ abort (); ++} ++*/ ++ .file "dw2-loclist-prelinked.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl func ++ .type func, @function ++func: ++.LFB2: ++ .file 1 "dw2-loclist-prelinked.c" ++ .loc 1 5 0 ++ pushl %ebp ++.LCFI0: ++ movl %esp, %ebp ++.LCFI1: ++ subl $24, %esp ++.LCFI2: ++ .loc 1 8 0 ++ call abort ++.LFE2: ++ .size func, .-func ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -4 ++ .byte 0x8 ++ .byte 0xc ++ .uleb128 0x4 ++ .uleb128 0x4 ++ .byte 0x88 ++ .uleb128 0x1 ++ .align 4 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x8 ++ .byte 0x85 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x5 ++ .align 4 ++.LEFDE0: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .long .LFB2-.Ltext0 ++ .long .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x74 ++ .sleb128 4 ++ .long .LCFI0-.Ltext0 ++ .long .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x74 ++ .sleb128 8 ++ .long .LCFI1-.Ltext0 ++ .long .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x75 ++ .sleb128 8 ++ .long 0x0 ++ .long 0x0 ++ .section .debug_info ++ .long 0x94 ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x4 ++ .uleb128 0x1 ++ .long .LASF10 ++ .byte 0x1 ++ .long .LASF11 ++ .long .LASF12 ++ .long .Ltext0 ++ .long .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x4 ++ .byte 0x7 ++ .long .LASF0 ++ .uleb128 0x3 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++ .uleb128 0x2 ++ .byte 0x4 ++ .byte 0x5 ++ .long .LASF1 ++ .uleb128 0x2 ++ .byte 0x1 ++ .byte 0x8 ++ .long .LASF2 ++ .uleb128 0x2 ++ .byte 0x2 ++ .byte 0x7 ++ .long .LASF3 ++ .uleb128 0x2 ++ .byte 0x4 ++ .byte 0x7 ++ .long .LASF4 ++ .uleb128 0x2 ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF5 ++ .uleb128 0x2 ++ .byte 0x2 ++ .byte 0x5 ++ .long .LASF6 ++ .uleb128 0x2 ++ .byte 0x8 ++ .byte 0x5 ++ .long .LASF7 ++ .uleb128 0x2 ++ .byte 0x8 ++ .byte 0x7 ++ .long .LASF8 ++ .uleb128 0x4 ++ .byte 0x4 ++ .byte 0x7 ++ .uleb128 0x2 ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF9 ++ .uleb128 0x5 ++ .byte 0x1 ++ .long .LASF13 ++ .byte 0x1 ++ .byte 0x5 ++ .byte 0x1 ++ .long .LFB2 ++ .long .LFE2 ++ .long .LLST0 ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x6 ++ .long 0x2c ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -12 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x17 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0x98 ++ .long 0x75 ++ .string "func" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x1c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x4 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .long .Ltext0 ++ .long .Letext0-.Ltext0 ++ .long 0x0 ++ .long 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF7: ++ .string "long long int" ++.LASF0: ++ .string "unsigned int" ++.LASF11: ++ .string "dw2-loclist-prelinked.c" ++.LASF12: ++ .string "gdb-6.8/gdb/testsuite/gdb.dwarf2" ++.LASF4: ++ .string "long unsigned int" ++.LASF8: ++ .string "long long unsigned int" ++.LASF2: ++ .string "unsigned char" ++.LASF9: ++ .string "char" ++.LASF1: ++ .string "long int" ++.LASF3: ++ .string "short unsigned int" ++.LASF5: ++ .string "signed char" ++.LASF10: ++ .string "GNU C 4.3.2 20081007 (Red Hat 4.3.2-6)" ++.LASF13: ++ .string "func" ++.LASF6: ++ .string "short int" ++ .ident "GCC: (GNU) 4.3.2 20081007 (Red Hat 4.3.2-6)" ++ .section .note.GNU-stack,"",@progbits diff --git a/gdb/patches/gdb-6.8-quit-never-aborts.patch b/gdb/patches/gdb-6.8-quit-never-aborts.patch new file mode 100644 index 000000000..d71557fa8 --- /dev/null +++ b/gdb/patches/gdb-6.8-quit-never-aborts.patch @@ -0,0 +1,72 @@ +We may abort the process of detaching threads with multiple SIGINTs - which are +being sent during a testcase terminating its child GDB. + +Some of the threads may not be properly PTRACE_DETACHed which hurts if they +should have been detached with SIGSTOP (as they are accidentally left running +on the debugger termination). + +Index: gdb-7.2.50.20110117/gdb/defs.h +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/defs.h 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/defs.h 2011-01-17 15:53:05.000000000 +0100 +@@ -165,6 +165,7 @@ extern char *python_libdir; + extern char *debug_file_directory; + + extern int quit_flag; ++extern int quit_flag_cleanup; + extern int immediate_quit; + extern int sevenbit_strings; + +@@ -178,7 +179,7 @@ extern void quit (void); + needed. */ + + #define QUIT { \ +- if (quit_flag) quit (); \ ++ if (quit_flag && !quit_flag_cleanup) quit (); \ + if (deprecated_interactive_hook) deprecated_interactive_hook (); \ + } + +Index: gdb-7.2.50.20110117/gdb/event-top.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/event-top.c 2011-01-17 15:52:39.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/event-top.c 2011-01-17 15:52:49.000000000 +0100 +@@ -904,7 +904,7 @@ async_request_quit (gdb_client_data arg) + is no reason to call quit again here, unless immediate_quit is + set. */ + +- if (quit_flag || immediate_quit) ++ if ((quit_flag || immediate_quit) && !quit_flag_cleanup) + quit (); + } + +Index: gdb-7.2.50.20110117/gdb/top.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/top.c 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/top.c 2011-01-17 15:52:49.000000000 +0100 +@@ -1257,7 +1257,9 @@ quit_force (char *args, int from_tty) + qt.args = args; + qt.from_tty = from_tty; + +- /* We want to handle any quit errors and exit regardless. */ ++ /* We want to handle any quit errors and exit regardless but we should never ++ get user-interrupted to properly detach the inferior. */ ++ quit_flag_cleanup = 1; + catch_errors (quit_target, &qt, + "Quitting: ", RETURN_MASK_ALL); + +Index: gdb-7.2.50.20110117/gdb/utils.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/utils.c 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/utils.c 2011-01-17 15:52:49.000000000 +0100 +@@ -121,6 +121,11 @@ int job_control; + + int quit_flag; + ++/* Nonzero means we are already processing the quitting cleanups and we should ++ no longer get aborted. */ ++ ++int quit_flag_cleanup; ++ + /* Nonzero means quit immediately if Control-C is typed now, rather + than waiting until QUIT is executed. Be careful in setting this; + code which executes with immediate_quit set has to be very careful diff --git a/gdb/patches/gdb-6.8-sparc64-silence-memcpy-check.patch b/gdb/patches/gdb-6.8-sparc64-silence-memcpy-check.patch new file mode 100644 index 000000000..a9d30ce45 --- /dev/null +++ b/gdb/patches/gdb-6.8-sparc64-silence-memcpy-check.patch @@ -0,0 +1,11 @@ +diff -up gdb-6.8/gdb/sparc-tdep.c.BAD gdb-6.8/gdb/sparc-tdep.c +--- gdb-6.8/gdb/sparc-tdep.c.BAD 2008-05-15 16:12:58.000000000 -0500 ++++ gdb-6.8/gdb/sparc-tdep.c 2008-05-15 16:13:41.000000000 -0500 +@@ -1122,6 +1122,7 @@ sparc32_store_return_value (struct type + if (sparc_floating_p (type)) + { + /* Floating return values. */ ++ len = (len <= 8) ? len : 8; + memcpy (buf, valbuf, len); + regcache_cooked_write (regcache, SPARC_F0_REGNUM, buf); + if (len > 4) diff --git a/gdb/patches/gdb-6.8-tui-singlebinary.patch b/gdb/patches/gdb-6.8-tui-singlebinary.patch new file mode 100644 index 000000000..cb0be4586 --- /dev/null +++ b/gdb/patches/gdb-6.8-tui-singlebinary.patch @@ -0,0 +1,24 @@ +Provide `gdb --tui' functionality for the hardlink `gdbtui'. + +--- ./gdb/gdb.c 1 Jan 2008 22:53:09 -0000 1.6 ++++ ./gdb/gdb.c 20 Jun 2008 08:02:57 -0000 +@@ -30,5 +30,19 @@ main (int argc, char **argv) + args.argv = argv; + args.use_windows = 0; + args.interpreter_p = INTERP_CONSOLE; ++ ++ if (argv[0]) ++ { ++ char *s; ++ ++ s = strrchr (argv[0], '/'); ++ if (s) ++ s++; ++ else ++ s = argv[0]; ++ if (strcmp (s, "gdbtui") == 0) ++ args.interpreter_p = INTERP_TUI; ++ } ++ + return gdb_main (&args); + } diff --git a/gdb/patches/gdb-6.8-watchpoint-conditionals-test.patch b/gdb/patches/gdb-6.8-watchpoint-conditionals-test.patch new file mode 100644 index 000000000..b0140746a --- /dev/null +++ b/gdb/patches/gdb-6.8-watchpoint-conditionals-test.patch @@ -0,0 +1,78 @@ +For: +http://sourceware.org/ml/gdb-patches/2008-04/msg00379.html +http://sourceware.org/ml/gdb-cvs/2008-04/msg00104.html + +--- /dev/null 2008-11-04 06:31:10.599601840 +0100 ++++ gdb-6.8/gdb/testsuite/gdb.base/watchpoint-cond.exp 2008-11-04 06:43:29.000000000 +0100 +@@ -0,0 +1,37 @@ ++# 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 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 . ++ ++set testfile watchpoint-cond ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${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} ++ ++if { [runto_main] < 0 } { ++ untested watchpoint-cond ++ return -1 ++} ++ ++gdb_test "watch i if i < 20" "atchpoint \[0-9\]+: i" ++gdb_test "cont" "atchpoint \[0-9\]+: i.*Old value = 20.*New value = 19.*" +--- /dev/null 2008-11-04 06:31:10.599601840 +0100 ++++ gdb-6.8/gdb/testsuite/gdb.base/watchpoint-cond.c 2008-11-04 06:42:48.000000000 +0100 +@@ -0,0 +1,31 @@ ++/* 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 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 . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++int ++main (int argc, char **argv) ++{ ++ static int i = 0; /* `static' to start initialized. */ ++ int j = 2; ++ ++ for (j = 0; j < 30; j++) ++ i = 30 - j; ++ ++ return 0; ++} diff --git a/gdb/patches/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch b/gdb/patches/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch new file mode 100644 index 000000000..b01165829 --- /dev/null +++ b/gdb/patches/gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch @@ -0,0 +1,51 @@ +Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-22 19:37:15.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-22 19:44:42.000000000 +0200 +@@ -67,12 +67,14 @@ + #ifdef HAVE_ZLIB_H + #include + #endif ++#ifndef __sparc__ + #ifdef HAVE_MMAP + #include + #ifndef MAP_FAILED + #define MAP_FAILED ((void *) -1) + #endif + #endif ++#endif + + typedef struct symbol *symbolp; + DEF_VEC_P (symbolp); +@@ -1618,6 +1620,7 @@ dwarf2_read_section (struct objfile *obj + } + } + ++#ifndef __sparc__ + #ifdef HAVE_MMAP + if (pagesize == 0) + pagesize = getpagesize (); +@@ -1641,6 +1644,7 @@ dwarf2_read_section (struct objfile *obj + } + } + #endif ++#endif + + /* If we get here, we are a normal, not-compressed section. */ + info->buffer = buf +@@ -15983,6 +15987,7 @@ munmap_section_buffer (struct dwarf2_sec + { + if (info->map_addr != NULL) + { ++#ifndef __sparc__ + #ifdef HAVE_MMAP + int res; + +@@ -15992,6 +15997,7 @@ munmap_section_buffer (struct dwarf2_sec + /* Without HAVE_MMAP, we should never be here to begin with. */ + gdb_assert_not_reached ("no mmap support"); + #endif ++#endif + } + } + diff --git a/gdb/patches/gdb-archer-next-over-throw-cxx-exec.patch b/gdb/patches/gdb-archer-next-over-throw-cxx-exec.patch new file mode 100644 index 000000000..cbd9a36a3 --- /dev/null +++ b/gdb/patches/gdb-archer-next-over-throw-cxx-exec.patch @@ -0,0 +1,85 @@ +Archer-upstreamed: +http://sourceware.org/ml/archer/2010-q2/msg00031.html + +--- ./gdb/testsuite/gdb.cp/cxxexec.cc 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.cp/cxxexec.cc 2010-05-29 01:18:56.000000000 +0200 +@@ -0,0 +1,25 @@ ++/* This test script 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 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 . */ ++ ++#include ++ ++int ++main() ++{ ++ execlp ("true", "true", NULL); ++ return 1; ++} +--- ./gdb/testsuite/gdb.cp/cxxexec.exp 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.cp/cxxexec.exp 2010-05-29 01:29:25.000000000 +0200 +@@ -0,0 +1,51 @@ ++# 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 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 . ++ ++if { [skip_cplus_tests] } { continue } ++ ++set testfile cxxexec ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } { ++ return -1 ++} ++ ++runto_main ++ ++# We could stop after `continue' again at `main'. ++delete_breakpoints ++ ++set test "p _Unwind_DebugHook" ++gdb_test_multiple $test $test { ++ -re " = .* 0x\[0-9a-f\].*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "\r\nNo symbol .*\r\n$gdb_prompt $" { ++ xfail $test ++ untested ${testfile}.exp ++ return -1 ++ } ++} ++ ++set test continue ++gdb_test_multiple $test $test { ++ -re "Cannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++# `info inferiors' can show on older GDBs. ++gdb_test "info threads" "info threads" "program finished" diff --git a/gdb/patches/gdb-archer-pie-addons-keep-disabled.patch b/gdb/patches/gdb-archer-pie-addons-keep-disabled.patch new file mode 100644 index 000000000..d2b6c718d --- /dev/null +++ b/gdb/patches/gdb-archer-pie-addons-keep-disabled.patch @@ -0,0 +1,83 @@ +Index: gdb-7.3.50.20110722/gdb/breakpoint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/breakpoint.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/breakpoint.c 2011-07-22 19:32:04.000000000 +0200 +@@ -13195,6 +13195,50 @@ iterate_over_breakpoints (int (*callback + + return NULL; + } ++ ++void ++breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta) ++{ ++ struct bp_location *bl, **blp_tmp; ++ int changed = 0; ++ ++ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); ++ ++ ALL_BP_LOCATIONS (bl, blp_tmp) ++ { ++ struct obj_section *osect; ++ ++ /* BL->SECTION can be correctly NULL for breakpoints with multiple ++ locations expanded through symtab. */ ++ ++ ALL_OBJFILE_OSECTIONS (objfile, osect) ++ { ++ CORE_ADDR relocated_address; ++ CORE_ADDR delta_offset; ++ ++ delta_offset = ANOFFSET (delta, osect->the_bfd_section->index); ++ if (delta_offset == 0) ++ continue; ++ relocated_address = bl->address + delta_offset; ++ ++ if (obj_section_addr (osect) <= relocated_address ++ && relocated_address < obj_section_endaddr (osect)) ++ { ++ if (bl->inserted) ++ remove_breakpoint (bl, mark_uninserted); ++ ++ bl->address += delta_offset; ++ bl->requested_address += delta_offset; ++ ++ changed = 1; ++ } ++ } ++ } ++ ++ if (changed) ++ qsort (bp_location, bp_location_count, sizeof (*bp_location), ++ bp_location_compare); ++} + + void + _initialize_breakpoint (void) +Index: gdb-7.3.50.20110722/gdb/breakpoint.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/breakpoint.h 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/breakpoint.h 2011-07-22 19:31:22.000000000 +0200 +@@ -1328,4 +1328,7 @@ extern int user_breakpoint_p (struct bre + + extern void modify_semaphore (struct bp_location *location, int set); + ++extern void breakpoints_relocate (struct objfile *objfile, ++ struct section_offsets *delta); ++ + #endif /* !defined (BREAKPOINT_H) */ +Index: gdb-7.3.50.20110722/gdb/objfiles.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/objfiles.c 2011-07-22 19:08:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/objfiles.c 2011-07-22 19:31:22.000000000 +0200 +@@ -847,6 +847,11 @@ objfile_relocate1 (struct objfile *objfi + objfile->sf->sym_probe_fns->sym_relocate_probe (objfile, + new_offsets, delta); + ++ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if ++ their addresses match. */ ++ if (objfile->separate_debug_objfile_backlink == NULL) ++ breakpoints_relocate (objfile, delta); ++ + /* Data changed. */ + return 1; + } diff --git a/gdb/patches/gdb-archer.patch b/gdb/patches/gdb-archer.patch new file mode 100644 index 000000000..5d346d5cf --- /dev/null +++ b/gdb/patches/gdb-archer.patch @@ -0,0 +1,15142 @@ +http://sourceware.org/gdb/wiki/ProjectArcher +http://sourceware.org/gdb/wiki/ArcherBranchManagement + +GIT snapshot: +commit 069aac3325764793a2d57f8b2f0933a326c6b7a3 + +branch `archer' - the merge of branches: +archer-jankratochvil-vla +archer-jankratochvil-watchpoint3 +archer-tromey-python +archer-sergiodj-stap-patch-split + + +Index: gdb-7.3.50.20110722/gdb/Makefile.in +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/Makefile.in 2011-07-22 01:46:08.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/Makefile.in 2011-07-29 22:52:02.000000000 +0200 +@@ -720,8 +720,8 @@ SFILES = ada-exp.y ada-lang.c ada-typepr + sentinel-frame.c \ + serial.c ser-base.c ser-unix.c \ + solib.c solib-target.c source.c \ +- stabsread.c stack.c std-regs.c symfile.c symfile-mem.c symmisc.c \ +- symtab.c \ ++ stabsread.c stack.c stap-probe.c std-regs.c \ ++ symfile.c symfile-mem.c symmisc.c symtab.c \ + target.c target-descriptions.c target-memory.c \ + thread.c top.c tracepoint.c \ + trad-frame.c \ +@@ -818,7 +818,7 @@ osdata.h procfs.h python/py-event.h pyth + python/python-internal.h python/python.h ravenscar-thread.h record.h \ + solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \ + gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \ +-gnulib/stddef.in.h inline-frame.h \ ++gnulib/stddef.in.h inline-frame.h stap-probe.h \ + common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ + common/linux-osdata.h + +@@ -906,7 +906,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $ + xml-support.o xml-syscall.o xml-utils.o \ + target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \ + inferior.o osdata.o gdb_usleep.o record.o gcore.o \ +- jit.o progspace.o \ ++ jit.o progspace.o stap-probe.o \ + common-utils.o buffer.o ptid.o + + TSOBS = inflow.o +@@ -1328,6 +1328,12 @@ stamp-h: $(srcdir)/config.in config.stat + CONFIG_LINKS= \ + $(SHELL) config.status + ++.gdbinit: $(srcdir)/gdbinit.in config.status ++ CONFIG_FILES=".gdbinit:gdbinit.in" \ ++ CONFIG_COMMANDS= \ ++ CONFIG_HEADERS= \ ++ $(SHELL) config.status ++ + config.status: $(srcdir)/configure configure.tgt configure.host + $(SHELL) config.status --recheck + +Index: gdb-7.3.50.20110722/gdb/NEWS +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/NEWS 2011-07-21 19:23:55.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/NEWS 2011-07-29 22:52:02.000000000 +0200 +@@ -109,6 +109,10 @@ QTDisable + Initial support for the OpenCL C language (http://www.khronos.org/opencl) + has been integrated into GDB. + ++* GDB now has support for SystemTap probes. You can set a ++ breakpoint using the new "probe:" linespec and inspect the probe ++ arguments using the new $_probe_arg family of convenience variables. ++ + * Python scripting + + ** The function gdb.Write now accepts an optional keyword 'stream'. +Index: gdb-7.3.50.20110722/gdb/ada-lang.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/ada-lang.c 2011-07-05 06:34:55.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/ada-lang.c 2011-07-29 22:52:02.000000000 +0200 +@@ -11862,6 +11862,7 @@ ada_operator_length (const struct expres + + static int + ada_operator_check (struct expression *exp, int pos, ++ int (*type_func) (struct type *type, void *data), + int (*objfile_func) (struct objfile *objfile, void *data), + void *data) + { +@@ -11876,12 +11877,15 @@ ada_operator_check (struct expression *e + break; + + default: +- return operator_check_standard (exp, pos, objfile_func, data); ++ return operator_check_standard (exp, pos, type_func, objfile_func, ++ data); + } + + /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ + +- if (type && TYPE_OBJFILE (type) ++ if (type && type_func && (*type_func) (type, data)) ++ return 1; ++ if (type && TYPE_OBJFILE (type) && objfile_func + && (*objfile_func) (TYPE_OBJFILE (type), data)) + return 1; + +Index: gdb-7.3.50.20110722/gdb/amd64-linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/amd64-linux-nat.c 2011-01-07 20:36:15.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/amd64-linux-nat.c 2011-07-29 22:52:02.000000000 +0200 +@@ -265,18 +265,11 @@ amd64_linux_store_inferior_registers (st + + /* Support for debug registers. */ + +-static unsigned long amd64_linux_dr[DR_CONTROL + 1]; +- + static unsigned long +-amd64_linux_dr_get (ptid_t ptid, int regnum) ++amd64_linux_dr_get (int tid, int regnum) + { +- int tid; + unsigned long value; + +- tid = TIDGET (ptid); +- if (tid == 0) +- tid = PIDGET (ptid); +- + /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the + ptrace call fails breaks debugging remote targets. The correct + way to fix this is to add the hardware breakpoint and watchpoint +@@ -298,14 +291,8 @@ amd64_linux_dr_get (ptid_t ptid, int reg + /* Set debug register REGNUM to VALUE in only the one LWP of PTID. */ + + static void +-amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) ++amd64_linux_dr_set (int tid, int regnum, unsigned long value) + { +- int tid; +- +- tid = TIDGET (ptid); +- if (tid == 0) +- tid = PIDGET (ptid); +- + errno = 0; + ptrace (PTRACE_POKEUSER, tid, + offsetof (struct user, u_debugreg[regnum]), value); +@@ -313,35 +300,96 @@ amd64_linux_dr_set (ptid_t ptid, int reg + perror_with_name (_("Couldn't write debug register")); + } + +-/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */ ++/* Helper for amd64_linux_dr_set_control. */ ++ ++static void ++amd64_linux_dr_set_control_callback (int tid, void *control_voidp) ++{ ++ unsigned long control = *(unsigned long *) control_voidp; ++ ++ amd64_linux_dr_set (tid, DR_CONTROL, control); ++} ++ ++static void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr); ++ ++/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */ + + static void + amd64_linux_dr_set_control (unsigned long control) + { +- struct lwp_info *lp; +- ptid_t ptid; ++ int inferior_pid = ptid_get_pid (inferior_ptid); ++ struct inferior *inf = current_inferior (); ++ ++ /* Are we detaching breakpoints from a fork-ed child? ++ See linux_nat_iterate_watchpoint_lwps for the fork-ed child description. ++ The i386 counterpart is i386_linux_dr_set_control. */ ++ if (inf->pid != inferior_pid) ++ { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); ++ int i; ++ ++ /* There were two changes in Linux kernel 2.6.33 by the commit: ++ 72f674d203cd230426437cdcf7dd6f681dad8b0d ++ ++ (1) After fork/vfork/clone the new task no longer inherits the debug ++ registers. It has them zeroed instead. Either case is OK for GDB as ++ GDB already registers a fix up by linux_nat_set_new_thread. ++ ++ (2) If you enable a breakpoint by the CONTROL bits you have already ++ written its ADDRESS. Otherwise Linux kernel will report EINVAL. ++ For this case the workaround here ensures that during resetting ++ (detaching) watchpoints for a fork-ed child we can set CONTROL ++ arbitrarily as the addresses get pre-set here just to be sure. ++ ++ The second issue is hopefully going to be fixed in Linux kernel: ++ https://bugzilla.redhat.com/show_bug.cgi?id=660204 */ ++ ++ if (!dr_mirror->addr_preset) ++ { ++ dr_mirror->addr_preset = 1; ++ ++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++) ++ amd64_linux_dr_set_addr (i, dr_mirror->addr[i]); ++ } ++ } ++ ++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_control_callback, ++ &control); ++} ++ ++/* Helper for amd64_linux_dr_set_addr. */ ++ ++struct amd64_linux_dr_set_addr_data ++ { ++ int regnum; ++ CORE_ADDR addr; ++ }; ++ ++static void ++amd64_linux_dr_set_addr_callback (int tid, void *datap_voidp) ++{ ++ const struct amd64_linux_dr_set_addr_data *datap = datap_voidp; + +- amd64_linux_dr[DR_CONTROL] = control; +- ALL_LWPS (lp, ptid) +- amd64_linux_dr_set (ptid, DR_CONTROL, control); ++ amd64_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr); + } + +-/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */ ++/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR. ++ */ + + static void + amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr) + { +- struct lwp_info *lp; +- ptid_t ptid; ++ struct amd64_linux_dr_set_addr_data data; + + gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); + +- amd64_linux_dr[DR_FIRSTADDR + regnum] = addr; +- ALL_LWPS (lp, ptid) +- amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr); ++ data.regnum = regnum; ++ data.addr = addr; ++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_addr_callback, &data); + } + +-/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */ ++/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR. ++ */ + + static void + amd64_linux_dr_reset_addr (int regnum) +@@ -354,37 +402,54 @@ amd64_linux_dr_reset_addr (int regnum) + static unsigned long + amd64_linux_dr_get_status (void) + { +- return amd64_linux_dr_get (inferior_ptid, DR_STATUS); ++ int tid; ++ ++ tid = TIDGET (inferior_ptid); ++ if (tid == 0) ++ tid = PIDGET (inferior_ptid); ++ ++ return amd64_linux_dr_get (tid, DR_STATUS); + } + +-/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */ ++/* Helper for amd64_linux_dr_unset_status. */ + + static void +-amd64_linux_dr_unset_status (unsigned long mask) ++amd64_linux_dr_unset_status_callback (int tid, void *mask_voidp) + { +- struct lwp_info *lp; +- ptid_t ptid; +- +- ALL_LWPS (lp, ptid) +- { +- unsigned long value; ++ unsigned long mask = *(unsigned long *) mask_voidp; ++ unsigned long value; + +- value = amd64_linux_dr_get (ptid, DR_STATUS); +- value &= ~mask; +- amd64_linux_dr_set (ptid, DR_STATUS, value); +- } ++ value = amd64_linux_dr_get (tid, DR_STATUS); ++ value &= ~mask; ++ amd64_linux_dr_set (tid, DR_STATUS, value); + } + ++/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */ ++ ++static void ++amd64_linux_dr_unset_status (unsigned long mask) ++{ ++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_unset_status_callback, ++ &mask); ++} + + static void + amd64_linux_new_thread (ptid_t ptid) + { +- int i; ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); ++ int i, tid; ++ ++ /* Verify DR_MIRROR is valid. */ ++ gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid)); ++ ++ tid = TIDGET (ptid); ++ if (tid == 0) ++ tid = PIDGET (ptid); + +- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) +- amd64_linux_dr_set (ptid, i, amd64_linux_dr[i]); ++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++) ++ amd64_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]); + +- amd64_linux_dr_set (ptid, DR_CONTROL, amd64_linux_dr[DR_CONTROL]); ++ amd64_linux_dr_set (tid, DR_CONTROL, dr_mirror->control); + } + + +Index: gdb-7.3.50.20110722/gdb/ax-gdb.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/ax-gdb.c 2011-06-17 22:46:47.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/ax-gdb.c 2011-07-29 22:52:02.000000000 +0200 +@@ -2001,7 +2001,8 @@ gen_expr (struct expression *exp, union + + case OP_INTERNALVAR: + { +- const char *name = internalvar_name ((*pc)[1].internalvar); ++ struct internalvar *var = (*pc)[1].internalvar; ++ const char *name = internalvar_name (var); + struct trace_state_variable *tsv; + + (*pc) += 3; +@@ -2015,7 +2016,7 @@ gen_expr (struct expression *exp, union + value->kind = axs_rvalue; + value->type = builtin_type (exp->gdbarch)->builtin_long_long; + } +- else ++ else if (! compile_internalvar_to_ax (var, ax, value)) + error (_("$%s is not a trace state variable; GDB agent " + "expressions cannot use convenience variables."), name); + } +Index: gdb-7.3.50.20110722/gdb/block.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/block.c 2011-01-01 16:32:57.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/block.c 2011-07-29 22:52:02.000000000 +0200 +@@ -322,3 +322,21 @@ allocate_block (struct obstack *obstack) + + return bl; + } ++ ++/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for ++ whatever reason. */ ++ ++struct objfile * ++block_objfile (const struct block *block) ++{ ++ struct symbol *func; ++ ++ if (block == NULL) ++ return NULL; ++ ++ func = block_linkage_function (block); ++ if (func == NULL) ++ return NULL; ++ ++ return SYMBOL_SYMTAB (func)->objfile; ++} +Index: gdb-7.3.50.20110722/gdb/block.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/block.h 2011-04-04 16:10:12.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/block.h 2011-07-29 22:52:02.000000000 +0200 +@@ -163,4 +163,6 @@ extern const struct block *block_global_ + + extern struct block *allocate_block (struct obstack *obstack); + ++extern struct objfile *block_objfile (const struct block *block); ++ + #endif /* BLOCK_H */ +Index: gdb-7.3.50.20110722/gdb/breakpoint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/breakpoint.c 2011-07-05 06:34:55.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/breakpoint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -63,6 +63,8 @@ + #include "jit.h" + #include "xml-syscall.h" + #include "parser-defs.h" ++#include "gdb_regex.h" ++#include "stap-probe.h" + #include "cli/cli-utils.h" + #include "continuations.h" + +@@ -1248,6 +1250,9 @@ update_watchpoint (struct breakpoint *b, + if (!watchpoint_in_thread_scope (b)) + return; + ++ if (b->pspace != current_program_space) ++ return; ++ + if (b->disposition == disp_del_at_next_stop) + return; + +@@ -1532,6 +1537,40 @@ should_be_inserted (struct bp_location * + return 1; + } + ++/* See the comment in breakpoint.h. */ ++ ++void ++modify_semaphore (struct bp_location *loc, int set) ++{ ++ struct gdbarch *arch = loc->gdbarch; ++ gdb_byte bytes[sizeof (LONGEST)]; ++ /* The ABI specifies "unsigned short". */ ++ struct type *type = builtin_type (arch)->builtin_unsigned_short; ++ CORE_ADDR address = loc->semaphore; ++ ULONGEST value; ++ ++ if (address == 0) ++ return; ++ ++ /* Swallow errors. */ ++ if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0) ++ return; ++ ++ value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), ++ gdbarch_byte_order (arch)); ++ /* Note that we explicitly don't worry about overflow or ++ underflow. */ ++ if (set) ++ ++value; ++ else ++ --value; ++ ++ store_unsigned_integer (bytes, TYPE_LENGTH (type), ++ gdbarch_byte_order (arch), value); ++ ++ target_write_memory (address, bytes, TYPE_LENGTH (type)); ++} ++ + /* Insert a low-level "breakpoint" of some type. BL is the breakpoint + location. Any error messages are printed to TMP_ERROR_STREAM; and + DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems. +@@ -1628,6 +1667,8 @@ insert_bp_location (struct bp_location * + else + val = target_insert_breakpoint (bl->gdbarch, + &bl->target_info); ++ ++ modify_semaphore (bl, 1); + } + else + { +@@ -1883,6 +1924,7 @@ insert_breakpoint_locations (void) + int val = 0; + int disabled_breaks = 0; + int hw_breakpoint_error = 0; ++ struct program_space *saved_current_program_space = current_program_space; + + struct ui_file *tmp_error_stream = mem_fileopen (); + struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream); +@@ -1910,9 +1952,13 @@ insert_breakpoint_locations (void) + /* For targets that support global breakpoints, there's no need + to select an inferior to insert breakpoint to. In fact, even + if we aren't attached to any process yet, we should still +- insert breakpoints. */ ++ insert breakpoints. ++ ++ Also inserting breakpoints into inappropriate inferior must be ++ prevented. */ + if (!gdbarch_has_global_breakpoints (target_gdbarch) +- && ptid_equal (inferior_ptid, null_ptid)) ++ && (ptid_equal (inferior_ptid, null_ptid) ++ || bl->pspace != saved_current_program_space)) + continue; + + val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks, +@@ -1936,13 +1982,19 @@ insert_breakpoint_locations (void) + + if (bpt->disposition == disp_del_at_next_stop) + continue; +- ++ + for (loc = bpt->loc; loc; loc = loc->next) +- if (!loc->inserted && should_be_inserted (loc)) +- { +- some_failed = 1; +- break; +- } ++ { ++ /* Verify the first loop above really tried to insert this LOC. */ ++ if (!loc->inserted && should_be_inserted (loc) ++ && (gdbarch_has_global_breakpoints (target_gdbarch) ++ || (!ptid_equal (inferior_ptid, null_ptid) ++ && loc->pspace == saved_current_program_space))) ++ { ++ some_failed = 1; ++ break; ++ } ++ } + if (some_failed) + { + for (loc = bpt->loc; loc; loc = loc->next) +@@ -2110,11 +2162,23 @@ struct breakpoint_objfile_data + /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any). */ + struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES]; + ++ /* True if we have looked for longjmp probes. */ ++ int longjmp_searched; ++ ++ /* SystemTap probe points for longjmp (if any). */ ++ VEC (stap_probe_p) *longjmp_probes; ++ + /* Minimal symbol for "std::terminate()" (if any). */ + struct minimal_symbol *terminate_msym; + + /* Minimal symbol for "_Unwind_DebugHook" (if any). */ + struct minimal_symbol *exception_msym; ++ ++ /* True if we have looked for exception probes. */ ++ int exception_searched; ++ ++ /* SystemTap probe points for unwinding (if any). */ ++ VEC (stap_probe_p) *exception_probes; + }; + + static const struct objfile_data *breakpoint_objfile_key; +@@ -2151,6 +2215,15 @@ get_breakpoint_objfile_data (struct objf + } + + static void ++free_breakpoint_probes (struct objfile *obj, void *data) ++{ ++ struct breakpoint_objfile_data *bp_objfile_data = data; ++ ++ VEC_free (stap_probe_p, bp_objfile_data->longjmp_probes); ++ VEC_free (stap_probe_p, bp_objfile_data->exception_probes); ++} ++ ++static void + create_overlay_event_breakpoint (void) + { + struct objfile *objfile; +@@ -2226,6 +2299,36 @@ create_longjmp_master_breakpoint (void) + + bp_objfile_data = get_breakpoint_objfile_data (objfile); + ++ if (!bp_objfile_data->longjmp_searched) ++ { ++ bp_objfile_data->longjmp_probes ++ = find_probes_in_objfile (objfile, "libc", "longjmp"); ++ bp_objfile_data->longjmp_searched = 1; ++ } ++ ++ if (bp_objfile_data->longjmp_probes != NULL) ++ { ++ int i; ++ const struct stap_probe *probe; ++ struct gdbarch *gdbarch = get_objfile_arch (objfile); ++ ++ for (i = 0; ++ VEC_iterate (stap_probe_p, ++ bp_objfile_data->longjmp_probes, ++ i, probe); ++ ++i) ++ { ++ struct breakpoint *b; ++ ++ b = create_internal_breakpoint (gdbarch, probe->address, ++ bp_longjmp_master); ++ b->addr_string = xstrdup ("probe:libc:longjmp"); ++ b->enable_state = bp_disabled; ++ } ++ ++ continue; ++ } ++ + for (i = 0; i < NUM_LONGJMP_NAMES; i++) + { + struct breakpoint *b; +@@ -2334,6 +2437,39 @@ create_exception_master_breakpoint (void + + bp_objfile_data = get_breakpoint_objfile_data (objfile); + ++ /* We prefer the SystemTap probe point if it exists. */ ++ if (!bp_objfile_data->exception_searched) ++ { ++ bp_objfile_data->exception_probes ++ = find_probes_in_objfile (objfile, "libgcc", "unwind"); ++ bp_objfile_data->exception_searched = 1; ++ } ++ ++ if (bp_objfile_data->exception_probes != NULL) ++ { ++ struct gdbarch *gdbarch = get_objfile_arch (objfile); ++ int i; ++ const struct stap_probe *probe; ++ ++ for (i = 0; ++ VEC_iterate (stap_probe_p, ++ bp_objfile_data->exception_probes, ++ i, probe); ++ ++i) ++ { ++ struct breakpoint *b; ++ ++ b = create_internal_breakpoint (gdbarch, probe->address, ++ bp_exception_master); ++ b->addr_string = xstrdup ("probe:libgcc:unwind"); ++ b->enable_state = bp_disabled; ++ } ++ ++ continue; ++ } ++ ++ /* Otherwise, try the hook function. */ ++ + if (msym_not_found_p (bp_objfile_data->exception_msym)) + continue; + +@@ -2552,6 +2688,8 @@ remove_breakpoint_1 (struct bp_location + val = target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info); + else + val = target_remove_breakpoint (bl->gdbarch, &bl->target_info); ++ ++ modify_semaphore (bl, 0); + } + else + { +@@ -5957,6 +6095,7 @@ init_raw_breakpoint (struct breakpoint * + b->loc->requested_address = sal.pc; + b->loc->address = adjusted_address; + b->loc->pspace = sal.pspace; ++ b->loc->semaphore = sal.semaphore; + + /* Store the program space that was used to set the breakpoint, for + breakpoint resetting. */ +@@ -7226,6 +7365,7 @@ clone_momentary_breakpoint (struct break + copy->loc->address = orig->loc->address; + copy->loc->section = orig->loc->section; + copy->loc->pspace = orig->loc->pspace; ++ copy->loc->semaphore = orig->loc->semaphore; + + if (orig->source_file == NULL) + copy->source_file = NULL; +@@ -7444,6 +7584,7 @@ add_location_to_breakpoint (struct break + loc->address = adjust_breakpoint_address (loc->gdbarch, + loc->requested_address, b->type); + loc->pspace = sal->pspace; ++ loc->semaphore = sal->semaphore; + gdb_assert (loc->pspace != NULL); + loc->section = sal->section; + +@@ -7792,6 +7933,16 @@ create_breakpoints_sal (struct gdbarch * + { + int i; + ++ if (canonical->pre_expanded) ++ { ++ create_breakpoint_sal (gdbarch, sals, canonical->canonical[0], ++ cond_string, type, disposition, ++ thread, task, ignore_count, ops, ++ from_tty, enabled, internal, ++ canonical->special_display); ++ return; ++ } ++ + for (i = 0; i < sals.nelts; ++i) + { + struct symtabs_and_lines expanded = +@@ -8300,7 +8451,7 @@ create_breakpoint (struct gdbarch *gdbar + observer_notify_breakpoint_created (b); + } + +- if (sals.nelts > 1) ++ if (sals.nelts > 1 && !canonical.pre_expanded) + { + warning (_("Multiple breakpoints were set.\nUse the " + "\"delete\" command to delete unwanted breakpoints.")); +@@ -9394,6 +9545,7 @@ watch_command_1 (char *arg, int accessfl + /* Now set up the breakpoint. */ + b = set_raw_breakpoint_without_location (NULL, bp_type); + b->thread = thread; ++ b->pspace = current_program_space; + b->disposition = disp_donttouch; + b->exp = exp; + b->exp_valid_block = exp_valid_block; +@@ -10512,6 +10664,9 @@ update_global_location_list (int should_ + int keep_in_target = 0; + int removed = 0; + ++ if (old_loc->pspace != current_program_space) ++ continue; ++ + /* Skip LOCP entries which will definitely never be needed. + Stop either at or being the one matching OLD_LOC. */ + while (locp < bp_location + bp_location_count +@@ -11333,12 +11488,14 @@ update_breakpoint_locations (struct brea + On return, FOUND will be 1 if any SaL was found, zero otherwise. */ + + static struct symtabs_and_lines +-addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found) ++addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found, ++ int *pre_expanded) + { + char *s; + int marker_spec; + struct symtabs_and_lines sals = {0}; + struct gdb_exception e; ++ int my_pre_expanded = 0; + + s = addr_string; + marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s); +@@ -11357,7 +11514,27 @@ addr_string_to_sals (struct breakpoint * + error (_("marker %s not found"), b->static_trace_marker_id); + } + else +- sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL); ++ { ++ struct linespec_result canonical; ++ ++ init_linespec_result (&canonical); ++ sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, ++ &canonical); ++ ++ /* We don't need the contents. */ ++ if (canonical.canonical) ++ { ++ int i; ++ ++ for (i = 0; i < sals.nelts; ++i) ++ xfree (canonical.canonical[i]); ++ xfree (canonical.canonical); ++ } ++ ++ my_pre_expanded = canonical.pre_expanded; ++ if (pre_expanded) ++ *pre_expanded = my_pre_expanded; ++ } + } + if (e.reason < 0) + { +@@ -11390,7 +11567,7 @@ addr_string_to_sals (struct breakpoint * + + if (e.reason == 0 || e.error != NOT_FOUND_ERROR) + { +- gdb_assert (sals.nelts == 1); ++ gdb_assert (my_pre_expanded || sals.nelts == 1); + + resolve_sal_pc (&sals.sals[0]); + if (b->condition_not_parsed && s && s[0]) +@@ -11426,17 +11603,22 @@ breakpoint_re_set_default (struct breakp + struct symtabs_and_lines sals, sals_end; + struct symtabs_and_lines expanded = {0}; + struct symtabs_and_lines expanded_end = {0}; ++ int pre_expanded = 0; + +- sals = addr_string_to_sals (b, b->addr_string, &found); ++ sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded); + if (found) + { + make_cleanup (xfree, sals.sals); +- expanded = expand_line_sal_maybe (sals.sals[0]); ++ if (pre_expanded) ++ expanded = sals; ++ else ++ expanded = expand_line_sal_maybe (sals.sals[0]); + } + + if (b->addr_string_range_end) + { +- sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found); ++ sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found, ++ NULL); + if (found) + { + make_cleanup (xfree, sals_end.sals); +@@ -12913,6 +13095,24 @@ all_tracepoints (void) + return tp_vec; + } + ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ ++ ++static void ++breakpoint_types_mark_used (void) ++{ ++ struct breakpoint *b; ++ ++ ALL_BREAKPOINTS (b) ++ { ++ if (b->exp) ++ exp_types_mark_used (b->exp); ++ if (b->val) ++ type_mark_used (value_type (b->val)); ++ } ++} ++#endif ++ + + /* This help string is used for the break, hbreak, tbreak and thbreak + commands. It is defined as a macro to prevent duplication. +@@ -13005,7 +13205,8 @@ _initialize_breakpoint (void) + observer_attach_inferior_exit (clear_syscall_counts); + observer_attach_memory_changed (invalidate_bp_value_on_memory_change); + +- breakpoint_objfile_key = register_objfile_data (); ++ breakpoint_objfile_key ++ = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes); + + breakpoint_chain = 0; + /* Don't bother to call set_breakpoint_count. $bpnum isn't useful +@@ -13532,4 +13733,7 @@ range (including START-LOCATION and END- + automatic_hardware_breakpoints = 1; + + observer_attach_about_to_proceed (breakpoint_about_to_proceed); ++#if 0 ++ observer_attach_mark_used (breakpoint_types_mark_used); ++#endif + } +Index: gdb-7.3.50.20110722/gdb/breakpoint.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/breakpoint.h 2011-06-22 19:53:44.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/breakpoint.h 2011-07-29 22:52:02.000000000 +0200 +@@ -383,6 +383,11 @@ struct bp_location + processor's architectual constraints. */ + CORE_ADDR requested_address; + ++ /* If the location comes from a SystemTap probe point, and the probe ++ has an associated semaphore variable, then this is the address of ++ the semaphore. Otherwise, this is zero. */ ++ CORE_ADDR semaphore; ++ + char *function_name; + + /* Details of the placed breakpoint, when inserted. */ +@@ -1316,4 +1321,11 @@ extern struct breakpoint *iterate_over_b + + extern int user_breakpoint_p (struct breakpoint *); + ++/* Set or clear a SystemTap semaphore. LOC is the location which may ++ hold a semaphore. SET is non-zero if the semaphore should be set, ++ or zero if the semaphore should be cleared. Semaphores act as ++ reference counters, so calls to this function must be paired. */ ++ ++extern void modify_semaphore (struct bp_location *location, int set); ++ + #endif /* !defined (BREAKPOINT_H) */ +Index: gdb-7.3.50.20110722/gdb/c-typeprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/c-typeprint.c 2011-05-18 18:30:34.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/c-typeprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -625,9 +625,14 @@ c_type_print_varspec_suffix (struct type + fprintf_filtered (stream, ")"); + + fprintf_filtered (stream, "["); +- if (get_array_bounds (type, &low_bound, &high_bound)) +- fprintf_filtered (stream, "%d", +- (int) (high_bound - low_bound + 1)); ++ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind ++ != RANGE_BOUND_KIND_CONSTANT) ++ { ++ /* No _() - printed sources should not be locale dependent. */ ++ fprintf_filtered (stream, "variable"); ++ } ++ else if (get_array_bounds (type, &low_bound, &high_bound)) ++ fprintf_filtered (stream, "%d", (int) (high_bound - low_bound + 1)); + fprintf_filtered (stream, "]"); + + c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, +Index: gdb-7.3.50.20110722/gdb/cli/cli-utils.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/cli/cli-utils.c 2011-03-16 22:12:12.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/cli/cli-utils.c 2011-07-29 22:52:02.000000000 +0200 +@@ -245,3 +245,32 @@ remove_trailing_whitespace (const char * + + return s; + } ++ ++/* See documentation in cli-utils.h. */ ++ ++char * ++extract_arg (char **arg) ++{ ++ char *result, *copy; ++ ++ if (!*arg) ++ return NULL; ++ ++ /* Find the start of the argument. */ ++ *arg = skip_spaces (*arg); ++ if (! **arg) ++ return NULL; ++ result = *arg; ++ ++ /* Find the end of the argument. */ ++ *arg = skip_to_space (*arg + 1); ++ ++ if (result == *arg) ++ return NULL; ++ ++ copy = xmalloc (*arg - result + 1); ++ memcpy (copy, result, *arg - result); ++ copy[*arg - result] = '\0'; ++ ++ return copy; ++} +Index: gdb-7.3.50.20110722/gdb/cli/cli-utils.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/cli/cli-utils.h 2011-03-16 22:12:12.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/cli/cli-utils.h 2011-07-29 22:52:02.000000000 +0200 +@@ -103,4 +103,11 @@ extern char *skip_to_space (char *inp); + START. */ + + extern char *remove_trailing_whitespace (const char *start, char *s); ++ ++/* A helper function to extract an argument from *ARG. An argument is ++ delimited by whitespace. The return value is either NULL if no ++ argument was found, or an xmalloc'd string. */ ++ ++extern char *extract_arg (char **arg); ++ + #endif /* CLI_UTILS_H */ +Index: gdb-7.3.50.20110722/gdb/coffread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/coffread.c 2011-06-14 20:53:13.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/coffread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -2197,6 +2197,7 @@ static const struct sym_fns coff_sym_fns + + default_symfile_relocate, /* sym_relocate: Relocate a debug + section. */ ++ NULL, /* sym_probe_fns */ + &psym_functions + }; + +Index: gdb-7.3.50.20110722/gdb/data-directory/Makefile.in +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/data-directory/Makefile.in 2011-02-04 19:34:41.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/data-directory/Makefile.in 2011-07-29 22:52:02.000000000 +0200 +@@ -52,11 +52,23 @@ SYSCALLS_FILES = \ + PYTHON_DIR = python + PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) + PYTHON_FILES = \ ++ gdb/FrameIterator.py \ ++ gdb/FrameWrapper.py \ + gdb/__init__.py \ +- gdb/types.py \ +- gdb/printing.py \ ++ gdb/backtrace.py \ + gdb/command/__init__.py \ +- gdb/command/pretty_printers.py ++ gdb/command/alias.py \ ++ gdb/command/backtrace.py \ ++ gdb/command/ignore_errors.py \ ++ gdb/command/pahole.py \ ++ gdb/command/pretty_printers.py \ ++ gdb/command/require.py \ ++ gdb/command/upto.py \ ++ gdb/function/__init__.py \ ++ gdb/function/caller_is.py \ ++ gdb/function/in_scope.py \ ++ gdb/printing.py \ ++ gdb/types.py + + FLAGS_TO_PASS = \ + "prefix=$(prefix)" \ +Index: gdb-7.3.50.20110722/gdb/dbxread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dbxread.c 2011-06-27 21:21:50.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dbxread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -3590,6 +3590,7 @@ static const struct sym_fns aout_sym_fns + default_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ NULL, /* sym_probe_fns */ + &psym_functions + }; + +Index: gdb-7.3.50.20110722/gdb/defs.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/defs.h 2011-07-22 01:46:08.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/defs.h 2011-07-29 22:52:02.000000000 +0200 +@@ -406,6 +406,8 @@ extern struct cleanup *make_cleanup_rest + extern struct cleanup * + set_batch_flag_and_make_cleanup_restore_page_info (void); + ++extern struct cleanup *make_cleanup_restore_selected_frame (void); ++ + extern char *gdb_realpath (const char *); + extern char *xfullpath (const char *); + +Index: gdb-7.3.50.20110722/gdb/doc/gdb.texinfo +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/doc/gdb.texinfo 2011-07-21 17:13:29.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/doc/gdb.texinfo 2011-07-29 22:52:02.000000000 +0200 +@@ -1175,6 +1175,16 @@ for remote debugging. + Run using @var{device} for your program's standard input and output. + @c FIXME: kingdon thinks there is more to -tty. Investigate. + ++@item -P ++@cindex @code{-P} ++@itemx --python ++@cindex @code{--python} ++Change interpretation of command line so that the argument immediately ++following this switch is taken to be the name of a Python script file. ++This option stops option processing; subsequent options are passed to ++Python as @code{sys.argv}. This option is only available if Python ++scripting support was enabled when @value{GDBN} was configured. ++ + @c resolve the situation of these eventually + @item -tui + @cindex @code{--tui} +@@ -3295,6 +3305,7 @@ all breakpoints in that range are operat + * Conditions:: Break conditions + * Break Commands:: Breakpoint command lists + * Save Breakpoints:: How to save breakpoints in a file ++* Static Probe Points:: Listing static probe points + * Error in Breakpoints:: ``Cannot insert breakpoints'' + * Breakpoint-related Warnings:: ``Breakpoint address adjusted...'' + @end menu +@@ -4525,6 +4536,50 @@ and remove the breakpoint definitions yo + that can no longer be recreated. + @end table + ++@node Static Probe Points ++@subsection Static Probe Points ++ ++@cindex SystemTap static probe point ++@cindex sdt-probe ++The @sc{gnu}/Linux tool @code{SystemTap} provides a way for ++applications to embed static probes, using @file{sys/sdt.h}. @value{GDBN} ++can list the available probes, and you can put breakpoints at the ++probe points (@pxref{Specify Location}). ++ ++You can examine the available @code{SystemTap} static probes using ++@code{info probes}: ++ ++@table @code ++@kindex info probes ++@item info probes [@var{provider} [@var{name} [@var{objfile}]]] ++List the available @code{SystemTap} static probes. ++ ++If given, @var{provider} is a regular expression used to select which ++providers to list. If omitted, all providers are listed. ++ ++If given, @var{name} is a regular expression used to select which ++probes to list. If omitted, all probes are listed. ++ ++If given, @var{objfile} is a regular expression used to select which ++object files (executable or shared libraries) to examine. If not ++given, all object files are considered. ++@end table ++ ++@vindex $_probe_arg@r{, convenience variable} ++A probe may specify up to ten arguments. These are available at the ++point at which the probe is defined---that is, when the current PC is ++at the probe's location. The arguments are available using the ++convenience variables (@pxref{Convenience Vars}) ++@code{$_probe_arg0}@dots{}@code{$_probe_arg9}. Each probe argument is ++an integer of the appropriate size; types are not preserved. The ++convenience variable @code{$_probe_argc} holds the number of arguments ++at the current probe point. ++ ++These variables are always available, but attempts to access them at ++any location other than a probe point will cause @value{GDBN} to give ++an error. ++ ++ + @c @ifclear BARETARGET + @node Error in Breakpoints + @subsection ``Cannot insert breakpoints'' +@@ -6440,6 +6495,29 @@ specify the function unambiguously, e.g. + functions with identical names in different source files. + @end table + ++@cindex SystemTap static probe point ++@item probe:@r{[}@var{objfile}:@r{]}@r{[}@var{provider}:@r{]}@var{name} ++The @sc{gnu}/Linux tool @code{SystemTap} provides a way for ++applications to embed static probes. This form of linespec specifies ++the location of such a static probe. See ++@uref{http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps} ++for more information on static probes. ++ ++If @var{objfile} is given, only probes coming from that shared library ++or executable are considered. If @var{provider} is given, then only ++probes from that provider are considered. ++ ++@xref{Static Probe Points}, for more information on finding and using ++static probes. ++ ++Some probes have an associated semaphore variable; for instance, this ++happens automatically if you defined your probe using a DTrace-style ++@file{.d} file. If your probe has a semaphore, @value{GDBN} will ++automatically enable it when you specify a breakpoint using the ++@samp{probe:} notation. But, if you put a breakpoint at a probe's ++location by some other method (e.g., @code{break file:line}), then ++@value{GDBN} will not automatically set the semaphore. ++ + @end table + + +@@ -8526,6 +8604,10 @@ to match the format in which the data wa + The variable @code{$_exitcode} is automatically set to the exit code when + the program being debugged terminates. + ++@item $_probe_argc ++@itemx $_probe_arg0@dots{}$_probe_arg9 ++Arguments to a SystemTap static probe. @xref{Static Probe Points}. ++ + @item $_sdata + @vindex $_sdata@r{, inspect, convenience variable} + The variable @code{$_sdata} contains extra collected static tracepoint +@@ -10264,6 +10346,16 @@ Collect all function arguments. + @item $locals + Collect all local variables. + ++@item $_probe_argc ++Collects the number of arguments from the @code{SystemTap} probe at ++which the tracepoint is located. ++@xref{Static Probe Points,,Static Probe Points} ++ ++@item $_probe_arg@var{N} ++Where @var{N} varies from 0 to 9. Collects the @var{N}th argument ++from the @code{SystemTap} probe at which the tracepoint is located. ++@xref{Static Probe Points,,Static Probe Points} ++ + @item $_sdata + @vindex $_sdata@r{, collect} + Collect static tracepoint marker specific data. Only available for +@@ -20805,8 +20897,6 @@ containing @code{end}. For example: + + @smallexample + (@value{GDBP}) python +-Type python script +-End with a line saying just "end". + >print 23 + >end + 23 +@@ -20824,6 +20914,14 @@ occurs in a Python script. This can be + python print-stack}: if @code{on}, then Python stack printing is + enabled; if @code{off}, the default, then Python stack printing is + disabled. ++ ++@kindex maint set python auto-load ++@item maint set python auto-load ++By default, @value{GDBN} will attempt to automatically load Python ++code when an object file is opened. This can be controlled using ++@code{maint set python auto-load}: if @code{on}, the default, then ++Python auto-loading is enabled; if @code{off}, then Python ++auto-loading is disabled. + @end table + + It is also possible to execute a Python script from the @value{GDBN} +@@ -20845,6 +20943,14 @@ and thus is always available. + @cindex python api + @cindex programming in python + ++You can get quick online help for @value{GDBN}'s Python API by issuing ++the command @w{@kbd{python help (gdb)}}. ++ ++Functions and methods which have two or more optional arguments allow ++them to be specified using keyword syntax. This allows passing some ++optional arguments while skipping others. Example: ++@w{@code{gdb.some_function ('foo', bar = 1, baz = 2)}}. ++ + @cindex python stdout + @cindex python pagination + At startup, @value{GDBN} overrides Python's @code{sys.stdout} and +Index: gdb-7.3.50.20110722/gdb/doc/gdbint.texinfo +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/doc/gdbint.texinfo 2011-04-19 20:04:08.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/doc/gdbint.texinfo 2011-07-29 22:52:02.000000000 +0200 +@@ -2104,6 +2104,18 @@ time, and so we attempt to handle symbol + we create @dfn{partial symbol tables} consisting of only selected + symbols, and only expand them to full symbol tables when necessary. + ++@menu ++* Symbol Reading:: ++* Partial Symbol Tables:: ++* Types:: ++* Object File Formats:: ++* Debugging File Formats:: ++* Adding a New Symbol Reader to GDB:: ++* Memory Management for Symbol Files:: ++* Memory Management for Types:: ++@end menu ++ ++@node Symbol Reading + @section Symbol Reading + + @cindex symbol reading +@@ -2196,6 +2208,7 @@ symtab. Upon return, @code{pst->readin} + zero if there were no symbols in that part of the symbol file. + @end table + ++@node Partial Symbol Tables + @section Partial Symbol Tables + + @value{GDBN} has three types of symbol tables: +@@ -2297,6 +2310,7 @@ and partial symbol tables behind a set o + the @dfn{quick symbol functions}. These are documented in + @file{symfile.h}. + ++@node Types + @section Types + + @unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}). +@@ -2319,6 +2333,7 @@ types map to one @code{TYPE_CODE_*} type + other members of the type struct, such as whether the type is signed + or unsigned, and how many bits it uses. + ++@anchor{Builtin Types} + @unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}). + + These are instances of type structs that roughly correspond to +@@ -2333,6 +2348,7 @@ only one instance exists, while @file{c- + @code{TYPE_CODE_INT} types as needed, with each one associated with + some particular objfile. + ++@node Object File Formats + @section Object File Formats + @cindex object file formats + +@@ -2418,6 +2434,7 @@ SOM, which is a cross-language ABI). + + The SOM reader is in @file{somread.c}. + ++@node Debugging File Formats + @section Debugging File Formats + + This section describes characteristics of debugging information that +@@ -2489,6 +2506,7 @@ DWARF 3 is an improved version of DWARF + @cindex SOM debugging info + Like COFF, the SOM definition includes debugging information. + ++@node Adding a New Symbol Reader to GDB + @section Adding a New Symbol Reader to @value{GDBN} + + @cindex adding debugging info reader +@@ -2511,6 +2529,7 @@ will only ever be implemented by one obj + directly. This interface should be described in a file + @file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}. + ++@node Memory Management for Symbol Files + @section Memory Management for Symbol Files + + Most memory associated with a loaded symbol file is stored on +@@ -2522,10 +2541,45 @@ released when the objfile is unloaded or + objfile must not reference symbol or type data from another objfile; + they could be unloaded at different times. + +-User convenience variables, et cetera, have associated types. Normally +-these types live in the associated objfile. However, when the objfile +-is unloaded, those types are deep copied to global memory, so that +-the values of the user variables and history items are not lost. ++@node Memory Management for Types ++@section Memory Management for Types ++@cindex memory management for types ++ ++@findex TYPE_OBJFILE ++@code{TYPE_OBJFILE} macro indicates the current memory owner of the type. ++Non-@code{NULL} value indicates it is owned by an objfile (specifically by its ++obstack) and in such case the type remains valid till the objfile is unloaded ++or reloaded. For such types with an associated objfile no reference counting ++is being made. ++ ++User convenience variables, et cetera, have associated types. Normally these ++types live in the associated objfile. However, when the objfile is unloaded, ++those types are deep copied to global memory, so that the values of the user ++variables and history items are not lost. During the copy they will get their ++@code{TYPE_OBJFILE} set to @code{NULL} and become so-called @dfn{reclaimable} ++types. ++ ++Types with null @code{TYPE_OBJFILE} can be either permanent types ++(@pxref{Builtin Types}) or reclaimable types which will be deallocated at the ++first idle @value{GDBN} moment if the last object referencing them is removed. ++Permanent types are allocated by the function @code{alloc_type} (and its ++derivations like @code{init_type}) specifying objfile as @code{NULL}. The ++reclaimable types are created the same way but moreover they need to have ++@code{type_init_group} called to start their tracking as being possibly ++deallocatable. ++ ++@findex free_all_types ++When @value{GDBN} gets idle it always calls the @code{free_all_types} function ++which deallocates any unused types. All types currently not owned by an ++objfile must be marked as used on each @code{free_all_types} call as they would ++get deallocated as unused otherwise. ++ ++@code{free_all_types} automatically checks for any cross-type references such ++as through @code{TYPE_TARGET_TYPE}, @code{TYPE_POINTER_TYPE} etc.@: and ++prevents early deallocation for any such existing references. Reclaimable ++types may reference any other reclaimable types or even permanent types. But ++permanent types must not reference reclaimable types (nor an objfile associated ++type). + + + @node Language Support +Index: gdb-7.3.50.20110722/gdb/doc/observer.texi +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/doc/observer.texi 2011-07-21 13:03:47.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/doc/observer.texi 2011-07-29 22:52:02.000000000 +0200 +@@ -227,6 +227,11 @@ Called before a top-level prompt is disp + the current top-level prompt. + @end deftypefun + ++@c @deftypefun void mark_used (void) ++@c Mark any possibly reclaimable objects as used during a mark-and-sweep garbage ++@c collector pass. Currently only @code{type_mark_used} marker is supported. ++@c @end deftypefun ++ + @deftypefun void test_notification (int @var{somearg}) + This observer is used for internal testing. Do not use. + See testsuite/gdb.gdb/observer.exp. +Index: gdb-7.3.50.20110722/gdb/dwarf2expr.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2expr.c 2011-07-15 22:54:32.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2expr.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1258,6 +1258,14 @@ execute_stack_op (struct dwarf_expr_cont + } + break; + ++ case DW_OP_push_object_address: ++ if (ctx->funcs->get_object_address == NULL) ++ error (_("DWARF-2 expression error: DW_OP_push_object_address must " ++ "have a value to push.")); ++ result = (ctx->funcs->get_object_address) (ctx->baton); ++ result_val = value_from_ulongest (address_type, result); ++ break; ++ + default: + error (_("Unhandled dwarf expression opcode 0x%x"), op); + } +Index: gdb-7.3.50.20110722/gdb/dwarf2expr.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2expr.h 2011-07-15 22:54:32.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2expr.h 2011-07-29 22:52:02.000000000 +0200 +@@ -62,12 +62,10 @@ struct dwarf_expr_context_funcs + meaningful to substitute a stub type of the correct size. */ + struct type *(*get_base_type) (struct dwarf_expr_context *ctx, size_t die); + +-#if 0 + /* Not yet implemented. */ + + /* Return the `object address' for DW_OP_push_object_address. */ + CORE_ADDR (*get_object_address) (void *baton); +-#endif + }; + + /* The location of a value. */ +Index: gdb-7.3.50.20110722/gdb/dwarf2loc.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2loc.c 2011-07-19 22:28:52.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2loc.c 2011-07-29 22:52:02.000000000 +0200 +@@ -134,6 +134,9 @@ struct dwarf_expr_baton + { + struct frame_info *frame; + struct dwarf2_per_cu_data *per_cu; ++ /* From DW_TAG_variable's DW_AT_location (not DW_TAG_type's ++ DW_AT_data_location) for DW_OP_push_object_address. */ ++ CORE_ADDR object_address; + }; + + /* Helper functions for dwarf2_evaluate_loc_desc. */ +@@ -202,23 +205,33 @@ dwarf_expr_frame_base_1 (struct symbol * + symbaton = SYMBOL_LOCATION_BATON (framefunc); + *start = dwarf2_find_location_expression (symbaton, length, pc); + } +- else ++ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs) + { + struct dwarf2_locexpr_baton *symbaton; + + symbaton = SYMBOL_LOCATION_BATON (framefunc); +- if (symbaton != NULL) +- { +- *length = symbaton->size; +- *start = symbaton->data; +- } +- else +- *start = NULL; ++ gdb_assert (symbaton != NULL); ++ *start = symbaton->data; ++ *length = symbaton->size; + } ++ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_missing_funcs) ++ { ++ struct dwarf2_locexpr_baton *symbaton; ++ ++ symbaton = SYMBOL_LOCATION_BATON (framefunc); ++ gdb_assert (symbaton == NULL); ++ *start = NULL; ++ *length = 0; /* unused */ ++ } ++ else ++ internal_error (__FILE__, __LINE__, ++ _("Unsupported SYMBOL_COMPUTED_OPS %p for \"%s\""), ++ SYMBOL_COMPUTED_OPS (framefunc), ++ SYMBOL_PRINT_NAME (framefunc)); + + if (*start == NULL) + error (_("Could not find the frame base for \"%s\"."), +- SYMBOL_NATURAL_NAME (framefunc)); ++ SYMBOL_PRINT_NAME (framefunc)); + } + + /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for +@@ -291,6 +304,85 @@ dwarf_expr_dwarf_call (struct dwarf_expr + ctx->funcs->get_frame_pc, ctx->baton); + } + ++static CORE_ADDR ++dwarf_expr_object_address (void *baton) ++{ ++ struct dwarf_expr_baton *debaton = baton; ++ ++ /* The message is suppressed in DWARF_BLOCK_EXEC. */ ++ if (debaton->object_address == 0) ++ error (_("Cannot resolve DW_OP_push_object_address for a missing object")); ++ ++ return debaton->object_address; ++} ++ ++/* Address of the variable we are currently referring to. It is set from ++ DW_TAG_variable's DW_AT_location (not DW_TAG_type's DW_AT_data_location) for ++ DW_OP_push_object_address. */ ++ ++static CORE_ADDR object_address; ++ ++/* Callers use object_address_set while their callers use the result set so we ++ cannot run the cleanup at the local block of our direct caller. Still we ++ should reset OBJECT_ADDRESS at least for the next GDB command. */ ++ ++static void ++object_address_cleanup (void *prev_save_voidp) ++{ ++ CORE_ADDR *prev_save = prev_save_voidp; ++ ++ object_address = *prev_save; ++ xfree (prev_save); ++} ++ ++/* Set the base address - DW_AT_location - of a variable. It is being later ++ used to derive other object addresses by DW_OP_push_object_address. ++ ++ It would be useful to sanity check ADDRESS - such as for some objects with ++ unset value_raw_address - but some valid addresses may be zero (such as first ++ objects in relocatable .o files). */ ++ ++void ++object_address_set (CORE_ADDR address) ++{ ++ CORE_ADDR *prev_save; ++ ++ prev_save = xmalloc (sizeof *prev_save); ++ *prev_save = object_address; ++ make_cleanup (object_address_cleanup, prev_save); ++ ++ object_address = address; ++} ++ ++/* Evaluate DWARF location list at DLLBATON expecting it produces exactly one ++ CORE_ADDR result stored to *ADDRP on the DWARF stack stack. If the result ++ could not be found return zero and keep *ADDRP unchanged. */ ++ ++int ++dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp) ++{ ++ struct frame_info *frame = get_selected_frame (NULL); ++ const gdb_byte *data; ++ size_t size; ++ struct value *val; ++ ++ if (!dllbaton) ++ return 0; ++ ++ data = dwarf2_find_location_expression (dllbaton, &size, ++ get_frame_address_in_block (frame)); ++ if (data == NULL) ++ return 0; ++ ++ val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu); ++ if (value_optimized_out (val)) ++ return 0; ++ ++ *addrp = value_as_address (val); ++ return 1; ++} ++ + /* Callback function for dwarf2_evaluate_loc_desc. */ + + static struct type * +@@ -301,6 +393,85 @@ dwarf_expr_get_base_type (struct dwarf_e + return dwarf2_get_die_type (die_offset, debaton->per_cu); + } + ++/* Virtual method table for dwarf2_evaluate_loc_desc_full below. */ ++ ++static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = ++{ ++ dwarf_expr_read_reg, ++ dwarf_expr_read_mem, ++ dwarf_expr_frame_base, ++ dwarf_expr_frame_cfa, ++ dwarf_expr_frame_pc, ++ dwarf_expr_tls_address, ++ dwarf_expr_dwarf_call, ++ dwarf_expr_get_base_type, ++ dwarf_expr_object_address ++}; ++ ++/* Evaluate DWARF expression at DATA ... DATA + SIZE with its result readable ++ by dwarf_expr_fetch (RETVAL, 0). FRAME parameter can be NULL to call ++ get_selected_frame to find it. Returned dwarf_expr_context freeing is ++ pushed on the cleanup chain. */ ++ ++static void ++dwarf_expr_prep_ctx (struct dwarf_expr_context *ctx, struct frame_info *frame, ++ const gdb_byte *data, size_t size, ++ struct dwarf2_per_cu_data *per_cu) ++{ ++ struct dwarf_expr_baton baton; ++ struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); ++ volatile struct gdb_exception ex; ++ ++ baton.frame = frame; ++ baton.per_cu = per_cu; ++ baton.object_address = object_address; ++ ++ ctx->gdbarch = get_objfile_arch (objfile); ++ ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); ++ ctx->offset = dwarf2_per_cu_text_offset (per_cu); ++ ctx->baton = &baton; ++ ctx->funcs = &dwarf_expr_ctx_funcs; ++ ++ dwarf_expr_eval (ctx, data, size); ++} ++ ++/* Evaluate DWARF expression at DLBATON expecting it produces exactly one ++ CORE_ADDR result on the DWARF stack stack. */ ++ ++CORE_ADDR ++dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton) ++{ ++ struct dwarf_expr_context *ctx; ++ CORE_ADDR retval; ++ struct cleanup *back_to; ++ ++ ctx = new_dwarf_expr_context (); ++ back_to = make_cleanup_free_dwarf_expr_context (ctx); ++ ++ dwarf_expr_prep_ctx (ctx, get_selected_frame (NULL), dlbaton->data, ++ dlbaton->size, dlbaton->per_cu); ++ ++ if (ctx->num_pieces > 0) ++ error (_("DW_OP_*piece is unsupported for DW_FORM_block")); ++ ++ retval = dwarf_expr_fetch_address (ctx, 0); ++ ++ if (ctx->location == DWARF_VALUE_REGISTER) ++ { ++ /* Inlined dwarf_expr_read_reg as we no longer have the baton. */ ++ ++ int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (ctx->gdbarch, retval); ++ struct type *type = builtin_type (ctx->gdbarch)->builtin_data_ptr; ++ struct frame_info *frame = get_selected_frame (NULL); ++ ++ retval = address_from_register (type, gdb_regnum, frame); ++ } ++ ++ do_cleanups (back_to); ++ ++ return retval; ++} ++ + struct piece_closure + { + /* Reference count. */ +@@ -1082,20 +1253,6 @@ invalid_synthetic_pointer (void) + "referenced via synthetic pointer")); + } + +-/* Virtual method table for dwarf2_evaluate_loc_desc_full below. */ +- +-static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = +-{ +- dwarf_expr_read_reg, +- dwarf_expr_read_mem, +- dwarf_expr_frame_base, +- dwarf_expr_frame_cfa, +- dwarf_expr_frame_pc, +- dwarf_expr_tls_address, +- dwarf_expr_dwarf_call, +- dwarf_expr_get_base_type +-}; +- + /* Evaluate a location description, starting at DATA and with length + SIZE, to find the current location of variable of TYPE in the + context of FRAME. BYTE_OFFSET is applied after the contents are +@@ -1108,10 +1265,8 @@ dwarf2_evaluate_loc_desc_full (struct ty + LONGEST byte_offset) + { + struct value *retval; +- struct dwarf_expr_baton baton; + struct dwarf_expr_context *ctx; + struct cleanup *old_chain, *value_chain; +- struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); + volatile struct gdb_exception ex; + + if (byte_offset < 0) +@@ -1120,28 +1275,18 @@ dwarf2_evaluate_loc_desc_full (struct ty + if (size == 0) + return allocate_optimized_out_value (type); + +- baton.frame = frame; +- baton.per_cu = per_cu; +- + ctx = new_dwarf_expr_context (); + old_chain = make_cleanup_free_dwarf_expr_context (ctx); + value_chain = make_cleanup_value_free_to_mark (value_mark ()); + +- ctx->gdbarch = get_objfile_arch (objfile); +- ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); +- ctx->offset = dwarf2_per_cu_text_offset (per_cu); +- ctx->baton = &baton; +- ctx->funcs = &dwarf_expr_ctx_funcs; +- + TRY_CATCH (ex, RETURN_MASK_ERROR) + { +- dwarf_expr_eval (ctx, data, size); ++ dwarf_expr_prep_ctx (ctx, frame, data, size, per_cu); + } + if (ex.reason < 0) + { + if (ex.error == NOT_AVAILABLE_ERROR) + { +- do_cleanups (old_chain); + retval = allocate_value (type); + mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type)); + return retval; +@@ -1198,6 +1343,16 @@ dwarf2_evaluate_loc_desc_full (struct ty + int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); + + do_cleanups (value_chain); ++ ++ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */ ++ make_cleanup_restore_selected_frame (); ++ select_frame (frame); ++ ++ /* object_address_set called here is required in ALLOCATE_VALUE's ++ CHECK_TYPEDEF for the object's possible ++ DW_OP_push_object_address. */ ++ object_address_set (address); ++ + retval = allocate_value_lazy (type); + VALUE_LVAL (retval) = lval_memory; + if (in_stack_memory) +@@ -2974,11 +3129,51 @@ loclist_tracepoint_var_ref (struct symbo + dlbaton->per_cu); + } + +-/* The set of location functions used with the DWARF-2 expression +- evaluator and location lists. */ ++/* The set of location functions used with the DWARF-2 location lists. */ + const struct symbol_computed_ops dwarf2_loclist_funcs = { + loclist_read_variable, + loclist_read_needs_frame, + loclist_describe_location, + loclist_tracepoint_var_ref + }; ++ ++static struct value * ++missing_read_variable (struct symbol *symbol, struct frame_info *frame) ++{ ++ struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); ++ ++ gdb_assert (dlbaton == NULL); ++ error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol)); ++} ++ ++static int ++missing_read_needs_frame (struct symbol *symbol) ++{ ++ return 0; ++} ++ ++static void ++missing_describe_location (struct symbol *symbol, CORE_ADDR addr, ++ struct ui_file *stream) ++{ ++ fprintf_filtered (stream, _("a variable we are unable to resolve")); ++} ++ ++static void ++missing_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, ++ struct agent_expr *ax, struct axs_value *value) ++{ ++ struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); ++ ++ gdb_assert (dlbaton == NULL); ++ error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol)); ++} ++ ++/* The set of location functions used with the DWARF-2 evaluator when we are ++ unable to resolve the symbols. */ ++const struct symbol_computed_ops dwarf2_missing_funcs = { ++ missing_read_variable, ++ missing_read_needs_frame, ++ missing_describe_location, ++ missing_tracepoint_var_ref ++}; +Index: gdb-7.3.50.20110722/gdb/dwarf2loc.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2loc.h 2011-05-12 19:40:54.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2loc.h 2011-07-29 22:52:02.000000000 +0200 +@@ -110,6 +110,15 @@ struct dwarf2_loclist_baton + + extern const struct symbol_computed_ops dwarf2_locexpr_funcs; + extern const struct symbol_computed_ops dwarf2_loclist_funcs; ++extern const struct symbol_computed_ops dwarf2_missing_funcs; ++ ++extern void object_address_set (CORE_ADDR address); ++ ++extern CORE_ADDR dwarf_locexpr_baton_eval ++ (struct dwarf2_locexpr_baton *dlbaton); ++ ++extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp); + + /* Compile a DWARF location expression to an agent expression. + +Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-29 22:52:00.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1251,6 +1251,9 @@ static void fill_in_loclist_baton (struc + struct dwarf2_loclist_baton *baton, + struct attribute *attr); + ++static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton ++ (struct attribute *attr, struct dwarf2_cu *cu); ++ + static void dwarf2_symbol_mark_computed (struct attribute *attr, + struct symbol *sym, + struct dwarf2_cu *cu); +@@ -1285,6 +1288,9 @@ static void age_cached_comp_units (void) + + static void free_one_cached_comp_unit (void *); + ++static void fetch_die_type_attrs (struct die_info *die, struct type *type, ++ struct dwarf2_cu *cu); ++ + static struct type *set_die_type (struct die_info *, struct type *, + struct dwarf2_cu *); + +@@ -1309,6 +1315,9 @@ static struct type *get_die_type_at_offs + + static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); + ++static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton ++ (struct attribute *attr, struct dwarf2_cu *cu); ++ + static void dwarf2_release_queue (void *dummy); + + static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, +@@ -7785,6 +7794,29 @@ process_enumeration_scope (struct die_in + new_symbol (die, this_type, cu); + } + ++/* Create a new array dimension referencing its target type TYPE. ++ ++ Multidimensional arrays are internally represented as a stack of ++ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */ ++ ++static struct type * ++create_single_array_dimension (struct type *type, struct type *range_type, ++ struct die_info *die, struct dwarf2_cu *cu) ++{ ++ type = create_array_type (NULL, type, range_type); ++ ++ /* These generic type attributes need to be fetched by ++ evaluate_subexp_standard 's call of ++ value_subscripted_rvalue only for the innermost array type. */ ++ fetch_die_type_attrs (die, type, cu); ++ ++ /* These generic type attributes are checked for allocated/associated ++ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */ ++ fetch_die_type_attrs (die, range_type, cu); ++ ++ return type; ++} ++ + /* Extract all information from a DW_TAG_array_type DIE and put it in + the DIE's type field. For now, this only handles one dimensional + arrays. */ +@@ -7798,7 +7830,7 @@ read_array_type (struct die_info *die, s + struct type *element_type, *range_type, *index_type; + struct type **range_types = NULL; + struct attribute *attr; +- int ndim = 0; ++ int ndim = 0, i; + struct cleanup *back_to; + char *name; + +@@ -7851,17 +7883,19 @@ read_array_type (struct die_info *die, s + type = element_type; + + if (read_array_order (die, cu) == DW_ORD_col_major) +- { +- int i = 0; +- +- while (i < ndim) +- type = create_array_type (NULL, type, range_types[i++]); +- } +- else +- { +- while (ndim-- > 0) +- type = create_array_type (NULL, type, range_types[ndim]); +- } ++ for (i = 0; i < ndim; i++) ++ type = create_single_array_dimension (type, range_types[i], die, cu); ++ else /* (read_array_order (die, cu) == DW_ORD_row_major) */ ++ for (i = ndim - 1; i >= 0; i--) ++ type = create_single_array_dimension (type, range_types[i], die, cu); ++ ++ /* Data locations should be set only for the outermost dimension as they ++ would be confusing for the dereferenced offset on the inner ones. */ ++ attr = dwarf2_attr (die, DW_AT_data_location, cu); ++ if (attr_form_is_block (attr)) ++ TYPE_DATA_LOCATION_DWARF_BLOCK (type) ++ = dwarf2_attr_to_locexpr_baton (attr, cu); ++ gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type)); + + /* Understand Dwarf2 support for vector types (like they occur on + the PowerPC w/ AltiVec). Gcc just adds another attribute to the +@@ -8345,29 +8379,114 @@ read_tag_string_type (struct die_info *d + struct gdbarch *gdbarch = get_objfile_arch (objfile); + struct type *type, *range_type, *index_type, *char_type; + struct attribute *attr; +- unsigned int length; ++ int length; ++ ++ index_type = objfile_type (objfile)->builtin_int; ++ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */ ++ range_type = alloc_type (objfile); ++ /* LOW_BOUND and HIGH_BOUND are set for real below. */ ++ range_type = create_range_type (range_type, index_type, 0, -1); ++ ++ /* C/C++ should probably have the low bound 0 but C/C++ does not use ++ DW_TAG_string_type. */ ++ TYPE_LOW_BOUND (range_type) = 1; + + attr = dwarf2_attr (die, DW_AT_string_length, cu); +- if (attr) ++ if (attr && attr_form_is_block (attr)) + { +- length = DW_UNSND (attr); ++ /* Security check for a size overflow. */ ++ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size) ++ TYPE_HIGH_BOUND (range_type) = 1; ++ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size ++ instruction as DW_AT_string_length specifies the length location, not ++ its value. */ ++ else ++ { ++ struct dwarf2_locexpr_baton *length_baton = NULL; ++ struct dwarf_block *blk = DW_BLOCK (attr); ++ ++ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing ++ DW_OP_deref* in such case. */ ++ ++ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0 ++ && blk->data[0] <= DW_OP_reg31) ++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); ++ else if (blk->size > 1 && blk->data[0] == DW_OP_regx) ++ { ++ ULONGEST ulongest; ++ const gdb_byte *end; ++ ++ end = read_uleb128 (&blk->data[1], &blk->data[blk->size], ++ &ulongest); ++ if (end == &blk->data[blk->size]) ++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); ++ } ++ ++ if (length_baton == NULL) ++ { ++ struct attribute *size_attr; ++ gdb_byte *data; ++ ++ length_baton = obstack_alloc (&cu->comp_unit_obstack, ++ sizeof (*length_baton)); ++ length_baton->per_cu = cu->per_cu; ++ length_baton->size = DW_BLOCK (attr)->size + 2; ++ data = obstack_alloc (&cu->comp_unit_obstack, ++ length_baton->size); ++ length_baton->data = data; ++ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size); ++ ++ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH ++ specifies the size of an integer to fetch. */ ++ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu); ++ if (size_attr) ++ { ++ data[DW_BLOCK (attr)->size] = DW_OP_deref_size; ++ data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr); ++ if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr)) ++ complaint (&symfile_complaints, ++ _("DW_AT_string_length's DW_AT_byte_size " ++ "integer exceeds the byte size storage")); ++ } ++ else ++ { ++ data[DW_BLOCK (attr)->size] = DW_OP_deref; ++ data[DW_BLOCK (attr)->size + 1] = DW_OP_nop; ++ } ++ } ++ ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton; ++ TYPE_DYNAMIC (range_type) = 1; ++ } + } + else + { +- /* Check for the DW_AT_byte_size attribute. */ ++ if (attr && attr_form_is_constant (attr)) ++ { ++ /* We currently do not support a constant address where the location ++ should be read from - attr_form_is_block is expected instead. See ++ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. ++ */ ++ /* PASSTHRU */ ++ } ++ + attr = dwarf2_attr (die, DW_AT_byte_size, cu); +- if (attr) +- { +- length = DW_UNSND (attr); +- } ++ if (attr && attr_form_is_block (attr)) ++ { ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && attr_form_is_constant (attr)) ++ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0); + else +- { +- length = 1; +- } ++ TYPE_HIGH_BOUND (range_type) = 1; + } + +- index_type = objfile_type (objfile)->builtin_int; +- range_type = create_range_type (NULL, index_type, 1, length); + char_type = language_string_char_type (cu->language_defn, gdbarch); + type = create_string_type (NULL, char_type, range_type); + +@@ -8658,8 +8777,7 @@ read_subrange_type (struct die_info *die + struct type *base_type; + struct type *range_type; + struct attribute *attr; +- LONGEST low = 0; +- LONGEST high = -1; ++ LONGEST low; + char *name; + LONGEST negative_mask; + +@@ -8672,53 +8790,126 @@ read_subrange_type (struct die_info *die + if (range_type) + return range_type; + +- if (cu->language == language_fortran) +- { +- /* FORTRAN implies a lower bound of 1, if not given. */ +- low = 1; +- } ++ /* LOW_BOUND and HIGH_BOUND are set for real below. */ ++ range_type = create_range_type (NULL, base_type, 0, -1); ++ TYPE_UNSIGNED (range_type) = 0; + +- /* FIXME: For variable sized arrays either of these could be +- a variable rather than a constant value. We'll allow it, +- but we don't know how to handle it. */ +- attr = dwarf2_attr (die, DW_AT_lower_bound, cu); +- if (attr) +- low = dwarf2_get_attr_constant_value (attr, 0); ++ negative_mask = ++ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); + +- attr = dwarf2_attr (die, DW_AT_upper_bound, cu); +- if (attr) ++ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada ++ supports implements the dynamic bounds in a non-DWARF way and the ++ existing DWARF dynamic bounds are invalid, leading to memory access ++ errors. */ ++ ++ attr = dwarf2_attr (die, DW_AT_lower_bound, cu); ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) + { +- if (attr_form_is_block (attr) || is_ref_attr (attr)) +- { +- /* GCC encodes arrays with unspecified or dynamic length +- with a DW_FORM_block1 attribute or a reference attribute. +- FIXME: GDB does not yet know how to handle dynamic +- arrays properly, treat them as arrays with unspecified +- length for now. +- +- FIXME: jimb/2003-09-22: GDB does not really know +- how to handle arrays of unspecified length +- either; we just represent them as zero-length +- arrays. Choose an appropriate upper bound given +- the lower bound we've computed above. */ +- high = low - 1; +- } +- else +- high = dwarf2_get_attr_constant_value (attr, 1); ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ ++ low = 0; ++ } ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ ++ low = 0; + } + else + { +- attr = dwarf2_attr (die, DW_AT_count, cu); +- if (attr) ++ if (attr && attr_form_is_constant (attr)) ++ low = dwarf2_get_attr_constant_value (attr, 0); ++ else + { +- int count = dwarf2_get_attr_constant_value (attr, 1); +- high = low + count - 1; ++ if (cu->language == language_fortran) ++ { ++ /* FORTRAN implies a lower bound of 1, if not given. */ ++ low = 1; ++ } ++ else ++ { ++ /* According to DWARF we should assume the value 0 only for ++ LANGUAGE_C and LANGUAGE_CPLUS. */ ++ low = 0; ++ } + } ++ if (!TYPE_UNSIGNED (base_type) && (low & negative_mask)) ++ low |= negative_mask; ++ TYPE_LOW_BOUND (range_type) = low; ++ if (low >= 0) ++ TYPE_UNSIGNED (range_type) = 1; ++ } ++ ++ attr = dwarf2_attr (die, DW_AT_upper_bound, cu); ++ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr) ++ && !is_ref_attr (attr))) ++ { ++ attr = dwarf2_attr (die, DW_AT_count, cu); ++ /* It does not hurt but it is needlessly ineffective in check_typedef. */ ++ if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr))) ++ { ++ TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1; ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ /* Pass it now as the regular DW_AT_upper_bound. */ ++ } ++ ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) ++ { ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else ++ { ++ LONGEST high; ++ ++ if (attr && attr_form_is_constant (attr)) ++ high = dwarf2_get_attr_constant_value (attr, 0); + else + { +- /* Unspecified array length. */ ++ /* Ada expects an empty array on no boundary attributes. */ ++ if (cu->language != language_ada) ++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; + high = low - 1; + } ++ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) ++ high |= negative_mask; ++ TYPE_HIGH_BOUND (range_type) = high; + } + + /* Dwarf-2 specifications explicitly allows to create subrange types +@@ -8759,24 +8950,41 @@ read_subrange_type (struct die_info *die + } + } + +- negative_mask = +- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); +- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask)) +- low |= negative_mask; +- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) +- high |= negative_mask; +- +- range_type = create_range_type (NULL, base_type, low, high); +- +- /* Mark arrays with dynamic length at least as an array of unspecified +- length. GDB could check the boundary but before it gets implemented at +- least allow accessing the array elements. */ +- if (attr && attr_form_is_block (attr)) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; +- +- /* Ada expects an empty array on no boundary attributes. */ +- if (attr == NULL && cu->language != language_ada) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ /* DW_AT_bit_stride is currently unsupported as we count in bytes. */ ++ attr = dwarf2_attr (die, DW_AT_byte_stride, cu); ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) ++ { ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && attr_form_is_constant (attr)) ++ { ++ TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0); ++ if (TYPE_BYTE_STRIDE (range_type) == 0) ++ complaint (&symfile_complaints, ++ _("Found DW_AT_byte_stride with unsupported value 0")); ++ } + + name = dwarf2_name (die, cu); + if (name) +@@ -11333,10 +11541,12 @@ var_decode_location (struct attribute *a + (i.e. when the value of a register or memory location is + referenced, or a thread-local block, etc.). Then again, it might + not be worthwhile. I'm assuming that it isn't unless performance +- or memory numbers show me otherwise. */ ++ or memory numbers show me otherwise. ++ ++ SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */ + +- dwarf2_symbol_mark_computed (attr, sym, cu); + SYMBOL_CLASS (sym) = LOC_COMPUTED; ++ dwarf2_symbol_mark_computed (attr, sym, cu); + + if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs) + cu->has_loclist = 1; +@@ -11377,6 +11587,8 @@ new_symbol_full (struct die_info *die, s + else + sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol); + OBJSTAT (objfile, n_syms++); ++ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */ ++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs; + + /* Cache this symbol's name and the name's demangled form (if any). */ + SYMBOL_SET_LANGUAGE (sym, cu->language); +@@ -12149,6 +12361,9 @@ read_type_die_1 (struct die_info *die, s + break; + } + ++ if (this_type) ++ finalize_type (this_type); ++ + return this_type; + } + +@@ -15324,61 +15539,99 @@ fill_in_loclist_baton (struct dwarf2_cu + baton->base_address = cu->base_address; + } + +-static void +-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, +- struct dwarf2_cu *cu) ++/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK ++ attribute type. */ ++ ++static struct dwarf2_locexpr_baton * ++dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu) + { +- if (attr_form_is_section_offset (attr) +- /* ".debug_loc" may not exist at all, or the offset may be outside +- the section. If so, fall through to the complaint in the +- other branch. */ +- && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile, +- &dwarf2_per_objfile->loc)) +- { +- struct dwarf2_loclist_baton *baton; ++ struct dwarf2_locexpr_baton *baton; + +- baton = obstack_alloc (&cu->objfile->objfile_obstack, +- sizeof (struct dwarf2_loclist_baton)); ++ gdb_assert (attr_form_is_block (attr)); + +- fill_in_loclist_baton (cu, baton, attr); ++ baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton)); ++ baton->per_cu = cu->per_cu; ++ gdb_assert (baton->per_cu); + +- if (cu->base_known == 0) +- complaint (&symfile_complaints, +- _("Location list used without " +- "specifying the CU base address.")); ++ /* Note that we're just copying the block's data pointer ++ here, not the actual data. We're still pointing into the ++ info_buffer for SYM's objfile; right now we never release ++ that buffer, but when we do clean up properly this may ++ need to change. */ ++ baton->size = DW_BLOCK (attr)->size; ++ baton->data = DW_BLOCK (attr)->data; ++ gdb_assert (baton->size == 0 || baton->data != NULL); + ++ return baton; ++} ++ ++static struct dwarf2_loclist_baton * ++dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) ++{ ++ struct dwarf2_loclist_baton *baton; ++ ++ /* DW_AT_location of the referenced DIE may be missing if the referenced ++ variable has been optimized out. */ ++ if (!attr) ++ return NULL; ++ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, ++ &dwarf2_per_objfile->loc); ++ ++ if (!(attr_form_is_section_offset (attr) ++ /* ".debug_loc" may not exist at all, or the offset may be outside ++ the section. If so, fall through to the complaint in the ++ other branch. */ ++ && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile, ++ &dwarf2_per_objfile->loc))) ++ return NULL; ++ ++ baton = obstack_alloc (&cu->objfile->objfile_obstack, ++ sizeof (struct dwarf2_loclist_baton)); ++ ++ fill_in_loclist_baton (cu, baton, attr); ++ ++ if (cu->base_known == 0) ++ complaint (&symfile_complaints, ++ _("Location list used without " ++ "specifying the CU base address.")); ++ ++ return baton; ++} ++ ++/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */ ++ ++static void ++dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, ++ struct dwarf2_cu *cu) ++{ ++ struct dwarf2_loclist_baton *loclist_baton; ++ ++ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu); ++ if (loclist_baton) ++ { + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs; +- SYMBOL_LOCATION_BATON (sym) = baton; ++ SYMBOL_LOCATION_BATON (sym) = loclist_baton; ++ } ++ else if (attr_form_is_block (attr)) ++ { ++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; ++ SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu); + } + else + { +- struct dwarf2_locexpr_baton *baton; ++ dwarf2_invalid_attrib_class_complaint ("location description", ++ SYMBOL_NATURAL_NAME (sym)); + +- baton = obstack_alloc (&cu->objfile->objfile_obstack, +- sizeof (struct dwarf2_locexpr_baton)); +- baton->per_cu = cu->per_cu; +- gdb_assert (baton->per_cu); ++ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */ + +- if (attr_form_is_block (attr)) +- { +- /* Note that we're just copying the block's data pointer +- here, not the actual data. We're still pointing into the +- info_buffer for SYM's objfile; right now we never release +- that buffer, but when we do clean up properly this may +- need to change. */ +- baton->size = DW_BLOCK (attr)->size; +- baton->data = DW_BLOCK (attr)->data; +- } +- else +- { +- dwarf2_invalid_attrib_class_complaint ("location description", +- SYMBOL_NATURAL_NAME (sym)); +- baton->size = 0; +- baton->data = NULL; +- } ++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs; ++ SYMBOL_LOCATION_BATON (sym) = NULL; + +- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; +- SYMBOL_LOCATION_BATON (sym) = baton; ++ /* For functions a missing DW_AT_frame_base does not optimize out the ++ whole function definition, only its frame base resolving. */ ++ if (attr->name == DW_AT_location) ++ SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; + } + } + +@@ -15727,6 +15980,25 @@ offset_and_type_eq (const void *item_lhs + return ofs_lhs->offset == ofs_rhs->offset; + } + ++/* Fill in generic attributes applicable for type DIEs. */ ++ ++static void ++fetch_die_type_attrs (struct die_info *die, struct type *type, ++ struct dwarf2_cu *cu) ++{ ++ struct attribute *attr; ++ ++ attr = dwarf2_attr (die, DW_AT_allocated, cu); ++ if (attr_form_is_block (attr)) ++ TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu); ++ gdb_assert (!TYPE_NOT_ALLOCATED (type)); ++ ++ attr = dwarf2_attr (die, DW_AT_associated, cu); ++ if (attr_form_is_block (attr)) ++ TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu); ++ gdb_assert (!TYPE_NOT_ASSOCIATED (type)); ++} ++ + /* Set the type associated with DIE to TYPE. Save it in CU's hash + table if necessary. For convenience, return TYPE. + +@@ -15752,6 +16024,8 @@ set_die_type (struct die_info *die, stru + struct objfile *objfile = cu->objfile; + htab_t *type_hash_ptr; + ++ fetch_die_type_attrs (die, type, cu); ++ + /* For Ada types, make sure that the gnat-specific data is always + initialized (if not already set). There are a few types where + we should not be doing so, because the type-specific area is +Index: gdb-7.3.50.20110722/gdb/elfread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/elfread.c 2011-05-26 09:47:10.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/elfread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -38,6 +38,8 @@ + #include "demangle.h" + #include "psympriv.h" + #include "filenames.h" ++#include "stap-probe.h" ++#include "arch-utils.h" + #include "gdbtypes.h" + #include "value.h" + #include "infcall.h" +@@ -61,6 +63,21 @@ struct elfinfo + asection *mdebugsect; /* Section pointer for .mdebug section */ + }; + ++/* Per-objfile data for SystemTap probe info. */ ++ ++static const struct objfile_data *stap_probe_key = NULL; ++ ++/* Per-objfile data about SystemTap probes. */ ++ ++struct stap_probe_per_objfile ++ { ++ /* The number of probes in this objfile. */ ++ int stap_num_probes; ++ ++ /* The probes themselves. */ ++ struct stap_probe *probes; ++ }; ++ + static void free_elfinfo (void *); + + /* Minimal symbols located at the GOT entries for .plt - that is the real +@@ -1574,7 +1591,266 @@ elfstab_offset_sections (struct objfile + complaint (&symfile_complaints, + _("elf/stab section information missing for %s"), filename); + } ++ ++/* Helper function that parses the information contained in a ++ SystemTap's probe. Basically, the information consists in: ++ ++ - Probe's PC address; ++ - Link-time section address of `.stapsdt.base' section; ++ - Link-time address of the semaphore variable, or ZERO if the ++ probe doesn't have an associated semaphore; ++ - Probe's provider name; ++ - Probe's name; ++ - Probe's argument format. */ ++ ++static void ++handle_probe (struct objfile *objfile, struct sdt_note *el, ++ struct stap_probe *ret, CORE_ADDR base) ++{ ++ bfd *abfd = objfile->obfd; ++ int size = bfd_get_arch_size (abfd) / 8; ++ struct gdbarch *gdbarch = get_objfile_arch (objfile); ++ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; ++ CORE_ADDR base_ref; ++ ++ /* Provider and the name of the probe. */ ++ ret->provider = (const char *) &el->data[3 * size]; ++ ret->name = memchr (ret->provider, '\0', ++ (unsigned long *) el->data ++ + el->size - (unsigned long *) ret->provider); ++ /* Making sure there is a name. */ ++ if (!ret->name) ++ complaint (&symfile_complaints, _("corrupt probe when reading `%s'"), ++ objfile->name); ++ else ++ ++ret->name; ++ ++ /* Retrieving the probe's address. */ ++ ret->address = extract_typed_address ((const gdb_byte *) &el->data[0], ++ ptr_type); ++ /* Link-time sh_addr of `.stapsdt.base' section. */ ++ base_ref = extract_typed_address ((const gdb_byte *) &el->data[size], ++ ptr_type); ++ /* Semaphore address. */ ++ ret->sem_addr = extract_typed_address ((const gdb_byte *) &el->data[2 * size], ++ ptr_type); ++ ++ ret->address += (ANOFFSET (objfile->section_offsets, ++ SECT_OFF_TEXT (objfile)) ++ + base - base_ref); ++ if (ret->sem_addr) ++ ret->sem_addr += (ANOFFSET (objfile->section_offsets, ++ SECT_OFF_DATA (objfile)) ++ + base - base_ref); ++ ++ /* Arguments. We can only extract the argument format if there is a valid ++ name for this probe. */ ++ if (ret->name) ++ { ++ ret->args = memchr (ret->name, '\0', ++ (unsigned long *) el->data ++ + el->size - (unsigned long *) ret->name); ++ ++ if (ret->args++ != NULL ++ || memchr (ret->args, '\0', (unsigned long *) el->data ++ + el->size - (unsigned long *) ret->name) ++ != el->data + el->size - 1) ++ complaint (&symfile_complaints, _("corrupt probe when reading `%s'"), ++ objfile->name); ++ } ++ else ++ ret->args = NULL; ++} ++ ++/* The name of the SystemTap section where we will find information about ++ the probes. */ ++ ++#define STAP_BASE_SECTION_NAME ".stapsdt.base" ++ ++/* Helper function which tries to find the base address of the SystemTap ++ base section named STAP_BASE_SECTION_NAME. */ ++ ++static void ++get_base_address_1 (bfd *abfd, asection *sect, void *obj) ++{ ++ bfd_vma *base = (bfd_vma *) obj; ++ ++ if (*base == (bfd_vma) -1 ++ && (sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS)) ++ && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME)) ++ *base = sect->vma; ++} ++ ++/* Helper function which iterates over every section in the BFD file, ++ trying to find the base address of the SystemTap base section. ++ Returns the section address if found, or -1 otherwise. */ ++ ++static bfd_vma ++get_base_address (bfd *obfd) ++{ ++ bfd_vma base = (bfd_vma) -1; ++ ++ bfd_map_over_sections (obfd, get_base_address_1, (void *) &base); ++ ++ return base; ++} ++ ++/* Implementation of `sym_get_probes', as documented in symfile.h. */ ++ ++static const struct stap_probe * ++elf_get_probes (struct objfile *objfile, int *num_probes) ++{ ++ struct stap_probe *ret = NULL; ++ struct stap_probe_per_objfile *probes_per_objfile; ++ ++ /* Initially, no probes. */ ++ *num_probes = 0; ++ ++ /* Have we parsed this objfile's probes already? */ ++ probes_per_objfile ++ = (struct stap_probe_per_objfile *) objfile_data (objfile, ++ stap_probe_key); ++ ++ if (!probes_per_objfile) ++ { ++ /* If we are here, then this is the first time we are parsing the ++ probe's information. We basically have to count how many probes ++ the objfile has, and then fill in the necessary information ++ for each one. */ ++ ++ bfd *obfd = objfile->obfd; ++ bfd_vma base = get_base_address (obfd); ++ struct sdt_note *iter; ++ int i; ++ int n = 0; ++ ++ if (! elf_tdata (obfd)->sdt_note_head) ++ /* There isn't any probe here. */ ++ return NULL; ++ ++ /* Allocating space for probe info. */ ++ for (iter = elf_tdata (obfd)->sdt_note_head; ++ iter; ++ iter = iter->next, ++n); ++ ++ ret = xcalloc (n, sizeof (struct stap_probe)); ++ ++ /* Parsing each probe's information. */ ++ for (iter = elf_tdata (obfd)->sdt_note_head, i = 0; ++ iter; ++ iter = iter->next, i++) ++ /* We first have to handle all the information about the ++ probe which is present in the section. */ ++ handle_probe (objfile, iter, &ret[i], base); ++ ++ /* Creating a cache for these probes in the objfile's registry. */ ++ probes_per_objfile = xmalloc (sizeof (struct stap_probe_per_objfile)); ++ ++ probes_per_objfile->stap_num_probes = n; ++ probes_per_objfile->probes = ret; ++ ++ set_objfile_data (objfile, stap_probe_key, probes_per_objfile); ++ } ++ else ++ ret = probes_per_objfile->probes; ++ ++ *num_probes = probes_per_objfile->stap_num_probes; ++ ++ return ret; ++} ++ ++/* Implementation of `sym_get_probe_argument_count', as documented in ++ symfile.h. */ ++ ++static int ++elf_get_probe_argument_count (struct objfile *objfile, ++ const struct stap_probe *probe) ++{ ++ const char *pargs = probe->args; ++ ++ if (!pargs || !*pargs || *pargs == ':') ++ /* No arguments. */ ++ return 0; ++ ++ return stap_get_probe_argument_count (probe); ++} ++ ++/* Implementation of `sym_evaluate_probe_argument', as documented in ++ symfile.h. */ ++ ++static struct value * ++elf_evaluate_probe_argument (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct frame_info *frame, ++ int n) ++{ ++ return stap_evaluate_probe_argument (objfile, probe, frame, n); ++} ++ ++/* Implementation of `sym_compile_to_ax', as documented in symfile.h. */ ++ ++static void ++elf_compile_to_ax (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ int n) ++{ ++ stap_compile_to_ax (objfile, probe, expr, value, n); ++} ++ ++/* Implementation of `sym_relocate_probe', as documented in symfile.h. */ ++ ++static void ++elf_symfile_relocate_probe (struct objfile *objfile, ++ struct section_offsets *new_offsets, ++ struct section_offsets *delta) ++{ ++ int i; ++ struct stap_probe_per_objfile *p ++ = (struct stap_probe_per_objfile *) objfile_data (objfile, ++ stap_probe_key); ++ ++ if (!p) ++ /* No probe to relocate. */ ++ return; ++ ++ for (i = 0; i < p->stap_num_probes; i++) ++ { ++ p->probes[i].address += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); ++ if (p->probes[i].sem_addr) ++ p->probes[i].sem_addr += ANOFFSET (delta, SECT_OFF_DATA (objfile)); ++ } ++} ++ ++/* Helper function used to free the space allocated for storing SystemTap ++ probe information. */ ++ ++static void ++stap_probe_key_free (struct objfile *objfile, void *d) ++{ ++ int i; ++ struct stap_probe_per_objfile *data = (struct stap_probe_per_objfile *) d; ++ ++ for (i = 0; i < data->stap_num_probes; i++) ++ stap_free_parsed_args (data->probes[i].parsed_args); ++ xfree (data->probes); ++ xfree (data); ++} ++ + ++ ++/* Implementation `sym_probe_fns', as documented in symfile.h. */ ++ ++static const struct sym_probe_fns elf_probe_fns = ++{ ++ elf_get_probes, /* sym_get_probes */ ++ elf_get_probe_argument_count, /* sym_get_probe_argument_count */ ++ elf_evaluate_probe_argument, /* sym_evaluate_probe_argument */ ++ elf_compile_to_ax, /* sym_compile_to_ax */ ++ elf_symfile_relocate_probe, /* sym_relocate_probe */ ++}; ++ + /* Register that we are able to handle ELF object file formats. */ + + static const struct sym_fns elf_sym_fns = +@@ -1589,6 +1865,7 @@ static const struct sym_fns elf_sym_fns + elf_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ &elf_probe_fns, /* sym_probe_fns */ + &psym_functions + }; + +@@ -1607,6 +1884,7 @@ static const struct sym_fns elf_sym_fns_ + elf_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ &elf_probe_fns, /* sym_probe_fns */ + &psym_functions + }; + +@@ -1624,6 +1902,7 @@ static const struct sym_fns elf_sym_fns_ + elf_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ &elf_probe_fns, /* sym_probe_fns */ + &dwarf2_gdb_index_functions + }; + +@@ -1640,6 +1919,8 @@ static const struct gnu_ifunc_fns elf_gn + void + _initialize_elfread (void) + { ++ stap_probe_key ++ = register_objfile_data_with_cleanup (NULL, stap_probe_key_free); + add_symtab_fns (&elf_sym_fns); + + elf_objfile_gnu_ifunc_cache_data = register_objfile_data (); +Index: gdb-7.3.50.20110722/gdb/eval.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/eval.c 2011-06-17 22:35:09.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/eval.c 2011-07-29 22:52:02.000000000 +0200 +@@ -44,6 +44,7 @@ + #include "objfiles.h" + #include "python/python.h" + #include "wrapper.h" ++#include "dwarf2loc.h" + + #include "gdb_assert.h" + +@@ -489,27 +490,217 @@ init_array_element (struct value *array, + } + + static struct value * +-value_f90_subarray (struct value *array, +- struct expression *exp, int *pos, enum noside noside) ++value_f90_subarray (struct value *array, struct expression *exp, int *pos, ++ int nargs, enum noside noside) + { +- int pc = (*pos) + 1; +- LONGEST low_bound, high_bound; +- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); +- enum f90_range_type range_type = longest_to_int (exp->elts[pc].longconst); +- +- *pos += 3; ++ /* Type to use for the newly allocated value ARRAY. */ ++ struct type *new_array_type; + +- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) +- low_bound = TYPE_LOW_BOUND (range); ++ /* Type being iterated for each dimension. */ ++ struct type *type, *type_last_target; ++ ++ /* Pointer in the last holder to the type of current dimension. */ ++ struct type **typep = &new_array_type; ++ ++ struct subscript_index ++ { ++ enum { SUBSCRIPT_RANGE, SUBSCRIPT_NUMBER } kind; ++ union ++ { ++ struct subscript_range ++ { ++ enum f90_range_type f90_range_type; ++ LONGEST low_bound, high_bound; ++ } ++ range; ++ LONGEST number; ++ }; ++ } ++ *subscript_array; ++ struct type **type_array; ++ int i; ++ struct cleanup *old_chain; ++ CORE_ADDR value_byte_address, value_byte_offset = 0; ++ htab_t copied_types; ++ struct value *saved_array; ++ ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (array)); ++ ++ if (value_optimized_out (array) ++ || (VALUE_LVAL (array) != not_lval ++ && VALUE_LVAL (array) != lval_memory ++ && VALUE_LVAL (array) != lval_internalvar_component ++ && VALUE_LVAL (array) != lval_internalvar)) ++ error (_("value being subranged must be in memory")); ++ type = check_typedef (value_type (array)); ++ f_object_address_data_valid_or_error (type); ++ ++ copied_types = create_copied_types_hash (NULL); ++ type = copy_type_recursive (type, copied_types); ++ htab_delete (copied_types); ++ ++ if (nargs != calc_f77_array_dims (type)) ++ error (_("Wrong number of subscripts")); ++ ++ if (TYPE_DATA_LOCATION_IS_ADDR (type)) ++ { ++ value_byte_address = (TYPE_DATA_LOCATION_ADDR (type) ++ + value_offset (array)); ++ TYPE_DATA_LOCATION_IS_ADDR (type) = 0; ++ TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL; ++ } + else +- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); ++ { ++ gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL); ++ value_byte_address = value_address (array); ++ } ++ ++ new_array_type = type; ++ ++ subscript_array = alloca (sizeof (*subscript_array) * nargs); ++ ++ gdb_assert (nargs > 0); ++ ++ /* Now that we know we have a legal array subscript expression ++ let us actually find out where this element exists in the array. */ ++ ++ /* Take array indices left to right. */ ++ for (i = 0; i < nargs; i++) ++ { ++ struct subscript_index *index = &subscript_array[i]; ++ ++ if (exp->elts[*pos].opcode == OP_F90_RANGE) ++ { ++ int pc = (*pos) + 1; ++ struct subscript_range *range; ++ ++ index->kind = SUBSCRIPT_RANGE; ++ range = &index->range; ++ ++ *pos += 3; ++ range->f90_range_type = longest_to_int (exp->elts[pc].longconst); ++ ++ if (range->f90_range_type == HIGH_BOUND_DEFAULT ++ || range->f90_range_type == NONE_BOUND_DEFAULT) ++ range->low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, ++ pos, noside)); ++ ++ if (range->f90_range_type == LOW_BOUND_DEFAULT ++ || range->f90_range_type == NONE_BOUND_DEFAULT) ++ range->high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, ++ pos, noside)); ++ } ++ else ++ { ++ struct value *val; ++ ++ index->kind = SUBSCRIPT_NUMBER; + +- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) +- high_bound = TYPE_HIGH_BOUND (range); ++ /* Evaluate each subscript; it must be a legal integer in F77. */ ++ val = evaluate_subexp_with_coercion (exp, pos, noside); ++ index->number = value_as_long (val); ++ } ++ } ++ ++ /* Internal type of array is arranged right to left. */ ++ for (i = nargs - 1; i >= 0; i--) ++ { ++ struct subscript_index *index = &subscript_array[i]; ++ struct type *range_type = TYPE_INDEX_TYPE (type); ++ ++ switch (index->kind) ++ { ++ case SUBSCRIPT_RANGE: ++ { ++ struct subscript_range *range = &index->range; ++ CORE_ADDR byte_offset; ++ ++ if (range->f90_range_type == LOW_BOUND_DEFAULT ++ || range->f90_range_type == BOTH_BOUND_DEFAULT) ++ range->low_bound = TYPE_LOW_BOUND (range_type); ++ ++ if (range->f90_range_type == HIGH_BOUND_DEFAULT ++ || range->f90_range_type == BOTH_BOUND_DEFAULT) ++ range->high_bound = TYPE_HIGH_BOUND (range_type); ++ ++ if (range->low_bound < TYPE_LOW_BOUND (range_type) ++ || (!TYPE_HIGH_BOUND_UNDEFINED (range_type) ++ && range->high_bound > TYPE_HIGH_BOUND (range_type))) ++ error (_("slice out of range")); ++ ++ byte_offset = ((range->low_bound - TYPE_LOW_BOUND (range_type)) ++ * TYPE_ARRAY_BYTE_STRIDE_VALUE (type)); ++ TYPE_LOW_BOUND (range_type) = range->low_bound; ++ TYPE_HIGH_BOUND (range_type) = range->high_bound; ++ if (range->f90_range_type == LOW_BOUND_DEFAULT ++ || range->f90_range_type == NONE_BOUND_DEFAULT) ++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 0; ++ ++ typep = &TYPE_TARGET_TYPE (type); ++ value_byte_offset += byte_offset; ++ type = TYPE_TARGET_TYPE (type); ++ } ++ break; ++ ++ case SUBSCRIPT_NUMBER: ++ { ++ CORE_ADDR byte_offset; ++ ++ if (index->number < TYPE_LOW_BOUND (range_type) ++ || (!TYPE_HIGH_BOUND_UNDEFINED (range_type) ++ && index->number > TYPE_HIGH_BOUND (range_type))) ++ error (_("no such vector element")); ++ ++ byte_offset = ((index->number - TYPE_LOW_BOUND (range_type)) ++ * TYPE_ARRAY_BYTE_STRIDE_VALUE (type)); ++ ++ type = TYPE_TARGET_TYPE (type); ++ *typep = type; ++ value_byte_offset += byte_offset; ++ } ++ break; ++ } ++ } ++ ++ type_last_target = type; ++ type_array = alloca (sizeof (*type_array) * nargs); ++ i = 0; ++ for (type = new_array_type; type != type_last_target; ++ type = TYPE_TARGET_TYPE (type)) ++ type_array[i++] = type; ++ while (i > 0) ++ { ++ struct type *type = type_array[--i]; ++ ++ /* Force TYPE_LENGTH (type) recalculation. */ ++ TYPE_TARGET_STUB (type) = 1; ++ check_typedef (type); ++ } ++ ++ saved_array = array; ++ array = allocate_value_lazy (new_array_type); ++ VALUE_LVAL (array) = VALUE_LVAL (saved_array); ++ if (VALUE_LVAL (saved_array) == lval_internalvar_component) ++ VALUE_LVAL (array) = lval_internalvar; + else +- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); ++ VALUE_LVAL (array) = VALUE_LVAL (saved_array); ++ VALUE_FRAME_ID (array) = VALUE_FRAME_ID (saved_array); ++ if (VALUE_LVAL (array) != lval_internalvar) ++ set_value_address (array, value_byte_address + value_byte_offset); + +- return value_slice (array, low_bound, high_bound - low_bound + 1); ++ if (!value_lazy (saved_array)) ++ { ++ allocate_value_contents (array); ++ set_value_lazy (array, 0); ++ ++ memcpy (value_contents_writeable (array), ++ value_contents (saved_array) + value_byte_offset, ++ TYPE_LENGTH (new_array_type)); ++ } ++ ++ do_cleanups (old_chain); ++ return array; + } + + +@@ -790,6 +981,7 @@ evaluate_subexp_standard (struct type *e + int save_pos1; + struct symbol *function = NULL; + char *function_name = NULL; ++ struct cleanup *old_chain; + + pc = (*pos)++; + op = exp->elts[pc].opcode; +@@ -1862,6 +2054,8 @@ evaluate_subexp_standard (struct type *e + + /* First determine the type code we are dealing with. */ + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (arg1)); + type = check_typedef (value_type (arg1)); + code = TYPE_CODE (type); + +@@ -1882,23 +2076,13 @@ evaluate_subexp_standard (struct type *e + code = TYPE_CODE (type); + } + } ++ do_cleanups (old_chain); + + switch (code) + { + case TYPE_CODE_ARRAY: +- if (exp->elts[*pos].opcode == OP_F90_RANGE) +- return value_f90_subarray (arg1, exp, pos, noside); +- else +- goto multi_f77_subscript; +- + case TYPE_CODE_STRING: +- if (exp->elts[*pos].opcode == OP_F90_RANGE) +- return value_f90_subarray (arg1, exp, pos, noside); +- else +- { +- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); +- return value_subscript (arg1, value_as_long (arg2)); +- } ++ return value_f90_subarray (arg1, exp, pos, nargs, noside); + + case TYPE_CODE_PTR: + case TYPE_CODE_FUNC: +@@ -2337,49 +2521,6 @@ evaluate_subexp_standard (struct type *e + } + return (arg1); + +- multi_f77_subscript: +- { +- LONGEST subscript_array[MAX_FORTRAN_DIMS]; +- int ndimensions = 1, i; +- struct value *array = arg1; +- +- if (nargs > MAX_FORTRAN_DIMS) +- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); +- +- ndimensions = calc_f77_array_dims (type); +- +- if (nargs != ndimensions) +- error (_("Wrong number of subscripts")); +- +- gdb_assert (nargs > 0); +- +- /* Now that we know we have a legal array subscript expression +- let us actually find out where this element exists in the array. */ +- +- /* Take array indices left to right. */ +- for (i = 0; i < nargs; i++) +- { +- /* Evaluate each subscript; it must be a legal integer in F77. */ +- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); +- +- /* Fill in the subscript array. */ +- +- subscript_array[i] = value_as_long (arg2); +- } +- +- /* Internal type of array is arranged right to left. */ +- for (i = nargs; i > 0; i--) +- { +- struct type *array_type = check_typedef (value_type (array)); +- LONGEST index = subscript_array[i - 1]; +- +- lower = f77_get_lowerbound (array_type); +- array = value_subscripted_rvalue (array, index, lower); +- } +- +- return array; +- } +- + case BINOP_LOGICAL_AND: + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); + if (noside == EVAL_SKIP) +@@ -2611,15 +2752,23 @@ evaluate_subexp_standard (struct type *e + if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) + expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type)); + arg1 = evaluate_subexp (expect_type, exp, pos, noside); ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (arg1)); + type = check_typedef (value_type (arg1)); + if (TYPE_CODE (type) == TYPE_CODE_METHODPTR + || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR) + error (_("Attempt to dereference pointer " + "to member without an object")); + if (noside == EVAL_SKIP) +- goto nosideret; ++ { ++ do_cleanups (old_chain); ++ goto nosideret; ++ } + if (unop_user_defined_p (op, arg1)) +- return value_x_unop (arg1, op, noside); ++ { ++ do_cleanups (old_chain); ++ return value_x_unop (arg1, op, noside); ++ } + else if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + type = check_typedef (value_type (arg1)); +@@ -2628,12 +2777,18 @@ evaluate_subexp_standard (struct type *e + /* In C you can dereference an array to get the 1st elt. */ + || TYPE_CODE (type) == TYPE_CODE_ARRAY + ) +- return value_zero (TYPE_TARGET_TYPE (type), +- lval_memory); ++ { ++ do_cleanups (old_chain); ++ return value_zero (TYPE_TARGET_TYPE (type), ++ lval_memory); ++ } + else if (TYPE_CODE (type) == TYPE_CODE_INT) +- /* GDB allows dereferencing an int. */ +- return value_zero (builtin_type (exp->gdbarch)->builtin_int, +- lval_memory); ++ { ++ do_cleanups (old_chain); ++ /* GDB allows dereferencing an int. */ ++ return value_zero (builtin_type (exp->gdbarch)->builtin_int, ++ lval_memory); ++ } + else + error (_("Attempt to take contents of a non-pointer value.")); + } +@@ -2643,9 +2798,14 @@ evaluate_subexp_standard (struct type *e + do. "long long" variables are rare enough that + BUILTIN_TYPE_LONGEST would seem to be a mistake. */ + if (TYPE_CODE (type) == TYPE_CODE_INT) +- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, +- (CORE_ADDR) value_as_address (arg1)); +- return value_ind (arg1); ++ { ++ do_cleanups (old_chain); ++ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, ++ (CORE_ADDR) value_as_address (arg1)); ++ } ++ arg1 = value_ind (arg1); ++ do_cleanups (old_chain); ++ return arg1; + + case UNOP_ADDR: + /* C++: check for and handle pointer to members. */ +@@ -2987,7 +3147,7 @@ evaluate_subexp_with_coercion (struct ex + { + enum exp_opcode op; + int pc; +- struct value *val; ++ struct value *val = NULL; + struct symbol *var; + struct type *type; + +@@ -2998,13 +3158,18 @@ evaluate_subexp_with_coercion (struct ex + { + case OP_VAR_VALUE: + var = exp->elts[pc + 2].symbol; ++ /* address_of_variable will call object_address_set for check_typedef. ++ Call it only if required as it can error-out on VAR in register. */ ++ if (TYPE_DYNAMIC (SYMBOL_TYPE (var))) ++ val = address_of_variable (var, exp->elts[pc + 1].block); + type = check_typedef (SYMBOL_TYPE (var)); + if (TYPE_CODE (type) == TYPE_CODE_ARRAY + && !TYPE_VECTOR (type) + && CAST_IS_CONVERSION (exp->language_defn)) + { + (*pos) += 4; +- val = address_of_variable (var, exp->elts[pc + 1].block); ++ if (!val) ++ val = address_of_variable (var, exp->elts[pc + 1].block); + return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), + val); + } +@@ -3056,9 +3221,13 @@ evaluate_subexp_for_sizeof (struct expre + + case OP_VAR_VALUE: + (*pos) += 4; +- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol)); +- return +- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); ++ /* We do not need to call read_var_value but the object evaluation may ++ need to have executed object_address_set which needs valid ++ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by ++ read_var_value we left as lazy. */ ++ type = value_type (read_var_value (exp->elts[pc + 2].symbol, ++ deprecated_safe_get_selected_frame ())); ++ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); + + default: + val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); +@@ -3089,18 +3258,25 @@ parse_and_eval_type (char *p, int length + int + calc_f77_array_dims (struct type *array_type) + { +- int ndimen = 1; +- struct type *tmp_type; ++ switch (TYPE_CODE (array_type)) ++ { ++ case TYPE_CODE_STRING: ++ return 1; + +- if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY)) +- error (_("Can't get dimensions for a non-array type")); ++ case TYPE_CODE_ARRAY: ++ { ++ int ndimen = 1; + +- tmp_type = array_type; ++ while ((array_type = TYPE_TARGET_TYPE (array_type))) ++ { ++ if (TYPE_CODE (array_type) == TYPE_CODE_ARRAY) ++ ++ndimen; ++ } ++ return ndimen; ++ } + +- while ((tmp_type = TYPE_TARGET_TYPE (tmp_type))) +- { +- if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY) +- ++ndimen; ++ default: ++ error (_("Can't get dimensions for a non-array/non-string type")); + } +- return ndimen; ++ + } +Index: gdb-7.3.50.20110722/gdb/f-exp.y +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-exp.y 2011-04-19 20:04:07.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-exp.y 2011-07-29 22:52:02.000000000 +0200 +@@ -293,7 +293,9 @@ arglist : subrange + { arglist_len = 1; } + ; + +-arglist : arglist ',' exp %prec ABOVE_COMMA ++arglist : arglist ',' exp %prec ABOVE_COMMA ++ { arglist_len++; } ++ | arglist ',' subrange %prec ABOVE_COMMA + { arglist_len++; } + ; + +Index: gdb-7.3.50.20110722/gdb/f-lang.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-lang.h 2011-01-07 20:36:16.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/f-lang.h 2011-07-29 22:52:02.000000000 +0200 +@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined + extern void f_print_type (struct type *, const char *, struct ui_file *, int, + int); + ++extern const char *f_object_address_data_valid_print_to_stream ++ (struct type *type, struct ui_file *stream); ++extern void f_object_address_data_valid_or_error (struct type *type); ++ + extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR, + struct ui_file *, int, + const struct value *, +Index: gdb-7.3.50.20110722/gdb/f-typeprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-typeprint.c 2011-06-29 17:32:39.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-typeprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -32,7 +32,7 @@ + #include "gdbcore.h" + #include "target.h" + #include "f-lang.h" +- ++#include "dwarf2loc.h" + #include "gdb_string.h" + #include + +@@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct + void f_type_print_base (struct type *, struct ui_file *, int, int); + + ++const char * ++f_object_address_data_valid_print_to_stream (struct type *type, ++ struct ui_file *stream) ++{ ++ const char *msg; ++ ++ msg = object_address_data_not_valid (type); ++ if (msg != NULL) ++ { ++ /* Assuming the content printed to STREAM should not be localized. */ ++ fprintf_filtered (stream, "<%s>", msg); ++ } ++ ++ return msg; ++} ++ ++void ++f_object_address_data_valid_or_error (struct type *type) ++{ ++ const char *msg; ++ ++ msg = object_address_data_not_valid (type); ++ if (msg != NULL) ++ { ++ error (_("Cannot access it because the %s."), _(msg)); ++ } ++} ++ + /* LEVEL is the depth to indent lines by. */ + + void +@@ -58,6 +86,9 @@ f_print_type (struct type *type, const c + enum type_code code; + int demangled_args; + ++ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL) ++ return; ++ + f_type_print_base (type, stream, show, level); + code = TYPE_CODE (type); + if ((varstring != NULL && *varstring != '\0') +@@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type + + QUIT; + ++ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF) ++ CHECK_TYPEDEF (type); ++ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_ARRAY: +Index: gdb-7.3.50.20110722/gdb/f-valprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-valprint.c 2011-06-29 17:32:39.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-valprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM + /* The following macro gives us the size of the nth dimension, Where + n is 1 based. */ + +-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1]) ++#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1]) + +-/* The following gives us the offset for row n where n is 1-based. */ ++/* The following gives us the element size for row n where n is 1-based. */ + +-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0]) ++#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0]) + + int + f77_get_lowerbound (struct type *type) + { ++ f_object_address_data_valid_or_error (type); ++ + if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type)) + error (_("Lower bound may not be '*' in F77")); + +@@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type) + int + f77_get_upperbound (struct type *type) + { ++ f_object_address_data_valid_or_error (type); ++ + if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) + { +- /* We have an assumed size array on our hands. Assume that +- upper_bound == lower_bound so that we show at least 1 element. +- If the user wants to see more elements, let him manually ask for 'em +- and we'll subscript the array and show him. */ ++ /* We have an assumed size array on our hands. As type_length_get ++ already assumes a length zero of arrays with underfined bounds VALADDR ++ passed to the Fortran functions does not contained the real inferior ++ memory content. User should request printing of specific array ++ elements instead. */ + +- return f77_get_lowerbound (type); ++ return f77_get_lowerbound (type) - 1; + } + + return TYPE_ARRAY_UPPER_BOUND_VALUE (type); +@@ -135,24 +140,29 @@ f77_create_arrayprint_offset_tbl (struct + upper = f77_get_upperbound (tmp_type); + lower = f77_get_lowerbound (tmp_type); + +- F77_DIM_SIZE (ndimen) = upper - lower + 1; ++ F77_DIM_COUNT (ndimen) = upper - lower + 1; ++ ++ F77_DIM_BYTE_STRIDE (ndimen) = ++ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type); + + tmp_type = TYPE_TARGET_TYPE (tmp_type); + ndimen++; + } + +- /* Now we multiply eltlen by all the offsets, so that later we ++ /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we + can print out array elements correctly. Up till now we +- know an offset to apply to get the item but we also ++ know an eltlen to apply to get the item but we also + have to know how much to add to get to the next item. */ + + ndimen--; + eltlen = TYPE_LENGTH (tmp_type); +- F77_DIM_OFFSET (ndimen) = eltlen; ++ if (F77_DIM_BYTE_STRIDE (ndimen) == 0) ++ F77_DIM_BYTE_STRIDE (ndimen) = eltlen; + while (--ndimen > 0) + { +- eltlen *= F77_DIM_SIZE (ndimen + 1); +- F77_DIM_OFFSET (ndimen) = eltlen; ++ eltlen *= F77_DIM_COUNT (ndimen + 1); ++ if (F77_DIM_BYTE_STRIDE (ndimen) == 0) ++ F77_DIM_BYTE_STRIDE (ndimen) = eltlen; + } + } + +@@ -174,37 +184,35 @@ f77_print_array_1 (int nss, int ndimensi + + if (nss != ndimensions) + { +- for (i = 0; +- (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); +- i++) ++ for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++) + { + fprintf_filtered (stream, "( "); + f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type), + valaddr, +- embedded_offset + i * F77_DIM_OFFSET (nss), ++ embedded_offset + i * F77_DIM_BYTE_STRIDE (nss), + address, + stream, recurse, val, options, elts); + fprintf_filtered (stream, ") "); + } +- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) ++ if (*elts >= options->print_max && i < F77_DIM_COUNT (nss)) + fprintf_filtered (stream, "..."); + } + else + { +- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max; ++ for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max; + i++, (*elts)++) + { + val_print (TYPE_TARGET_TYPE (type), + valaddr, +- embedded_offset + i * F77_DIM_OFFSET (ndimensions), ++ embedded_offset + i * F77_DIM_BYTE_STRIDE (ndimensions), + address, stream, recurse, + val, options, current_language); + +- if (i != (F77_DIM_SIZE (nss) - 1)) ++ if (i != (F77_DIM_COUNT (nss) - 1)) + fprintf_filtered (stream, ", "); + + if ((*elts == options->print_max - 1) +- && (i != (F77_DIM_SIZE (nss) - 1))) ++ && (i != (F77_DIM_COUNT (nss) - 1))) + fprintf_filtered (stream, "..."); + } + } +@@ -260,6 +268,9 @@ f_val_print (struct type *type, const gd + CORE_ADDR addr; + int index; + ++ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL) ++ return 0; ++ + CHECK_TYPEDEF (type); + switch (TYPE_CODE (type)) + { +Index: gdb-7.3.50.20110722/gdb/findvar.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/findvar.c 2011-07-12 23:16:48.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/findvar.c 2011-07-29 22:52:44.000000000 +0200 +@@ -35,6 +35,7 @@ + #include "user-regs.h" + #include "block.h" + #include "objfiles.h" ++#include "dwarf2loc.h" + + /* Basic byte-swapping routines. All 'extract' functions return a + host-format integer from a target-format integer at ADDR which is +@@ -408,8 +409,11 @@ symbol_read_needs_frame (struct symbol * + + /* Given a struct symbol for a variable, + and a stack frame id, read the value of the variable +- and return a (pointer to a) struct value containing the value. +- If the variable cannot be found, return a zero pointer. */ ++ and return a (pointer to a) struct value containing the value. ++ If the variable cannot be found, return a zero pointer. ++ We have to first find the address of the variable before allocating struct ++ value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly ++ used by its type. */ + + struct value * + read_var_value (struct symbol *var, struct frame_info *frame) +@@ -417,16 +421,6 @@ read_var_value (struct symbol *var, stru + struct value *v; + struct type *type = SYMBOL_TYPE (var); + CORE_ADDR addr; +- int len; +- +- /* Call check_typedef on our type to make sure that, if TYPE is +- a TYPE_CODE_TYPEDEF, its length is set to the length of the target type +- instead of zero. However, we do not replace the typedef type by the +- target type, because we want to keep the typedef in order to be able to +- set the returned value type description correctly. */ +- check_typedef (type); +- +- len = TYPE_LENGTH (type); + + if (symbol_read_needs_frame (var)) + gdb_assert (frame); +@@ -436,7 +430,7 @@ read_var_value (struct symbol *var, stru + case LOC_CONST: + /* Put the constant back in target format. */ + v = allocate_value (type); +- store_signed_integer (value_contents_raw (v), len, ++ store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type), + gdbarch_byte_order (get_type_arch (type)), + (LONGEST) SYMBOL_VALUE (var)); + VALUE_LVAL (v) = not_lval; +@@ -461,12 +455,12 @@ read_var_value (struct symbol *var, stru + + case LOC_CONST_BYTES: + v = allocate_value (type); +- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len); ++ memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), ++ TYPE_LENGTH (type)); + VALUE_LVAL (v) = not_lval; + return v; + + case LOC_STATIC: +- v = allocate_value_lazy (type); + if (overlay_debugging) + addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), + SYMBOL_OBJ_SECTION (var)); +@@ -479,7 +473,6 @@ read_var_value (struct symbol *var, stru + if (!addr) + return 0; + addr += SYMBOL_VALUE (var); +- v = allocate_value_lazy (type); + break; + + case LOC_REF_ARG: +@@ -493,14 +486,12 @@ read_var_value (struct symbol *var, stru + argref += SYMBOL_VALUE (var); + ref = value_at (lookup_pointer_type (type), argref); + addr = value_as_address (ref); +- v = allocate_value_lazy (type); + break; + } + + case LOC_LOCAL: + addr = get_frame_locals_address (frame); + addr += SYMBOL_VALUE (var); +- v = allocate_value_lazy (type); + break; + + case LOC_TYPEDEF: +@@ -508,7 +499,6 @@ read_var_value (struct symbol *var, stru + break; + + case LOC_BLOCK: +- v = allocate_value_lazy (type); + if (overlay_debugging) + addr = symbol_overlayed_address + (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)); +@@ -533,7 +523,6 @@ read_var_value (struct symbol *var, stru + error (_("Value of register variable not available.")); + + addr = value_as_address (regval); +- v = allocate_value_lazy (type); + } + else + { +@@ -572,7 +561,6 @@ read_var_value (struct symbol *var, stru + if (obj_section + && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) + addr = target_translate_tls_address (obj_section->objfile, addr); +- v = allocate_value_lazy (type); + } + break; + +@@ -584,6 +572,10 @@ read_var_value (struct symbol *var, stru + break; + } + ++ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for ++ DW_OP_PUSH_OBJECT_ADDRESS. */ ++ object_address_set (addr); ++ v = allocate_value_lazy (type); + VALUE_LVAL (v) = lval_memory; + set_value_address (v, addr); + return v; +@@ -623,11 +615,12 @@ struct value * + value_from_register (struct type *type, int regnum, struct frame_info *frame) + { + struct gdbarch *gdbarch = get_frame_arch (frame); +- struct type *type1 = check_typedef (type); + struct value *v; + int optim, unavail, ok; + +- if (gdbarch_convert_register_p (gdbarch, regnum, type1)) ++ type = check_typedef (type); ++ ++ if (gdbarch_convert_register_p (gdbarch, regnum, type)) + { + /* The ISA/ABI need to something weird when obtaining the + specified value from this register. It might need to +@@ -640,7 +633,7 @@ value_from_register (struct type *type, + VALUE_LVAL (v) = lval_register; + VALUE_FRAME_ID (v) = get_frame_id (frame); + VALUE_REGNUM (v) = regnum; +- ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1, ++ ok = gdbarch_register_to_value (gdbarch, frame, regnum, type, + value_contents_raw (v), &optim, + &unavail); + } +Index: gdb-7.3.50.20110722/gdb/gdbinit.in +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/gdbinit.in 2009-10-05 15:46:52.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/gdbinit.in 2011-07-29 22:52:02.000000000 +0200 +@@ -1,5 +1,15 @@ + echo Setting up the environment for debugging gdb.\n + ++# Set up the Python library and "require" command. ++python ++from os.path import abspath ++gdb.datadir = abspath ('@srcdir@/python/lib') ++gdb.pythonlibdir = gdb.datadir ++gdb.__path__ = [gdb.datadir + '/gdb'] ++sys.path.insert(0, gdb.datadir) ++end ++source @srcdir@/python/lib/gdb/__init__.py ++ + set complaints 1 + + b internal_error +Index: gdb-7.3.50.20110722/gdb/gdbtypes.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/gdbtypes.c 2011-06-24 21:47:37.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/gdbtypes.c 2011-07-29 22:52:02.000000000 +0200 +@@ -39,6 +39,9 @@ + #include "cp-abi.h" + #include "gdb_assert.h" + #include "hashtab.h" ++#include "observer.h" ++#include "dwarf2expr.h" ++#include "dwarf2loc.h" + + + /* Initialize BADNESS constants. */ +@@ -144,7 +147,16 @@ static void print_bit_vector (B_TYPE *, + static void print_arg_types (struct field *, int, int); + static void dump_fn_fieldlists (struct type *, int); + static void print_cplus_stuff (struct type *, int); ++static LONGEST type_length_get (struct type *type, struct type *target_type, ++ int full_span); + ++#if 0 ++/* The hash table holding all discardable `struct type *' references. */ ++static htab_t type_discardable_table; ++ ++/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */ ++static int type_discardable_age_current; ++#endif + + /* Allocate a new OBJFILE-associated type structure and fill it + with some defaults. Space for the type structure is allocated +@@ -175,6 +187,43 @@ alloc_type (struct objfile *objfile) + return type; + } + ++#if 0 ++/* Declare TYPE as discardable on next garbage collection by free_all_types. ++ You must call type_mark_used during each free_all_types to protect TYPE from ++ being deallocated. */ ++ ++static void ++set_type_as_discardable (struct type *type) ++{ ++ void **slot; ++ ++ gdb_assert (!TYPE_DISCARDABLE (type)); ++ ++ TYPE_DISCARDABLE (type) = 1; ++ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current; ++ ++ slot = htab_find_slot (type_discardable_table, type, INSERT); ++ gdb_assert (!*slot); ++ *slot = type; ++} ++#endif ++ ++/* Allocate a new type like alloc_type but preserve for it the discardability ++ state of PARENT_TYPE. */ ++ ++static struct type * ++alloc_type_as_parent (struct type *parent_type) ++{ ++ struct type *new_type = alloc_type_copy (parent_type); ++ ++#if 0 ++ if (TYPE_DISCARDABLE (parent_type)) ++ set_type_as_discardable (new_type); ++#endif ++ ++ return new_type; ++} ++ + /* Allocate a new GDBARCH-associated type structure and fill it + with some defaults. Space for the type structure is allocated + on the heap. */ +@@ -300,7 +349,7 @@ make_pointer_type (struct type *type, st + + if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ + { +- ntype = alloc_type_copy (type); ++ ntype = alloc_type_as_parent (type); + if (typeptr) + *typeptr = ntype; + } +@@ -377,7 +426,7 @@ make_reference_type (struct type *type, + + if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ + { +- ntype = alloc_type_copy (type); ++ ntype = alloc_type_as_parent (type); + if (typeptr) + *typeptr = ntype; + } +@@ -748,6 +797,7 @@ create_range_type (struct type *result_t + TYPE_ZALLOC (result_type, sizeof (struct range_bounds)); + TYPE_LOW_BOUND (result_type) = low_bound; + TYPE_HIGH_BOUND (result_type) = high_bound; ++ TYPE_BYTE_STRIDE (result_type) = 0; + + if (low_bound >= 0) + TYPE_UNSIGNED (result_type) = 1; +@@ -891,26 +941,31 @@ create_array_type (struct type *result_t + + TYPE_CODE (result_type) = TYPE_CODE_ARRAY; + TYPE_TARGET_TYPE (result_type) = element_type; +- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) +- low_bound = high_bound = 0; +- CHECK_TYPEDEF (element_type); +- /* Be careful when setting the array length. Ada arrays can be +- empty arrays with the high_bound being smaller than the low_bound. +- In such cases, the array length should be zero. */ +- if (high_bound < low_bound) +- TYPE_LENGTH (result_type) = 0; +- else +- TYPE_LENGTH (result_type) = +- TYPE_LENGTH (element_type) * (high_bound - low_bound + 1); + TYPE_NFIELDS (result_type) = 1; + TYPE_FIELDS (result_type) = + (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)); + TYPE_INDEX_TYPE (result_type) = range_type; + TYPE_VPTR_FIELDNO (result_type) = -1; + +- /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays. */ ++ /* DWARF blocks may depend on runtime information like ++ DW_OP_PUSH_OBJECT_ADDRESS not being available during the ++ CREATE_ARRAY_TYPE time. */ ++ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT ++ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT ++ || TYPE_DYNAMIC (element_type)) ++ TYPE_LENGTH (result_type) = 0; ++ else ++ { ++ CHECK_TYPEDEF (element_type); ++ TYPE_LENGTH (result_type) = type_length_get (result_type, element_type, ++ 0); ++ } + if (TYPE_LENGTH (result_type) == 0) +- TYPE_TARGET_STUB (result_type) = 1; ++ { ++ /* The real size will be computed for specific instances by ++ CHECK_TYPEDEF. */ ++ TYPE_TARGET_STUB (result_type) = 1; ++ } + + return result_type; + } +@@ -1439,6 +1494,105 @@ stub_noname_complaint (void) + complaint (&symfile_complaints, _("stub type has NULL name")); + } + ++/* Calculate the memory length of array TYPE. ++ ++ TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as ++ a performance hint. Feel free to pass NULL. Set FULL_SPAN to return the ++ size incl. the possible padding of the last element - it may differ from the ++ cleared FULL_SPAN return value (the expected SIZEOF) for non-zero ++ TYPE_BYTE_STRIDE values. */ ++ ++static LONGEST ++type_length_get (struct type *type, struct type *target_type, int full_span) ++{ ++ struct type *range_type; ++ LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */ ++ LONGEST count, element_size, retval; ++ ++ if (TYPE_CODE (type) != TYPE_CODE_ARRAY ++ && TYPE_CODE (type) != TYPE_CODE_STRING) ++ return TYPE_LENGTH (type); ++ ++ /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated) ++ Fortran arrays. The allocated data will never be used so they can be ++ zero-length. */ ++ if (object_address_data_not_valid (type)) ++ return 0; ++ ++ range_type = TYPE_INDEX_TYPE (type); ++ if (TYPE_LOW_BOUND_UNDEFINED (range_type) ++ || TYPE_HIGH_BOUND_UNDEFINED (range_type)) ++ return 0; ++ count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1; ++ /* It may happen for wrong DWARF annotations returning garbage data. */ ++ if (count < 0) ++ warning (_("Range for type %s has invalid bounds %s..%s"), ++ TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)), ++ plongest (TYPE_HIGH_BOUND (range_type))); ++ /* The code below does not handle count == 0 right. */ ++ if (count <= 0) ++ return 0; ++ if (full_span || count > 1) ++ { ++ /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to ++ force FULL_SPAN to 1. */ ++ byte_stride = TYPE_BYTE_STRIDE (range_type); ++ if (byte_stride == 0) ++ { ++ if (target_type == NULL) ++ target_type = check_typedef (TYPE_TARGET_TYPE (type)); ++ byte_stride = type_length_get (target_type, NULL, 1); ++ } ++ } ++ ++ /* For now, we conservatively take the array length to be 0 if its length ++ exceeds UINT_MAX. The code below assumes that for x < 0, ++ (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed ++ by C, but is usually true (because it would be true if x were unsigned ++ with its high-order bit on). It uses the fact that high_bound-low_bound is ++ always representable in ULONGEST and that if high_bound-low_bound+1 ++ overflows, it overflows to 0. We must change these tests if we decide to ++ increase the representation of TYPE_LENGTH from unsigned int to ULONGEST. ++ */ ++ ++ if (full_span) ++ { ++ retval = count * byte_stride; ++ if (count == 0 || retval / count != byte_stride || retval > UINT_MAX) ++ retval = 0; ++ return retval; ++ } ++ if (target_type == NULL) ++ target_type = check_typedef (TYPE_TARGET_TYPE (type)); ++ element_size = type_length_get (target_type, NULL, 1); ++ retval = (count - 1) * byte_stride + element_size; ++ if (retval < element_size ++ || (byte_stride != 0 ++ && (retval - element_size) / byte_stride != count - 1) ++ || retval > UINT_MAX) ++ retval = 0; ++ return retval; ++} ++ ++/* Prepare TYPE after being read in by the backend. Currently this function ++ only propagates the TYPE_DYNAMIC flag. */ ++ ++void ++finalize_type (struct type *type) ++{ ++ int i; ++ ++ for (i = 0; i < TYPE_NFIELDS (type); ++i) ++ if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i))) ++ break; ++ ++ /* FIXME: cplus_stuff is ignored here. */ ++ if (i < TYPE_NFIELDS (type) ++ || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type))) ++ || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type)))) ++ TYPE_DYNAMIC (type) = 1; ++} ++ + /* Find the real type of TYPE. This function returns the real type, + after removing all layers of typedefs, and completing opaque or stub + types. Completion changes the TYPE argument, but stripping of +@@ -1601,52 +1755,37 @@ check_typedef (struct type *type) + } + } + +- if (TYPE_TARGET_STUB (type)) ++ /* copy_type_recursive automatically makes the resulting type containing only ++ constant values expected by the callers of this function. */ ++ if (TYPE_DYNAMIC (type)) ++ { ++ htab_t copied_types; ++ ++ copied_types = create_copied_types_hash (NULL); ++ type = copy_type_recursive (type, copied_types); ++ htab_delete (copied_types); ++ ++ gdb_assert (TYPE_DYNAMIC (type) == 0); ++ /* Force TYPE_LENGTH (type) recalculation. */ ++ TYPE_DYNAMIC (type) = 1; ++ } ++ ++ if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type)) + { +- struct type *range_type; + struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)); + ++ if (TYPE_DYNAMIC (type)) ++ TYPE_TARGET_TYPE (type) = target_type; + if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type)) + { + /* Nothing we can do. */ + } + else if (TYPE_CODE (type) == TYPE_CODE_ARRAY +- && TYPE_NFIELDS (type) == 1 +- && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type)) +- == TYPE_CODE_RANGE)) ++ || TYPE_CODE (type) == TYPE_CODE_STRING) + { + /* Now recompute the length of the array type, based on its +- number of elements and the target type's length. +- Watch out for Ada null Ada arrays where the high bound +- is smaller than the low bound. */ +- const LONGEST low_bound = TYPE_LOW_BOUND (range_type); +- const LONGEST high_bound = TYPE_HIGH_BOUND (range_type); +- ULONGEST len; +- +- if (high_bound < low_bound) +- len = 0; +- else +- { +- /* For now, we conservatively take the array length to be 0 +- if its length exceeds UINT_MAX. The code below assumes +- that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1, +- which is technically not guaranteed by C, but is usually true +- (because it would be true if x were unsigned with its +- high-order bit on). It uses the fact that +- high_bound-low_bound is always representable in +- ULONGEST and that if high_bound-low_bound+1 overflows, +- it overflows to 0. We must change these tests if we +- decide to increase the representation of TYPE_LENGTH +- from unsigned int to ULONGEST. */ +- ULONGEST ulow = low_bound, uhigh = high_bound; +- ULONGEST tlen = TYPE_LENGTH (target_type); +- +- len = tlen * (uhigh - ulow + 1); +- if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh +- || len > UINT_MAX) +- len = 0; +- } +- TYPE_LENGTH (type) = len; ++ number of elements and the target type's length. */ ++ TYPE_LENGTH (type) = type_length_get (type, target_type, 0); + TYPE_TARGET_STUB (type) = 0; + } + else if (TYPE_CODE (type) == TYPE_CODE_RANGE) +@@ -1654,6 +1793,7 @@ check_typedef (struct type *type) + TYPE_LENGTH (type) = TYPE_LENGTH (target_type); + TYPE_TARGET_STUB (type) = 0; + } ++ TYPE_DYNAMIC (type) = 0; + } + + type = make_qualified_type (type, instance_flags, NULL); +@@ -3292,33 +3432,42 @@ type_pair_eq (const void *item_lhs, cons + } + + /* Allocate the hash table used by copy_type_recursive to walk +- types without duplicates. We use OBJFILE's obstack, because +- OBJFILE is about to be deleted. */ ++ types without duplicates. */ + + htab_t + create_copied_types_hash (struct objfile *objfile) + { +- return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq, +- NULL, &objfile->objfile_obstack, +- hashtab_obstack_allocate, +- dummy_obstack_deallocate); ++ if (objfile == NULL) ++ { ++ /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in ++ OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN. Table ++ element entries get allocated by xmalloc - so use xfree. */ ++ return htab_create (1, type_pair_hash, type_pair_eq, xfree); ++ } ++ else ++ { ++ /* Use OBJFILE's obstack, because OBJFILE is about to be deleted. Table ++ element entries get allocated by xmalloc - so use xfree. */ ++ return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq, ++ xfree, &objfile->objfile_obstack, ++ hashtab_obstack_allocate, ++ dummy_obstack_deallocate); ++ } + } + +-/* Recursively copy (deep copy) TYPE, if it is associated with +- OBJFILE. Return a new type allocated using malloc, a saved type if +- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is +- not associated with OBJFILE. */ ++/* A helper for copy_type_recursive. This does all the work. OBJFILE is used ++ only for an assertion checking. */ + +-struct type * +-copy_type_recursive (struct objfile *objfile, +- struct type *type, +- htab_t copied_types) ++static struct type * ++copy_type_recursive_1 (struct objfile *objfile, ++ struct type *type, ++ htab_t copied_types) + { + struct type_pair *stored, pair; + void **slot; + struct type *new_type; + +- if (! TYPE_OBJFILE_OWNED (type)) ++ if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type)) + return type; + + /* This type shouldn't be pointing to any types in other objfiles; +@@ -3333,9 +3482,10 @@ copy_type_recursive (struct objfile *obj + new_type = alloc_type_arch (get_type_arch (type)); + + /* We must add the new type to the hash table immediately, in case +- we encounter this type again during a recursive call below. */ +- stored +- = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair)); ++ we encounter this type again during a recursive call below. Memory could ++ be allocated from OBJFILE in the case we will be removing OBJFILE, this ++ optimization is missed and xfree is called for it from COPIED_TYPES. */ ++ stored = xmalloc (sizeof (*stored)); + stored->old = type; + stored->new = new_type; + *slot = stored; +@@ -3346,6 +3496,21 @@ copy_type_recursive (struct objfile *obj + TYPE_OBJFILE_OWNED (new_type) = 0; + TYPE_OWNER (new_type).gdbarch = get_type_arch (type); + ++#if 0 ++ /* TYPE_MAIN_TYPE memory copy above rewrote the TYPE_DISCARDABLE flag so we ++ need to initialize it again. And even if TYPE was already discardable ++ NEW_TYPE so far is not registered in TYPE_DISCARDABLE_TABLE. */ ++ TYPE_DISCARDABLE (new_type) = 0; ++ set_type_as_discardable (new_type); ++#endif ++ ++ /* Pre-clear the fields processed by delete_main_type. If DWARF block ++ evaluations below call error we would leave an unfreeable TYPE. */ ++ TYPE_TARGET_TYPE (new_type) = NULL; ++ TYPE_VPTR_BASETYPE (new_type) = NULL; ++ TYPE_NFIELDS (new_type) = 0; ++ TYPE_FIELDS (new_type) = NULL; ++ + if (TYPE_NAME (type)) + TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); + if (TYPE_TAG_NAME (type)) +@@ -3354,12 +3519,48 @@ copy_type_recursive (struct objfile *obj + TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); + TYPE_LENGTH (new_type) = TYPE_LENGTH (type); + ++ if (TYPE_ALLOCATED (new_type)) ++ { ++ gdb_assert (!TYPE_NOT_ALLOCATED (new_type)); ++ ++ if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type))) ++ TYPE_NOT_ALLOCATED (new_type) = 1; ++ TYPE_ALLOCATED (new_type) = NULL; ++ } ++ ++ if (TYPE_ASSOCIATED (new_type)) ++ { ++ gdb_assert (!TYPE_NOT_ASSOCIATED (new_type)); ++ ++ if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type))) ++ TYPE_NOT_ASSOCIATED (new_type) = 1; ++ TYPE_ASSOCIATED (new_type) = NULL; ++ } ++ ++ if (!TYPE_DATA_LOCATION_IS_ADDR (new_type) ++ && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type)) ++ { ++ if (TYPE_NOT_ALLOCATED (new_type) ++ || TYPE_NOT_ASSOCIATED (new_type)) ++ TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL; ++ else ++ { ++ TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1; ++ TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type)); ++ } ++ } ++ + /* Copy the fields. */ + if (TYPE_NFIELDS (type)) + { + int i, nfields; + ++ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */ ++ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE); ++ + nfields = TYPE_NFIELDS (type); ++ TYPE_NFIELDS (new_type) = nfields; + TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); + for (i = 0; i < nfields; i++) + { +@@ -3368,8 +3569,8 @@ copy_type_recursive (struct objfile *obj + TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i); + if (TYPE_FIELD_TYPE (type, i)) + TYPE_FIELD_TYPE (new_type, i) +- = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i), +- copied_types); ++ = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i), ++ copied_types); + if (TYPE_FIELD_NAME (type, i)) + TYPE_FIELD_NAME (new_type, i) = + xstrdup (TYPE_FIELD_NAME (type, i)); +@@ -3396,24 +3597,184 @@ copy_type_recursive (struct objfile *obj + } + } + ++ /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were ++ possibly converted. */ ++ TYPE_DYNAMIC (new_type) = 0; ++ + /* For range types, copy the bounds information. */ +- if (TYPE_CODE (type) == TYPE_CODE_RANGE) ++ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE) + { + TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds)); + *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type); ++ ++ switch (TYPE_RANGE_DATA (new_type)->low.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } ++ else ++ { ++ TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block); ++ if (TYPE_LOW_BOUND (new_type) >= 0) ++ TYPE_UNSIGNED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr)) ++ { ++ TYPE_LOW_BOUND (new_type) = addr; ++ if (TYPE_LOW_BOUND (new_type) >= 0) ++ TYPE_UNSIGNED (new_type) = 1; ++ } ++ else ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ switch (TYPE_RANGE_DATA (new_type)->high.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } ++ else ++ TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block); ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type, ++ &addr)) ++ TYPE_HIGH_BOUND (new_type) = addr; ++ else ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ TYPE_BYTE_STRIDE (new_type) = 0; ++ else ++ TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block); ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr = 0; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()) ++ dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type, ++ &addr); ++ TYPE_BYTE_STRIDE (new_type) = addr; ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */ ++ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type)) ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) ++ + TYPE_HIGH_BOUND (new_type) - 1; ++ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0; ++ } + } + + /* Copy pointers to other types. */ + if (TYPE_TARGET_TYPE (type)) + TYPE_TARGET_TYPE (new_type) = +- copy_type_recursive (objfile, +- TYPE_TARGET_TYPE (type), +- copied_types); ++ copy_type_recursive_1 (objfile, ++ TYPE_TARGET_TYPE (type), ++ copied_types); + if (TYPE_VPTR_BASETYPE (type)) + TYPE_VPTR_BASETYPE (new_type) = +- copy_type_recursive (objfile, +- TYPE_VPTR_BASETYPE (type), +- copied_types); ++ copy_type_recursive_1 (objfile, ++ TYPE_VPTR_BASETYPE (type), ++ copied_types); ++ ++ if (TYPE_CODE (new_type) == TYPE_CODE_ARRAY) ++ { ++ struct type *new_index_type = TYPE_INDEX_TYPE (new_type); ++ ++ if (TYPE_BYTE_STRIDE (new_index_type) == 0) ++ TYPE_BYTE_STRIDE (new_index_type) ++ = TYPE_LENGTH (TYPE_TARGET_TYPE (new_type)); ++ } ++ + /* Maybe copy the type_specific bits. + + NOTE drow/2005-12-09: We do not copy the C++-specific bits like +@@ -3430,6 +3791,17 @@ copy_type_recursive (struct objfile *obj + return new_type; + } + ++/* Recursively copy (deep copy) TYPE. Return a new type allocated using ++ malloc, a saved type if we have already visited TYPE (using COPIED_TYPES), ++ or TYPE if it is not associated with OBJFILE. */ ++ ++struct type * ++copy_type_recursive (struct type *type, ++ htab_t copied_types) ++{ ++ return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types); ++} ++ + /* Make a copy of the given TYPE, except that the pointer & reference + types are not preserved. + +@@ -3452,6 +3824,201 @@ copy_type (const struct type *type) + return new_type; + } + ++#if 0 ++/* Callback type for main_type_crawl. */ ++typedef int (*main_type_crawl_iter) (struct type *type, void *data); ++ ++/* Iterate all main_type structures reachable through any `struct type *' from ++ TYPE. ITER will be called only for one type of each main_type, use ++ TYPE_CHAIN traversal to find all the type instances. ITER is being called ++ for each main_type found. ITER returns non-zero if main_type_crawl should ++ depth-first enter the specific type. ITER must provide some detection for ++ reentering the same main_type as this function would otherwise endlessly ++ loop. */ ++ ++static void ++main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data) ++{ ++ struct type *type_iter; ++ int i; ++ ++ if (!type) ++ return; ++ ++ gdb_assert (TYPE_OBJFILE (type) == NULL); ++ ++ /* `struct cplus_struct_type' handling is unsupported by this function. */ ++ gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT ++ && TYPE_CODE (type) != TYPE_CODE_UNION) ++ || !HAVE_CPLUS_STRUCT (type)); ++ ++ if (!(*iter) (type, data)) ++ return; ++ ++ /* Iterate all the type instances of this main_type. */ ++ type_iter = type; ++ do ++ { ++ gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type)); ++ ++ main_type_crawl (TYPE_POINTER_TYPE (type), iter, data); ++ main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data); ++ ++ type_iter = TYPE_CHAIN (type_iter); ++ } ++ while (type_iter != type); ++ ++ for (i = 0; i < TYPE_NFIELDS (type); i++) ++ main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data); ++ ++ main_type_crawl (TYPE_TARGET_TYPE (type), iter, data); ++ main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data); ++} ++ ++/* A helper for delete_type which deletes a main_type and the things to which ++ it refers. TYPE is a type whose main_type we wish to destroy. */ ++ ++static void ++delete_main_type (struct type *type) ++{ ++ int i; ++ ++ gdb_assert (TYPE_DISCARDABLE (type)); ++ gdb_assert (TYPE_OBJFILE (type) == NULL); ++ ++ xfree (TYPE_NAME (type)); ++ xfree (TYPE_TAG_NAME (type)); ++ ++ for (i = 0; i < TYPE_NFIELDS (type); ++i) ++ { ++ xfree (TYPE_FIELD_NAME (type, i)); ++ ++ if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME) ++ xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i)); ++ } ++ xfree (TYPE_FIELDS (type)); ++ ++ gdb_assert (!HAVE_CPLUS_STRUCT (type)); ++ ++ xfree (TYPE_MAIN_TYPE (type)); ++} ++ ++/* Delete all the instances on TYPE_CHAIN of TYPE, including their referenced ++ main_type. TYPE must be a reclaimable type - neither permanent nor objfile ++ associated. */ ++ ++static void ++delete_type_chain (struct type *type) ++{ ++ struct type *type_iter, *type_iter_to_free; ++ ++ gdb_assert (TYPE_DISCARDABLE (type)); ++ gdb_assert (TYPE_OBJFILE (type) == NULL); ++ ++ delete_main_type (type); ++ ++ type_iter = type; ++ do ++ { ++ type_iter_to_free = type_iter; ++ type_iter = TYPE_CHAIN (type_iter); ++ xfree (type_iter_to_free); ++ } ++ while (type_iter != type); ++} ++ ++/* Hash function for type_discardable_table. */ ++ ++static hashval_t ++type_discardable_hash (const void *p) ++{ ++ const struct type *type = p; ++ ++ return htab_hash_pointer (TYPE_MAIN_TYPE (type)); ++} ++ ++/* Equality function for type_discardable_table. */ ++ ++static int ++type_discardable_equal (const void *a, const void *b) ++{ ++ const struct type *left = a; ++ const struct type *right = b; ++ ++ return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right); ++} ++ ++/* A helper for type_mark_used. */ ++ ++static int ++type_mark_used_crawl (struct type *type, void *unused) ++{ ++ if (!TYPE_DISCARDABLE (type)) ++ return 0; ++ ++ if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current) ++ return 0; ++ ++ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current; ++ ++ /* Continue the traversal. */ ++ return 1; ++} ++ ++/* Mark TYPE and its connected types as used in this free_all_types pass. */ ++ ++void ++type_mark_used (struct type *type) ++{ ++ if (type == NULL) ++ return; ++ ++ if (!TYPE_DISCARDABLE (type)) ++ return; ++ ++ main_type_crawl (type, type_mark_used_crawl, NULL); ++} ++ ++/* A traverse callback for type_discardable_table which removes any ++ type_discardable whose reference count is now zero (unused link). */ ++ ++static int ++type_discardable_remove (void **slot, void *unused) ++{ ++ struct type *type = *slot; ++ ++ gdb_assert (TYPE_DISCARDABLE (type)); ++ ++ if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current) ++ { ++ delete_type_chain (type); ++ ++ htab_clear_slot (type_discardable_table, slot); ++ } ++ ++ return 1; ++} ++ ++/* Free all the reclaimable types that have been allocated and that have ++ currently zero reference counter. ++ ++ This function is called after each command, successful or not. Use this ++ cleanup only in the GDB idle state as GDB only marks those types used by ++ globally tracked objects (with no autovariable references tracking). */ ++ ++void ++free_all_types (void) ++{ ++ /* Mark a new pass. As GDB checks all the entries were visited after each ++ pass there cannot be any stale entries already containing the changed ++ value. */ ++ type_discardable_age_current ^= 1; ++ ++ observer_notify_mark_used (); ++ ++ htab_traverse (type_discardable_table, type_discardable_remove, NULL); ++} ++#endif + + /* Helper functions to initialize architecture-specific types. */ + +@@ -3984,6 +4551,13 @@ void + _initialize_gdbtypes (void) + { + gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); ++ ++#if 0 ++ type_discardable_table = htab_create_alloc (20, type_discardable_hash, ++ type_discardable_equal, NULL, ++ xcalloc, xfree); ++#endif ++ + objfile_type_data = register_objfile_data (); + + add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, +Index: gdb-7.3.50.20110722/gdb/gdbtypes.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/gdbtypes.h 2011-07-05 15:36:41.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/gdbtypes.h 2011-07-29 22:52:02.000000000 +0200 +@@ -215,6 +215,11 @@ enum type_instance_flag_value + + #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub) + ++/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be ++ sticky. */ ++ ++#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic) ++ + /* Static type. If this is set, the corresponding type had + a static modifier. + Note: This may be unnecessary, since static data members +@@ -292,6 +297,50 @@ enum type_instance_flag_value + + #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class) + ++#if 0 ++/* Define this type as being reclaimable during free_all_types. Type is ++ required to be have TYPE_OBJFILE set to NULL. Setting this flag requires ++ initializing TYPE_DISCARDABLE_AGE, see alloc_type_discardable. */ ++ ++#define TYPE_DISCARDABLE(t) (TYPE_MAIN_TYPE (t)->flag_discardable) ++ ++/* Marker this type has been visited by the type_mark_used by this ++ mark-and-sweep types garbage collecting pass. Current pass is represented ++ by TYPE_DISCARDABLE_AGE_CURRENT. */ ++ ++#define TYPE_DISCARDABLE_AGE(t) (TYPE_MAIN_TYPE (t)->flag_discardable_age) ++#endif ++ ++/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */ ++ ++#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \ ++ (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count) ++ ++/* Not allocated. TYPE_ALLOCATED(t) must be NULL in such case. If this flag ++ is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated. If this ++ flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block ++ determines the actual allocation state. */ ++ ++#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated) ++ ++/* Not associated. TYPE_ASSOCIATED(t) must be NULL in such case. If this flag ++ is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated. If ++ this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block ++ determines the actual association state. */ ++ ++#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated) ++ ++/* Address of the actual data as for DW_AT_data_location. Its dwarf block must ++ not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are ++ false. If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value ++ is the actual data address value. If unset and ++ TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal ++ value_raw_address. If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL ++ then its DWARF block determines the actual data address. */ ++ ++#define TYPE_DATA_LOCATION_IS_ADDR(t) \ ++ (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr) ++ + /* Constant type. If this is set, the corresponding type has a + const modifier. */ + +@@ -400,6 +449,15 @@ struct main_type + /* True if this type was declared with "class" rather than + "struct". */ + unsigned int flag_declared_class : 1; ++#if 0 ++ unsigned int flag_discardable : 1; ++ unsigned int flag_discardable_age : 1; ++#endif ++ unsigned int flag_dynamic : 1; ++ unsigned int flag_range_high_bound_is_count : 1; ++ unsigned int flag_not_allocated : 1; ++ unsigned int flag_not_associated : 1; ++ unsigned int flag_data_location_is_addr : 1; + + /* A discriminant telling us which field of the type_specific union + is being used for this type, if any. */ +@@ -473,6 +531,20 @@ struct main_type + + struct type *target_type; + ++ /* For DW_AT_data_location. */ ++ union ++ { ++ struct dwarf2_locexpr_baton *dwarf_block; ++ CORE_ADDR addr; ++ } ++ data_location; ++ ++ /* For DW_AT_allocated. */ ++ struct dwarf2_locexpr_baton *allocated; ++ ++ /* For DW_AT_associated. */ ++ struct dwarf2_locexpr_baton *associated; ++ + /* For structure and union types, a description of each field. + For set and pascal array types, there is one "field", + whose type is the domain type of the set or array. +@@ -547,13 +619,34 @@ struct main_type + + struct range_bounds + { ++ struct ++ { ++ union ++ { ++ LONGEST constant; ++ struct dwarf2_locexpr_baton *dwarf_block; ++ struct ++ { ++ struct dwarf2_loclist_baton *loclist; ++ struct type *type; ++ } ++ dwarf_loclist; ++ } ++ u; ++ enum range_bound_kind ++ { ++ RANGE_BOUND_KIND_CONSTANT, ++ RANGE_BOUND_KIND_DWARF_BLOCK, ++ RANGE_BOUND_KIND_DWARF_LOCLIST ++ } ++ kind; ++ } + /* Low bound of range. */ +- +- LONGEST low; +- ++ low, + /* High bound of range. */ +- +- LONGEST high; ++ high, ++ /* Byte stride of range. */ ++ byte_stride; + + /* Flags indicating whether the values of low and high are + valid. When true, the respective range value is +@@ -929,9 +1022,9 @@ extern void allocate_gnat_aux_type (stru + #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type + #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type + #define TYPE_CHAIN(thistype) (thistype)->chain +-/* Note that if thistype is a TYPEDEF type, you have to call check_typedef. +- But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, +- so you only have to call check_typedef once. Since allocate_value ++/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call ++ check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF ++ type, so you only have to call check_typedef once. Since allocate_value + calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ + #define TYPE_LENGTH(thistype) (thistype)->length + /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real +@@ -939,11 +1032,16 @@ extern void allocate_gnat_aux_type (stru + #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code + #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields + #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields ++#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block ++#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr ++#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated ++#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated + + #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0) + #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds +-#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low +-#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high ++#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant ++#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant ++#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant + #define TYPE_LOW_BOUND_UNDEFINED(range_type) \ + TYPE_RANGE_DATA(range_type)->low_undefined + #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \ +@@ -960,7 +1058,14 @@ extern void allocate_gnat_aux_type (stru + (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) + + #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \ +- (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype)))) ++ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype)) ++ ++/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the ++ element size if no specific stride value is known. */ ++#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \ ++ (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \ ++ ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \ ++ : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype))) + + /* C++ */ + +@@ -1385,6 +1490,18 @@ extern struct type *create_array_type (s + struct type *); + extern struct type *lookup_array_range_type (struct type *, int, int); + ++extern CORE_ADDR type_range_any_field_internal (struct type *range_type, ++ int fieldno); ++ ++extern int type_range_high_bound_internal (struct type *range_type); ++ ++extern int type_range_count_bound_internal (struct type *range_type); ++ ++extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type, ++ struct type *element_type); ++ ++extern void finalize_type (struct type *type); ++ + extern struct type *create_string_type (struct type *, struct type *, + struct type *); + extern struct type *lookup_string_range_type (struct type *, int, int); +@@ -1430,6 +1547,10 @@ extern int is_public_ancestor (struct ty + + extern int is_unique_ancestor (struct type *, struct value *); + ++#if 0 ++extern void type_mark_used (struct type *type); ++#endif ++ + /* Overload resolution */ + + #define LENGTH_MATCH(bv) ((bv)->rank[0]) +@@ -1502,10 +1623,13 @@ extern void maintenance_print_type (char + + extern htab_t create_copied_types_hash (struct objfile *objfile); + +-extern struct type *copy_type_recursive (struct objfile *objfile, +- struct type *type, ++extern struct type *copy_type_recursive (struct type *type, + htab_t copied_types); + + extern struct type *copy_type (const struct type *type); + ++#if 0 ++extern void free_all_types (void); ++#endif ++ + #endif /* GDBTYPES_H */ +Index: gdb-7.3.50.20110722/gdb/i386-linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/i386-linux-nat.c 2011-02-27 17:25:37.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/i386-linux-nat.c 2011-07-29 22:52:02.000000000 +0200 +@@ -649,22 +649,13 @@ i386_linux_store_inferior_registers (str + } + + +-/* Support for debug registers. */ +- +-static unsigned long i386_linux_dr[DR_CONTROL + 1]; +- + /* Get debug register REGNUM value from only the one LWP of PTID. */ + + static unsigned long +-i386_linux_dr_get (ptid_t ptid, int regnum) ++i386_linux_dr_get (int tid, int regnum) + { +- int tid; + unsigned long value; + +- tid = TIDGET (ptid); +- if (tid == 0) +- tid = PIDGET (ptid); +- + /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the + ptrace call fails breaks debugging remote targets. The correct + way to fix this is to add the hardware breakpoint and watchpoint +@@ -686,14 +677,8 @@ i386_linux_dr_get (ptid_t ptid, int regn + /* Set debug register REGNUM to VALUE in only the one LWP of PTID. */ + + static void +-i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) ++i386_linux_dr_set (int tid, int regnum, unsigned long value) + { +- int tid; +- +- tid = TIDGET (ptid); +- if (tid == 0) +- tid = PIDGET (ptid); +- + errno = 0; + ptrace (PTRACE_POKEUSER, tid, + offsetof (struct user, u_debugreg[regnum]), value); +@@ -701,35 +686,78 @@ i386_linux_dr_set (ptid_t ptid, int regn + perror_with_name (_("Couldn't write debug register")); + } + +-/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */ ++/* Helper for i386_linux_dr_set_control. */ ++ ++static void ++i386_linux_dr_set_control_callback (int tid, void *control_voidp) ++{ ++ unsigned long control = *(unsigned long *) control_voidp; ++ ++ i386_linux_dr_set (tid, DR_CONTROL, control); ++} ++ ++static void i386_linux_dr_set_addr (int regnum, CORE_ADDR addr); ++ ++/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */ + + static void + i386_linux_dr_set_control (unsigned long control) + { +- struct lwp_info *lp; +- ptid_t ptid; ++ int inferior_pid = ptid_get_pid (inferior_ptid); ++ struct inferior *inf = current_inferior (); + +- i386_linux_dr[DR_CONTROL] = control; +- ALL_LWPS (lp, ptid) +- i386_linux_dr_set (ptid, DR_CONTROL, control); ++ /* The amd64 counterpart and description is amd64_linux_dr_set_control. */ ++ if (inf->pid != inferior_pid) ++ { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); ++ int i; ++ ++ if (!dr_mirror->addr_preset) ++ { ++ dr_mirror->addr_preset = 1; ++ ++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++) ++ i386_linux_dr_set_addr (i, dr_mirror->addr[i]); ++ } ++ } ++ ++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_control_callback, ++ &control); + } + +-/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */ ++/* Helper for i386_linux_dr_set_addr. */ ++ ++struct i386_linux_dr_set_addr_data ++ { ++ int regnum; ++ CORE_ADDR addr; ++ }; ++ ++static void ++i386_linux_dr_set_addr_callback (int tid, void *datap_voidp) ++{ ++ const struct i386_linux_dr_set_addr_data *datap = datap_voidp; ++ ++ i386_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr); ++} ++ ++/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR. ++ */ + + static void + i386_linux_dr_set_addr (int regnum, CORE_ADDR addr) + { +- struct lwp_info *lp; +- ptid_t ptid; ++ struct i386_linux_dr_set_addr_data data; + + gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); + +- i386_linux_dr[DR_FIRSTADDR + regnum] = addr; +- ALL_LWPS (lp, ptid) +- i386_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr); ++ data.regnum = regnum; ++ data.addr = addr; ++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_addr_callback, &data); + } + +-/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */ ++/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR. ++ */ + + static void + i386_linux_dr_reset_addr (int regnum) +@@ -742,36 +770,54 @@ i386_linux_dr_reset_addr (int regnum) + static unsigned long + i386_linux_dr_get_status (void) + { +- return i386_linux_dr_get (inferior_ptid, DR_STATUS); ++ int tid; ++ ++ tid = TIDGET (inferior_ptid); ++ if (tid == 0) ++ tid = PIDGET (inferior_ptid); ++ ++ return i386_linux_dr_get (tid, DR_STATUS); + } + +-/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */ ++/* Helper for i386_linux_dr_unset_status. */ + + static void +-i386_linux_dr_unset_status (unsigned long mask) ++i386_linux_dr_unset_status_callback (int tid, void *mask_voidp) + { +- struct lwp_info *lp; +- ptid_t ptid; +- +- ALL_LWPS (lp, ptid) +- { +- unsigned long value; ++ unsigned long mask = *(unsigned long *) mask_voidp; ++ unsigned long value; + +- value = i386_linux_dr_get (ptid, DR_STATUS); +- value &= ~mask; +- i386_linux_dr_set (ptid, DR_STATUS, value); +- } ++ value = i386_linux_dr_get (tid, DR_STATUS); ++ value &= ~mask; ++ i386_linux_dr_set (tid, DR_STATUS, value); ++} ++ ++/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */ ++ ++static void ++i386_linux_dr_unset_status (unsigned long mask) ++{ ++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_unset_status_callback, ++ &mask); + } + + static void + i386_linux_new_thread (ptid_t ptid) + { +- int i; ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); ++ int i, tid; ++ ++ /* Verify DR_MIRROR is valid. */ ++ gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid)); ++ ++ tid = TIDGET (ptid); ++ if (tid == 0) ++ tid = PIDGET (ptid); + +- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) +- i386_linux_dr_set (ptid, i, i386_linux_dr[i]); ++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++) ++ i386_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]); + +- i386_linux_dr_set (ptid, DR_CONTROL, i386_linux_dr[DR_CONTROL]); ++ i386_linux_dr_set (tid, DR_CONTROL, dr_mirror->control); + } + + +Index: gdb-7.3.50.20110722/gdb/i386-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/i386-nat.c 2011-02-26 23:04:51.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/i386-nat.c 2011-07-29 22:52:02.000000000 +0200 +@@ -25,6 +25,7 @@ + #include "gdbcmd.h" + #include "target.h" + #include "gdb_assert.h" ++#include "inferior.h" + + /* Support for hardware watchpoints and breakpoints using the i386 + debug registers. +@@ -44,7 +45,6 @@ struct i386_dr_low_type i386_dr_low; + #define TARGET_HAS_DR_LEN_8 (i386_dr_low.debug_register_length == 8) + + /* Debug registers' indices. */ +-#define DR_NADDR 4 /* The number of debug address registers. */ + #define DR_STATUS 6 /* Index of debug status register (DR6). */ + #define DR_CONTROL 7 /* Index of debug control register (DR7). */ + +@@ -111,49 +111,60 @@ struct i386_dr_low_type i386_dr_low; + + /* The I'th debug register is vacant if its Local and Global Enable + bits are reset in the Debug Control register. */ +-#define I386_DR_VACANT(i) \ +- ((dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0) ++ ++static inline int ++i386_dr_vacant (struct i386_dr_mirror *dr_mirror, int i) ++{ ++ return (dr_mirror->control & (3 << (DR_ENABLE_SIZE * i))) == 0; ++} + + /* Locally enable the break/watchpoint in the I'th debug register. */ +-#define I386_DR_LOCAL_ENABLE(i) \ +- dr_control_mirror |= (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i))) + +-/* Globally enable the break/watchpoint in the I'th debug register. */ +-#define I386_DR_GLOBAL_ENABLE(i) \ +- dr_control_mirror |= (1 << (DR_GLOBAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i))) ++static inline void ++i386_dr_local_enable (struct i386_dr_mirror *dr_mirror, int i) ++{ ++ dr_mirror->control |= 1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * i); ++} + + /* Disable the break/watchpoint in the I'th debug register. */ +-#define I386_DR_DISABLE(i) \ +- dr_control_mirror &= ~(3 << (DR_ENABLE_SIZE * (i))) ++ ++static inline void ++i386_dr_disable (struct i386_dr_mirror *dr_mirror, int i) ++{ ++ dr_mirror->control &= ~(3 << (DR_ENABLE_SIZE * i)); ++} + + /* Set in DR7 the RW and LEN fields for the I'th debug register. */ +-#define I386_DR_SET_RW_LEN(i,rwlen) \ +- do { \ +- dr_control_mirror &= ~(0x0f << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \ +- dr_control_mirror |= ((rwlen) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \ +- } while (0) ++ ++static inline void ++i386_dr_set_rw_len (struct i386_dr_mirror *dr_mirror, int i, unsigned rwlen) ++{ ++ dr_mirror->control &= ~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i)); ++ dr_mirror->control |= rwlen << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i); ++} + + /* Get from DR7 the RW and LEN fields for the I'th debug register. */ +-#define I386_DR_GET_RW_LEN(i) \ +- ((dr_control_mirror >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f) ++ ++static inline unsigned ++i386_dr_get_rw_len (struct i386_dr_mirror *dr_mirror, int i) ++{ ++ return ((dr_mirror->control >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i)) ++ & 0x0f); ++} + + /* Mask that this I'th watchpoint has triggered. */ + #define I386_DR_WATCH_MASK(i) (1 << (i)) + + /* Did the watchpoint whose address is in the I'th register break? */ +-#define I386_DR_WATCH_HIT(i) (dr_status_mirror & I386_DR_WATCH_MASK (i)) ++static inline int ++i386_dr_watch_hit (struct i386_dr_mirror *dr_mirror, int i) ++{ ++ return (dr_mirror->status & I386_DR_WATCH_MASK (i)) != 0; ++} + + /* A macro to loop over all debug registers. */ + #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++) + +-/* Mirror the inferior's DRi registers. We keep the status and +- control registers separated because they don't hold addresses. */ +-static CORE_ADDR dr_mirror[DR_NADDR]; +-static unsigned long dr_status_mirror, dr_control_mirror; +- +-/* Reference counts for each debug register. */ +-static int dr_ref_count[DR_NADDR]; +- + /* Whether or not to print the mirrored debug registers. */ + static int maint_show_dr; + +@@ -195,21 +206,80 @@ static int i386_handle_nonaligned_watchp + + /* Implementation. */ + ++/* Per-inferior data key. */ ++static const struct inferior_data *i386_inferior_data; ++ ++struct i386_inferior_data ++ { ++ /* Copy of i386 hardware debug registers for performance reasons. */ ++ struct i386_dr_mirror dr_mirror; ++ }; ++ ++static void ++i386_inferior_data_cleanup (struct inferior *inf, void *arg) ++{ ++ struct i386_inferior_data *inf_data = arg; ++ ++ xfree (inf_data); ++} ++ ++static struct i386_inferior_data * ++i386_inferior_data_get (void) ++{ ++ struct inferior *inf = current_inferior (); ++ struct i386_inferior_data *inf_data; ++ ++ inf_data = inferior_data (inf, i386_inferior_data); ++ if (inf_data == NULL) ++ { ++ inf_data = xzalloc (sizeof (*inf_data)); ++ set_inferior_data (current_inferior (), i386_inferior_data, inf_data); ++ } ++ ++ if (inf->pid != ptid_get_pid (inferior_ptid)) ++ { ++ static struct i386_inferior_data detached_inf_data_local; ++ static int detached_inf_pid = -1; ++ ++ if (detached_inf_pid != ptid_get_pid (inferior_ptid)) ++ { ++ detached_inf_pid = ptid_get_pid (inferior_ptid); ++ ++ /* Forked processes get a copy of the debug registers. */ ++ memcpy (&detached_inf_data_local, inf_data, ++ sizeof (detached_inf_data_local)); ++ detached_inf_data_local.dr_mirror.addr_preset = 0; ++ } ++ ++ return &detached_inf_data_local; ++ } ++ ++ return inf_data; ++} ++ + /* Clear the reference counts and forget everything we knew about the + debug registers. */ + ++struct i386_dr_mirror * ++i386_dr_mirror_get (void) ++{ ++ return &i386_inferior_data_get ()->dr_mirror; ++} ++ + void + i386_cleanup_dregs (void) + { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); + int i; + + ALL_DEBUG_REGISTERS(i) + { +- dr_mirror[i] = 0; +- dr_ref_count[i] = 0; ++ dr_mirror->addr[i] = 0; ++ dr_mirror->ref_count[i] = 0; + } +- dr_control_mirror = 0; +- dr_status_mirror = 0; ++ dr_mirror->addr_preset = 0; ++ dr_mirror->control = 0; ++ dr_mirror->status = 0; + } + + /* Print the values of the mirrored debug registers. This is called +@@ -220,6 +290,7 @@ static void + i386_show_dr (const char *func, CORE_ADDR addr, + int len, enum target_hw_bp_type type) + { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); + int addr_size = gdbarch_addr_bit (target_gdbarch) / 8; + int i; + +@@ -239,13 +310,16 @@ i386_show_dr (const char *func, CORE_ADD + : "??unknown??")))); + puts_unfiltered (":\n"); + printf_unfiltered ("\tCONTROL (DR7): %s STATUS (DR6): %s\n", +- phex (dr_control_mirror, 8), phex (dr_status_mirror, 8)); ++ phex (dr_mirror->control, 8), ++ phex (dr_mirror->status, 8)); + ALL_DEBUG_REGISTERS(i) + { + printf_unfiltered ("\ + \tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n", +- i, phex (dr_mirror[i], addr_size), dr_ref_count[i], +- i+1, phex (dr_mirror[i+1], addr_size), dr_ref_count[i+1]); ++ i, phex (dr_mirror->addr[i], addr_size), ++ dr_mirror->ref_count[i], i + 1, ++ phex (dr_mirror->addr[i + 1], addr_size), ++ dr_mirror->ref_count[i + 1]); + i++; + } + } +@@ -313,6 +387,7 @@ Invalid hardware breakpoint length %d in + static int + i386_insert_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits) + { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); + int i; + + if (!i386_dr_low.set_addr || !i386_dr_low.set_control) +@@ -323,11 +398,10 @@ i386_insert_aligned_watchpoint (CORE_ADD + reuse it for this watchpoint as well (and save a register). */ + ALL_DEBUG_REGISTERS(i) + { +- if (!I386_DR_VACANT (i) +- && dr_mirror[i] == addr +- && I386_DR_GET_RW_LEN (i) == len_rw_bits) ++ if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr ++ && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits) + { +- dr_ref_count[i]++; ++ dr_mirror->ref_count[i]++; + return 0; + } + } +@@ -335,7 +409,7 @@ i386_insert_aligned_watchpoint (CORE_ADD + /* Next, look for a vacant debug register. */ + ALL_DEBUG_REGISTERS(i) + { +- if (I386_DR_VACANT (i)) ++ if (i386_dr_vacant (dr_mirror, i)) + break; + } + +@@ -346,9 +420,9 @@ i386_insert_aligned_watchpoint (CORE_ADD + /* Now set up the register I to watch our region. */ + + /* Record the info in our local mirrored array. */ +- dr_mirror[i] = addr; +- dr_ref_count[i] = 1; +- I386_DR_SET_RW_LEN (i, len_rw_bits); ++ dr_mirror->addr[i] = addr; ++ dr_mirror->ref_count[i] = 1; ++ i386_dr_set_rw_len (dr_mirror, i, len_rw_bits); + /* Note: we only enable the watchpoint locally, i.e. in the current + task. Currently, no i386 target allows or supports global + watchpoints; however, if any target would want that in the +@@ -356,13 +430,13 @@ i386_insert_aligned_watchpoint (CORE_ADD + to enable watchpoints globally or locally, and the code below + should use global or local enable and slow-down flags as + appropriate. */ +- I386_DR_LOCAL_ENABLE (i); +- dr_control_mirror |= DR_LOCAL_SLOWDOWN; +- dr_control_mirror &= I386_DR_CONTROL_MASK; ++ i386_dr_local_enable (dr_mirror, i); ++ dr_mirror->control |= DR_LOCAL_SLOWDOWN; ++ dr_mirror->control &= I386_DR_CONTROL_MASK; + + /* Finally, actually pass the info to the inferior. */ + i386_dr_low.set_addr (i, addr); +- i386_dr_low.set_control (dr_control_mirror); ++ i386_dr_low.set_control (dr_mirror->control); + + /* Only a sanity check for leftover bits (set possibly only by inferior). */ + if (i386_dr_low.unset_status) +@@ -380,21 +454,21 @@ i386_insert_aligned_watchpoint (CORE_ADD + static int + i386_remove_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits) + { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); + int i, retval = -1; + + ALL_DEBUG_REGISTERS(i) + { +- if (!I386_DR_VACANT (i) +- && dr_mirror[i] == addr +- && I386_DR_GET_RW_LEN (i) == len_rw_bits) ++ if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr ++ && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits) + { +- if (--dr_ref_count[i] == 0) /* no longer in use? */ ++ if (--dr_mirror->ref_count[i] == 0) /* no longer in use? */ + { + /* Reset our mirror. */ +- dr_mirror[i] = 0; +- I386_DR_DISABLE (i); ++ dr_mirror->addr[i] = 0; ++ i386_dr_disable (dr_mirror, i); + /* Reset it in the inferior. */ +- i386_dr_low.set_control (dr_control_mirror); ++ i386_dr_low.set_control (dr_mirror->control); + if (i386_dr_low.reset_addr) + i386_dr_low.reset_addr (i); + } +@@ -556,26 +630,27 @@ i386_region_ok_for_watchpoint (CORE_ADDR + static int + i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) + { ++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get (); + CORE_ADDR addr = 0; + int i; + int rc = 0; + +- dr_status_mirror = i386_dr_low.get_status (); ++ dr_mirror->status = i386_dr_low.get_status (); + + ALL_DEBUG_REGISTERS(i) + { +- if (I386_DR_WATCH_HIT (i) ++ if (i386_dr_watch_hit (dr_mirror, i) + /* This second condition makes sure DRi is set up for a data + watchpoint, not a hardware breakpoint. The reason is + that GDB doesn't call the target_stopped_data_address + method except for data watchpoints. In other words, I'm + being paranoiac. */ +- && I386_DR_GET_RW_LEN (i) != 0 ++ && i386_dr_get_rw_len (dr_mirror, i) != 0 + /* This third condition makes sure DRi is not vacant, this + avoids false positives in windows-nat.c. */ +- && !I386_DR_VACANT (i)) ++ && !i386_dr_vacant (dr_mirror, i)) + { +- addr = dr_mirror[i]; ++ addr = dr_mirror->addr[i]; + rc = 1; + if (maint_show_dr) + i386_show_dr ("watchpoint_hit", addr, -1, hw_write); +@@ -689,6 +764,10 @@ i386_use_watchpoints (struct target_ops + t->to_remove_watchpoint = i386_remove_watchpoint; + t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint; + t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint; ++ ++ if (i386_inferior_data == NULL) ++ i386_inferior_data ++ = register_inferior_data_with_cleanup (i386_inferior_data_cleanup); + } + + void +Index: gdb-7.3.50.20110722/gdb/i386-nat.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/i386-nat.h 2011-01-09 04:08:56.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/i386-nat.h 2011-07-29 22:52:02.000000000 +0200 +@@ -78,6 +78,28 @@ struct i386_dr_low_type + + extern struct i386_dr_low_type i386_dr_low; + ++/* The number of debug address registers. */ ++#define DR_NADDR 4 ++ ++/* Copy of hardware debug registers for performance reasons. */ ++ ++struct i386_dr_mirror ++ { ++ /* Mirror the inferior's DRi registers. We keep the status and ++ control registers separated because they don't hold addresses. */ ++ CORE_ADDR addr[DR_NADDR]; ++ ++ /* All the ADDR hardware registers have been written at least once. */ ++ unsigned addr_preset : 1; ++ ++ /* Reference counts for each debug register. */ ++ int ref_count[DR_NADDR]; ++ ++ unsigned long status, control; ++ }; ++ ++extern struct i386_dr_mirror *i386_dr_mirror_get (void); ++ + /* Use this function to set i386_dr_low debug_register_length field + rather than setting it directly to check that the length is only + set once. It also enables the 'maint set/show show-debug-regs' +Index: gdb-7.3.50.20110722/gdb/infrun.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/infrun.c 2011-07-22 01:46:09.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/infrun.c 2011-07-29 22:52:02.000000000 +0200 +@@ -55,6 +55,8 @@ + #include "jit.h" + #include "tracepoint.h" + #include "continuations.h" ++#include "stap-probe.h" ++#include "objfiles.h" + + /* Prototypes for local functions */ + +@@ -2341,7 +2343,7 @@ static void handle_step_into_function (s + static void handle_step_into_function_backward (struct gdbarch *gdbarch, + struct execution_control_state *ecs); + static void check_exception_resume (struct execution_control_state *, +- struct frame_info *, struct symbol *); ++ struct frame_info *); + + static void stop_stepping (struct execution_control_state *ecs); + static void prepare_to_wait (struct execution_control_state *ecs); +@@ -4285,9 +4287,17 @@ process_event_stop_test: + + if (what.is_longjmp) + { +- if (!gdbarch_get_longjmp_target_p (gdbarch) +- || !gdbarch_get_longjmp_target (gdbarch, +- frame, &jmp_buf_pc)) ++ struct value *arg_value; ++ ++ /* If we set the longjmp breakpoint via a SystemTap probe, ++ then use it to extract the arguments. The destination ++ PC is the third argument to the probe. */ ++ arg_value = stap_safe_evaluate_at_pc (frame, 2); ++ if (arg_value) ++ jmp_buf_pc = value_as_address (arg_value); ++ else if (!gdbarch_get_longjmp_target_p (gdbarch) ++ || !gdbarch_get_longjmp_target (gdbarch, ++ frame, &jmp_buf_pc)) + { + if (debug_infrun) + fprintf_unfiltered (gdb_stdlog, +@@ -4305,12 +4315,7 @@ process_event_stop_test: + insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc); + } + else +- { +- struct symbol *func = get_frame_function (frame); +- +- if (func) +- check_exception_resume (ecs, frame, func); +- } ++ check_exception_resume (ecs, frame); + keep_going (ecs); + return; + +@@ -5423,15 +5428,65 @@ insert_exception_resume_breakpoint (stru + } + } + ++/* A helper for check_exception_resume that sets an ++ exception-breakpoint based on a SystemTap probe. */ ++ ++static void ++insert_exception_resume_from_probe (struct thread_info *tp, ++ const struct stap_probe *probe, ++ struct objfile *objfile, ++ struct frame_info *frame) ++{ ++ struct value *arg_value; ++ CORE_ADDR handler; ++ struct breakpoint *bp; ++ ++ arg_value = stap_safe_evaluate_at_pc (frame, 1); ++ if (!arg_value) ++ return; ++ ++ handler = value_as_address (arg_value); ++ ++ if (debug_infrun) ++ fprintf_unfiltered (gdb_stdlog, ++ "infrun: exception resume at %s\n", ++ paddress (get_objfile_arch (objfile), ++ handler)); ++ ++ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), ++ handler, bp_exception_resume); ++ bp->thread = tp->num; ++ inferior_thread ()->control.exception_resume_breakpoint = bp; ++} ++ + /* This is called when an exception has been intercepted. Check to + see whether the exception's destination is of interest, and if so, + set an exception resume breakpoint there. */ + + static void + check_exception_resume (struct execution_control_state *ecs, +- struct frame_info *frame, struct symbol *func) ++ struct frame_info *frame) + { + struct gdb_exception e; ++ struct objfile *objfile; ++ const struct stap_probe *probe; ++ struct symbol *func; ++ ++ /* First see if this exception unwinding breakpoint was set via a ++ SystemTap probe point. If so, the probe has two arguments: the ++ CFA and the HANDLER. We ignore the CFA, extract the handler, and ++ set a breakpoint there. */ ++ probe = find_probe_by_pc (get_frame_pc (frame), &objfile); ++ if (probe) ++ { ++ insert_exception_resume_from_probe (ecs->event_thread, probe, ++ objfile, frame); ++ return; ++ } ++ ++ func = get_frame_function (frame); ++ if (!func) ++ return; + + TRY_CATCH (e, RETURN_MASK_ERROR) + { +@@ -6434,7 +6489,8 @@ static const struct lval_funcs siginfo_v + if there's no object available. */ + + static struct value * +-siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var) ++siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var, ++ void *ignore) + { + if (target_has_stack + && !ptid_equal (inferior_ptid, null_ptid) +@@ -6929,6 +6985,15 @@ show_schedule_multiple (struct ui_file * + "of all processes is %s.\n"), value); + } + ++/* Implementation of `siginfo' variable. */ ++ ++static const struct internalvar_funcs siginfo_funcs = ++{ ++ siginfo_make_value, ++ NULL, ++ NULL ++}; ++ + void + _initialize_infrun (void) + { +@@ -7204,7 +7269,7 @@ Tells gdb whether to detach the child of + value with a void typed value, and when we get here, gdbarch + isn't initialized yet. At this point, we're quite sure there + isn't another convenience variable of the same name. */ +- create_internalvar_type_lazy ("_siginfo", siginfo_make_value); ++ create_internalvar_type_lazy ("_siginfo", &siginfo_funcs, NULL); + + add_setshow_boolean_cmd ("observer", no_class, + &observer_mode_1, _("\ +Index: gdb-7.3.50.20110722/gdb/linespec.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linespec.c 2011-07-05 22:30:19.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linespec.c 2011-07-29 22:52:02.000000000 +0200 +@@ -43,6 +43,7 @@ + #include "arch-utils.h" + #include + #include "cli/cli-utils.h" ++#include "stap-probe.h" + + /* Prototypes for local functions. */ + +@@ -783,6 +784,7 @@ keep_name_info (char *p, int on_boundary + PC returned is 0. + FILE:FUNCTION -- likewise, but prefer functions in that file. + *EXPR -- line in which address EXPR appears. ++ probe:[OBJFILE:][PROVIDER:]NAME -- a systemtap static probe + + This may all be followed by an "if EXPR", which we ignore. + +@@ -851,6 +853,9 @@ decode_line_1 (char **argptr, int funfir + if (**argptr == '*') + return decode_indirect (argptr); + ++ if (strncmp (*argptr, "probe:", 6) == 0) ++ return parse_stap_probe (argptr, canonical); ++ + is_quoted = (strchr (get_gdb_completer_quote_characters (), + **argptr) != NULL); + +Index: gdb-7.3.50.20110722/gdb/linespec.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linespec.h 2011-04-04 19:41:07.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linespec.h 2011-07-29 22:52:02.000000000 +0200 +@@ -30,6 +30,10 @@ struct linespec_result + display mechanism would do the wrong thing. */ + int special_display; + ++ /* If non-zero, the linespec result should be considered to be a ++ "pre-expanded" multi-location linespec. */ ++ int pre_expanded; ++ + /* If non-NULL, an array of canonical names for returned + symtab_and_line objects. The array has as many elements as the + `nelts' field in the symtabs_and_line returned by decode_line_1. +Index: gdb-7.3.50.20110722/gdb/linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linux-nat.c 2011-07-22 01:46:09.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/linux-nat.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1241,6 +1241,64 @@ iterate_over_lwps (ptid_t filter, + return NULL; + } + ++/* Helper for linux_nat_iterate_watchpoint_lwps. */ ++ ++struct iterate_watchpoint_lwps_data ++ { ++ linux_nat_iterate_watchpoint_lwps_ftype callback; ++ void *callback_data; ++ }; ++ ++static int ++iterate_watchpoint_lwps_callback (struct lwp_info *lp, void *datap_voidp) ++{ ++ struct iterate_watchpoint_lwps_data *datap = datap_voidp; ++ int tid; ++ ++ tid = TIDGET (lp->ptid); ++ if (tid == 0) ++ tid = PIDGET (lp->ptid); ++ ++ datap->callback (tid, datap->callback_data); ++ ++ /* Continue the traversal. */ ++ return 0; ++} ++ ++/* Iterate like iterate_over_lwps does except when forking-off a child call ++ CALLBACK with CALLBACK_DATA specifically only for that new child PID. ++ ++ During `set follow-fork-mode child' the call is also made for the new child ++ PID; parent watchpoints get detached elsewhere (during target_detach). */ ++ ++void ++linux_nat_iterate_watchpoint_lwps ++ (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data) ++{ ++ struct iterate_watchpoint_lwps_data data; ++ int inferior_pid = ptid_get_pid (inferior_ptid); ++ struct inferior *inf = current_inferior (); ++ ++ data.callback = callback; ++ data.callback_data = callback_data; ++ ++ if (inf->pid == inferior_pid) ++ { ++ /* Standard mode. Iterate all the threads of the current inferior. ++ Without specifying INFERIOR_PID it would iterate all the threads of ++ all the inferiors, which is inappropriate for watchpoints. */ ++ ++ iterate_over_lwps (pid_to_ptid (inferior_pid), ++ iterate_watchpoint_lwps_callback, &data); ++ } ++ else ++ { ++ /* Detaching a new child PID temporarily present in INFERIOR_PID. */ ++ ++ callback (inferior_pid, callback_data); ++ } ++} ++ + /* Update our internal state when changing from one checkpoint to + another indicated by NEW_PTID. We can only switch single-threaded + applications, so we only create one new LWP, and the previous list +Index: gdb-7.3.50.20110722/gdb/linux-nat.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/linux-nat.h 2011-01-05 23:22:49.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/linux-nat.h 2011-07-29 22:52:02.000000000 +0200 +@@ -140,6 +140,11 @@ struct lwp_info *iterate_over_lwps (ptid + void *), + void *data); + ++typedef void (*linux_nat_iterate_watchpoint_lwps_ftype) (int tid, void *data); ++ ++extern void linux_nat_iterate_watchpoint_lwps ++ (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data); ++ + /* Create a prototype generic GNU/Linux target. The client can + override it with local methods. */ + struct target_ops * linux_target (void); +Index: gdb-7.3.50.20110722/gdb/machoread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/machoread.c 2011-07-01 20:36:45.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/machoread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -842,6 +842,7 @@ static const struct sym_fns macho_sym_fn + default_symfile_segments, /* Get segment information from a file. */ + NULL, + macho_symfile_relocate, /* Relocate a debug section. */ ++ NULL, /* sym_get_probes */ + &psym_functions + }; + +Index: gdb-7.3.50.20110722/gdb/main.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/main.c 2011-06-13 12:55:26.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/main.c 2011-07-29 22:52:02.000000000 +0200 +@@ -39,6 +39,7 @@ + + #include "interps.h" + #include "main.h" ++#include "python/python.h" + #include "source.h" + #include "cli/cli-cmds.h" + #include "python/python.h" +@@ -262,6 +263,8 @@ captured_main (void *data) + char *cdarg = NULL; + char *ttyarg = NULL; + ++ int python_script = 0; ++ + /* These are static so that we can take their address in an + initializer. */ + static int print_help; +@@ -452,10 +455,14 @@ captured_main (void *data) + {"args", no_argument, &set_args, 1}, + {"l", required_argument, 0, 'l'}, + {"return-child-result", no_argument, &return_child_result, 1}, ++#if HAVE_PYTHON ++ {"python", no_argument, 0, 'P'}, ++ {"P", no_argument, 0, 'P'}, ++#endif + {0, no_argument, 0, 0} + }; + +- while (1) ++ while (!python_script) + { + int option_index; + +@@ -473,6 +480,9 @@ captured_main (void *data) + case 0: + /* Long option that just sets a flag. */ + break; ++ case 'P': ++ python_script = 1; ++ break; + case OPT_SE: + symarg = optarg; + execarg = optarg; +@@ -668,7 +678,31 @@ captured_main (void *data) + + /* Now that gdb_init has created the initial inferior, we're in + position to set args for that inferior. */ +- if (set_args) ++ if (python_script) ++ { ++ /* The first argument is a python script to evaluate, and ++ subsequent arguments are passed to the script for ++ processing there. */ ++ if (optind >= argc) ++ { ++ fprintf_unfiltered (gdb_stderr, ++ _("%s: Python script file name required\n"), ++ argv[0]); ++ exit (1); ++ } ++ ++ /* FIXME: should handle inferior I/O intelligently here. ++ E.g., should be possible to run gdb in pipeline and have ++ Python (and gdb) output go to stderr or file; and if a ++ prompt is needed, open the tty. */ ++ quiet = 1; ++ /* FIXME: should read .gdbinit if, and only if, a prompt is ++ requested by the script. Though... maybe this is not ++ ideal? */ ++ /* FIXME: likewise, reading in history. */ ++ inhibit_gdbinit = 1; ++ } ++ else if (set_args) + { + /* The remaining options are the command-line options for the + inferior. The first one is the sym/exec file, and the rest +@@ -917,7 +951,8 @@ captured_main (void *data) + + /* Read in the old history after all the command files have been + read. */ +- init_history (); ++ if (!python_script) ++ init_history (); + + if (batch_flag) + { +@@ -928,13 +963,25 @@ captured_main (void *data) + /* Show time and/or space usage. */ + do_cleanups (pre_stat_chain); + +- /* NOTE: cagney/1999-11-07: There is probably no reason for not +- moving this loop and the code found in captured_command_loop() +- into the command_loop() proper. The main thing holding back that +- change - SET_TOP_LEVEL() - has been eliminated. */ +- while (1) ++#if HAVE_PYTHON ++ if (python_script) ++ { ++ extern int pagination_enabled; ++ pagination_enabled = 0; ++ run_python_script (argc - optind, &argv[optind]); ++ return 1; ++ } ++ else ++#endif + { +- catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); ++ /* NOTE: cagney/1999-11-07: There is probably no reason for not ++ moving this loop and the code found in captured_command_loop() ++ into the command_loop() proper. The main thing holding back that ++ change - SET_TOP_LEVEL() - has been eliminated. */ ++ while (1) ++ { ++ catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); ++ } + } + /* No exit -- exit is through quit_command. */ + } +@@ -966,7 +1013,12 @@ print_gdb_help (struct ui_file *stream) + fputs_unfiltered (_("\ + This is the GNU debugger. Usage:\n\n\ + gdb [options] [executable-file [core-file or process-id]]\n\ +- gdb [options] --args executable-file [inferior-arguments ...]\n\n\ ++ gdb [options] --args executable-file [inferior-arguments ...]\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream); ++#endif ++ fputs_unfiltered (_("\n\ + Options:\n\n\ + "), stream); + fputs_unfiltered (_("\ +@@ -1004,7 +1056,13 @@ Options:\n\n\ + --nw Do not use a window interface.\n\ + --nx Do not read "), stream); + fputs_unfiltered (gdbinit, stream); +- fputs_unfiltered (_(" file.\n\ ++ fputs_unfiltered (_(" file.\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ --python, -P Following argument is Python script file; remaining\n\ ++ arguments are passed to script.\n"), stream); ++#endif ++ fputs_unfiltered (_("\ + --quiet Do not print version number on startup.\n\ + --readnow Fully read symbol files on first access.\n\ + "), stream); +Index: gdb-7.3.50.20110722/gdb/mi/mi-cmd-var.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/mi/mi-cmd-var.c 2011-06-27 21:21:51.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/mi/mi-cmd-var.c 2011-07-29 22:52:02.000000000 +0200 +@@ -707,7 +707,6 @@ mi_cmd_var_update (char *command, char * + } + else + { +- /* Get varobj handle, if a valid var obj name was specified */ + struct varobj *var = varobj_get_handle (name); + + varobj_update_one (var, print_values, 1 /* explicit */); +Index: gdb-7.3.50.20110722/gdb/mipsread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/mipsread.c 2011-04-19 20:04:07.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/mipsread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -402,6 +402,7 @@ static const struct sym_fns ecoff_sym_fn + default_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ NULL, /* sym_probe_fns */ + &psym_functions + }; + +Index: gdb-7.3.50.20110722/gdb/objfiles.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/objfiles.c 2011-06-14 18:49:41.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/objfiles.c 2011-07-29 22:52:02.000000000 +0200 +@@ -842,6 +842,11 @@ objfile_relocate1 (struct objfile *objfi + obj_section_addr (s)); + } + ++ /* Relocating SystemTap probes. */ ++ if (objfile->sf && objfile->sf->sym_probe_fns) ++ objfile->sf->sym_probe_fns->sym_relocate_probe (objfile, ++ new_offsets, delta); ++ + /* Data changed. */ + return 1; + } +Index: gdb-7.3.50.20110722/gdb/p-valprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/p-valprint.c 2011-03-15 17:00:56.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/p-valprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -39,6 +39,7 @@ + #include "cp-abi.h" + #include "cp-support.h" + #include "exceptions.h" ++#include "dwarf2loc.h" + + + /* See val_print for a description of the various parameters of this +@@ -63,8 +64,31 @@ pascal_val_print (struct type *type, con + struct type *char_type; + LONGEST val; + CORE_ADDR addr; ++ struct cleanup *back_to; ++ struct type *saved_type = type; ++ CORE_ADDR saved_address = address; ++ ++ back_to = make_cleanup (null_cleanup, 0); ++ address += embedded_offset; ++ type = object_address_get_data (type, &address); ++ if (type == NULL) ++ { ++ fputs_filtered (object_address_data_not_valid (saved_type), stream); ++ gdb_flush (stream); ++ do_cleanups (back_to); ++ return 0; ++ } ++ if (address != saved_address + embedded_offset) ++ { ++ size_t length = TYPE_LENGTH (type); + +- CHECK_TYPEDEF (type); ++ valaddr = xmalloc (length); ++ make_cleanup (xfree, (gdb_byte *) valaddr); ++ read_memory (address, (gdb_byte *) valaddr, length); ++ embedded_offset = 0; ++ } ++ else ++ address -= embedded_offset; + switch (TYPE_CODE (type)) + { + case TYPE_CODE_ARRAY: +@@ -120,8 +144,8 @@ pascal_val_print (struct type *type, con + { + i = 0; + } +- val_print_array_elements (type, valaddr, embedded_offset, +- address, stream, recurse, ++ val_print_array_elements (saved_type, valaddr, embedded_offset, ++ saved_address, stream, recurse, + original_value, options, i); + fprintf_filtered (stream, "}"); + } +@@ -160,6 +184,7 @@ pascal_val_print (struct type *type, con + /* Try to print what function it points to. */ + print_address_demangle (gdbarch, addr, stream, demangle); + /* Return value is irrelevant except for string pointers. */ ++ do_cleanups (back_to); + return (0); + } + +@@ -251,6 +276,7 @@ pascal_val_print (struct type *type, con + /* Return number of characters printed, including the terminating + '\0' if we reached the end. val_print_string takes care including + the terminating '\0' if necessary. */ ++ do_cleanups (back_to); + return i; + + break; +@@ -567,6 +593,7 @@ pascal_val_print (struct type *type, con + TYPE_CODE (type)); + } + gdb_flush (stream); ++ do_cleanups (back_to); + return (0); + } + +Index: gdb-7.3.50.20110722/gdb/parse.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/parse.c 2011-06-17 22:24:22.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/parse.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1501,6 +1501,7 @@ parser_fprintf (FILE *x, const char *y, + + int + operator_check_standard (struct expression *exp, int pos, ++ int (*type_func) (struct type *type, void *data), + int (*objfile_func) (struct objfile *objfile, + void *data), + void *data) +@@ -1542,7 +1543,7 @@ operator_check_standard (struct expressi + struct type *type = elts[pos + 2 + arg].type; + struct objfile *objfile = TYPE_OBJFILE (type); + +- if (objfile && (*objfile_func) (objfile, data)) ++ if (objfile && objfile_func && (*objfile_func) (objfile, data)) + return 1; + } + } +@@ -1560,7 +1561,8 @@ operator_check_standard (struct expressi + + /* Check objfile where the variable itself is placed. + SYMBOL_OBJ_SECTION (symbol) may be NULL. */ +- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) ++ if (objfile_func ++ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) + return 1; + + /* Check objfile where is placed the code touching the variable. */ +@@ -1573,24 +1575,27 @@ operator_check_standard (struct expressi + + /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ + +- if (type && TYPE_OBJFILE (type) ++ if (type && type_func && (*type_func) (type, data)) ++ return 1; ++ if (type && TYPE_OBJFILE (type) && objfile_func + && (*objfile_func) (TYPE_OBJFILE (type), data)) + return 1; +- if (objfile && (*objfile_func) (objfile, data)) ++ if (objfile && objfile_func && (*objfile_func) (objfile, data)) + return 1; + + return 0; + } + +-/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP. +- The functions are never called with NULL OBJFILE. Functions get passed an +- arbitrary caller supplied DATA pointer. If any of the functions returns +- non-zero value then (any other) non-zero value is immediately returned to +- the caller. Otherwise zero is returned after iterating through whole EXP. +- */ ++/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being ++ referenced by EXP. The functions are never called with NULL TYPE or NULL ++ OBJFILE. Functions get passed an arbitrary caller supplied DATA pointer. ++ If any of the functions returns non-zero value then (any other) non-zero ++ value is immediately returned to the caller. Otherwise zero is returned ++ after iterating through whole EXP. */ + + static int + exp_iterate (struct expression *exp, ++ int (*type_func) (struct type *type, void *data), + int (*objfile_func) (struct objfile *objfile, void *data), + void *data) + { +@@ -1605,7 +1610,9 @@ exp_iterate (struct expression *exp, + + pos = endpos - oplen; + if (exp->language_defn->la_exp_desc->operator_check (exp, pos, +- objfile_func, data)) ++ type_func, ++ objfile_func, ++ data)) + return 1; + + endpos = pos; +@@ -1636,8 +1643,29 @@ exp_uses_objfile (struct expression *exp + { + gdb_assert (objfile->separate_debug_objfile_backlink == NULL); + +- return exp_iterate (exp, exp_uses_objfile_iter, objfile); ++ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile); ++} ++ ++/* Helper for exp_types_mark_used. */ ++ ++#if 0 ++static int ++exp_types_mark_used_iter (struct type *type, void *unused) ++{ ++ type_mark_used (type); ++ ++ /* Continue the traversal. */ ++ return 0; ++} ++ ++/* Call type_mark_used for any type contained in EXP. */ ++ ++void ++exp_types_mark_used (struct expression *exp) ++{ ++ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL); + } ++#endif + + void + _initialize_parse (void) +Index: gdb-7.3.50.20110722/gdb/parser-defs.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/parser-defs.h 2011-01-10 21:38:49.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/parser-defs.h 2011-07-29 22:52:02.000000000 +0200 +@@ -194,6 +194,8 @@ extern void operator_length_standard (co + int *); + + extern int operator_check_standard (struct expression *exp, int pos, ++ int (*type_func) (struct type *type, ++ void *data), + int (*objfile_func) + (struct objfile *objfile, void *data), + void *data); +@@ -291,6 +293,7 @@ struct exp_descriptor + value should be immediately returned to the caller. Otherwise zero + should be returned. */ + int (*operator_check) (struct expression *exp, int pos, ++ int (*type_func) (struct type *type, void *data), + int (*objfile_func) (struct objfile *objfile, + void *data), + void *data); +@@ -329,4 +332,10 @@ extern void parser_fprintf (FILE *, cons + + extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); + ++extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); ++ ++#if 0 ++extern void exp_types_mark_used (struct expression *exp); ++#endif ++ + #endif /* PARSER_DEFS_H */ +Index: gdb-7.3.50.20110722/gdb/ppc-linux-nat.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/ppc-linux-nat.c 2011-05-06 20:46:31.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/ppc-linux-nat.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1647,6 +1647,14 @@ ppc_linux_ranged_break_num_registers (st + 2 : -1); + } + ++static void ++booke_insert_point_callback (int tid, void *pp_voidp) ++{ ++ struct ppc_hw_breakpoint *pp = pp_voidp; ++ ++ booke_insert_point (pp, tid); ++} ++ + /* Insert the hardware breakpoint described by BP_TGT. Returns 0 for + success, 1 if hardware breakpoints are not supported or -1 for failure. */ + +@@ -1654,8 +1662,6 @@ static int + ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) + { +- ptid_t ptid; +- struct lwp_info *lp; + struct ppc_hw_breakpoint p; + + if (!have_ptrace_booke_interface ()) +@@ -1681,18 +1687,23 @@ ppc_linux_insert_hw_breakpoint (struct g + p.addr2 = 0; + } + +- ALL_LWPS (lp, ptid) +- booke_insert_point (&p, TIDGET (ptid)); ++ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p); + + return 0; + } + ++static void ++booke_remove_point_callback (int tid, void *pp_voidp) ++{ ++ struct ppc_hw_breakpoint *pp = pp_voidp; ++ ++ booke_remove_point (pp, tid); ++} ++ + static int + ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) + { +- ptid_t ptid; +- struct lwp_info *lp; + struct ppc_hw_breakpoint p; + + if (!have_ptrace_booke_interface ()) +@@ -1718,8 +1729,7 @@ ppc_linux_remove_hw_breakpoint (struct g + p.addr2 = 0; + } + +- ALL_LWPS (lp, ptid) +- booke_remove_point (&p, TIDGET (ptid)); ++ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p); + + return 0; + } +@@ -2004,6 +2014,15 @@ ppc_linux_can_accel_watchpoint_condition + && check_condition (addr, cond, &data_value, &len)); + } + ++static void ++set_saved_dabr_value_callback (int tid, void *retp_voidp) ++{ ++ int *retp = retp_voidp; ++ ++ if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value) < 0) ++ *retp = -1; ++} ++ + /* Set up P with the parameters necessary to request a watchpoint covering + LEN bytes starting at ADDR and if possible with condition expression COND + evaluated by hardware. INSERT tells if we are creating a request for +@@ -2058,8 +2077,6 @@ static int + ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, + struct expression *cond) + { +- struct lwp_info *lp; +- ptid_t ptid; + int ret = -1; + + if (have_ptrace_booke_interface ()) +@@ -2068,8 +2085,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR a + + create_watchpoint_request (&p, addr, len, rw, cond, 1); + +- ALL_LWPS (lp, ptid) +- booke_insert_point (&p, TIDGET (ptid)); ++ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p); + + ret = 0; + } +@@ -2112,12 +2128,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR a + + saved_dabr_value = dabr_value; + +- ALL_LWPS (lp, ptid) +- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0, +- saved_dabr_value) < 0) +- return -1; +- + ret = 0; ++ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret); + } + + return ret; +@@ -2127,8 +2139,6 @@ static int + ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, + struct expression *cond) + { +- struct lwp_info *lp; +- ptid_t ptid; + int ret = -1; + + if (have_ptrace_booke_interface ()) +@@ -2137,20 +2147,16 @@ ppc_linux_remove_watchpoint (CORE_ADDR a + + create_watchpoint_request (&p, addr, len, rw, cond, 0); + +- ALL_LWPS (lp, ptid) +- booke_remove_point (&p, TIDGET (ptid)); ++ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p); + + ret = 0; + } + else + { + saved_dabr_value = 0; +- ALL_LWPS (lp, ptid) +- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0, +- saved_dabr_value) < 0) +- return -1; + + ret = 0; ++ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret); + } + + return ret; +Index: gdb-7.3.50.20110722/gdb/printcmd.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/printcmd.c 2011-03-22 15:39:40.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/printcmd.c 2011-07-29 22:52:02.000000000 +0200 +@@ -975,6 +975,11 @@ print_command_1 (char *exp, int inspect, + else + val = access_value_history (0); + ++ /* Do not try to OBJECT_ADDRESS_SET here anything. We are interested in the ++ source variable base addresses as found by READ_VAR_VALUE. The value here ++ can be already a calculated expression address inappropriate for ++ DW_OP_push_object_address. */ ++ + if (voidprint || (val && value_type (val) && + TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) + { +@@ -1476,6 +1481,24 @@ x_command (char *exp, int from_tty) + set_internalvar (lookup_internalvar ("__"), last_examine_value); + } + } ++ ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ ++ ++static void ++print_types_mark_used (void) ++{ ++ struct display *d; ++ ++ if (last_examine_value) ++ type_mark_used (value_type (last_examine_value)); ++ ++ for (d = display_chain; d; d = d->next) ++ if (d->exp) ++ exp_types_mark_used (d->exp); ++} ++#endif ++ + + + /* Add an expression to the auto-display chain. +@@ -2870,4 +2893,8 @@ Show printing of source filename and lin + add_com ("eval", no_class, eval_command, _("\ + Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ + a command line, and call it.")); ++ ++#if 0 ++ observer_attach_mark_used (print_types_mark_used); ++#endif + } +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/FrameIterator.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/FrameIterator.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,33 @@ ++# Iterator over frames. ++ ++# Copyright (C) 2008, 2009 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 . ++ ++class FrameIterator: ++ """An iterator that iterates over frames.""" ++ ++ def __init__ (self, frame): ++ "Initialize a FrameIterator. FRAME is the starting frame." ++ self.frame = frame ++ ++ def __iter__ (self): ++ return self ++ ++ def next (self): ++ result = self.frame ++ if result is None: ++ raise StopIteration ++ self.frame = result.older () ++ return result +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/FrameWrapper.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/FrameWrapper.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,112 @@ ++# Wrapper API for frames. ++ ++# Copyright (C) 2008, 2009 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 . ++ ++import gdb ++ ++# FIXME: arguably all this should be on Frame somehow. ++class FrameWrapper: ++ def __init__ (self, frame): ++ self.frame = frame; ++ ++ def write_symbol (self, stream, sym, block): ++ if len (sym.linkage_name): ++ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block) ++ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER: ++ sym = nsym ++ ++ stream.write (sym.print_name + "=") ++ try: ++ val = self.read_var (sym) ++ if val != None: ++ val = str (val) ++ # FIXME: would be nice to have a more precise exception here. ++ except RuntimeError, text: ++ val = text ++ if val == None: ++ stream.write ("???") ++ else: ++ stream.write (str (val)) ++ ++ def print_frame_locals (self, stream, func): ++ if not func: ++ return ++ ++ first = True ++ block = func.value ++ ++ for sym in block: ++ if sym.is_argument: ++ continue; ++ ++ self.write_symbol (stream, sym, block) ++ stream.write ('\n') ++ ++ def print_frame_args (self, stream, func): ++ if not func: ++ return ++ ++ first = True ++ block = func.value ++ ++ for sym in block: ++ if not sym.is_argument: ++ continue; ++ ++ if not first: ++ stream.write (", ") ++ ++ self.write_symbol (stream, sym, block) ++ first = False ++ ++ # FIXME: this should probably just be a method on gdb.Frame. ++ # But then we need stream wrappers. ++ def describe (self, stream, full): ++ if self.type () == gdb.DUMMY_FRAME: ++ stream.write (" \n") ++ elif self.type () == gdb.SIGTRAMP_FRAME: ++ stream.write (" \n") ++ else: ++ sal = self.find_sal () ++ pc = self.pc () ++ name = self.name () ++ if not name: ++ name = "??" ++ if pc != sal.pc or not sal.symtab: ++ stream.write (" 0x%08x in" % pc) ++ stream.write (" " + name + " (") ++ ++ func = self.function () ++ self.print_frame_args (stream, func) ++ ++ stream.write (")") ++ ++ if sal.symtab and sal.symtab.filename: ++ stream.write (" at " + sal.symtab.filename) ++ stream.write (":" + str (sal.line)) ++ ++ if not self.name () or (not sal.symtab or not sal.symtab.filename): ++ lib = gdb.solib_address (pc) ++ if lib: ++ stream.write (" from " + lib) ++ ++ stream.write ("\n") ++ ++ if full: ++ self.print_frame_locals (stream, func) ++ ++ def __getattr__ (self, name): ++ return getattr (self.frame, name) +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/backtrace.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/backtrace.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,42 @@ ++# Filtering backtrace. ++ ++# Copyright (C) 2008, 2011 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 . ++ ++import gdb ++import itertools ++ ++# Our only exports. ++__all__ = ['push_frame_filter', 'create_frame_filter'] ++ ++frame_filter = None ++ ++def push_frame_filter (constructor): ++ """Register a new backtrace filter class with the 'backtrace' command. ++The filter will be passed an iterator as an argument. The iterator ++will return gdb.Frame-like objects. The filter should in turn act as ++an iterator returning such objects.""" ++ global frame_filter ++ if frame_filter == None: ++ frame_filter = constructor ++ else: ++ frame_filter = lambda iterator, filter = frame_filter: constructor (filter (iterator)) ++ ++def create_frame_filter (iter): ++ global frame_filter ++ if frame_filter is None: ++ return iter ++ return frame_filter (iter) ++ +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/alias.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/alias.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,59 @@ ++# Alias command. ++ ++# Copyright (C) 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 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 . ++ ++import gdb ++ ++class AliasImplementation (gdb.Command): ++ def __init__ (self, name, real, doc): ++ # Have to set __doc__ before the super init call. ++ # It would be nice if gdb's help looked up __doc__ dynamically. ++ self.__doc__ = doc ++ # Note: no good way to complete :( ++ super (AliasImplementation, self).__init__ (name, gdb.COMMAND_NONE) ++ self.real = real ++ ++ def invoke(self, arg, from_tty): ++ gdb.execute (self.real + ' ' + arg, from_tty) ++ ++class AliasCommand (gdb.Command): ++ """Alias one command to another. ++In the simplest form, the first word is the name of the alias, and ++the remaining words are the the expansion. ++An '=' by itself can be used to define a multi-word alias; words ++before the '=' are the name of the new command.""" ++ ++ def __init__ (self): ++ # Completion is not quite right here. ++ super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE, ++ gdb.COMPLETE_COMMAND) ++ ++ def invoke (self, arg, from_tty): ++ self.dont_repeat () ++ # Without some form of quoting we can't alias a multi-word ++ # command to another command. ++ args = arg.split() ++ try: ++ start = args.index ('=') ++ end = start + 1 ++ except ValueError: ++ start = 1 ++ end = 1 ++ target = " ".join(args[end:]) ++ AliasImplementation (" ".join (args[0:start]), target, ++ "This command is an alias for '%s'." % target) ++ ++AliasCommand() +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/backtrace.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/backtrace.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,106 @@ ++# New backtrace command. ++ ++# Copyright (C) 2008, 2009, 2011 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 . ++ ++import gdb ++import gdb.backtrace ++import itertools ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++import sys ++ ++class ReverseBacktraceParameter (gdb.Parameter): ++ """The new-backtrace command can show backtraces in 'reverse' order. ++This means that the innermost frame will be printed last. ++Note that reverse backtraces are more expensive to compute.""" ++ ++ set_doc = "Enable or disable reverse backtraces." ++ show_doc = "Show whether backtraces will be printed in reverse order." ++ ++ def __init__(self): ++ gdb.Parameter.__init__ (self, "reverse-backtrace", ++ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) ++ # Default to compatibility with gdb. ++ self.value = False ++ ++class FilteringBacktrace (gdb.Command): ++ """Print backtrace of all stack frames, or innermost COUNT frames. ++With a negative argument, print outermost -COUNT frames. ++Use of the 'full' qualifier also prints the values of the local variables. ++Use of the 'raw' qualifier avoids any filtering by loadable modules. ++""" ++ ++ def __init__ (self): ++ # FIXME: this is not working quite well enough to replace ++ # "backtrace" yet. ++ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK) ++ self.reverse = ReverseBacktraceParameter() ++ ++ def reverse_iter (self, iter): ++ result = [] ++ for item in iter: ++ result.append (item) ++ result.reverse() ++ return result ++ ++ def final_n (self, iter, x): ++ result = [] ++ for item in iter: ++ result.append (item) ++ return result[x:] ++ ++ def invoke (self, arg, from_tty): ++ i = 0 ++ count = 0 ++ filter = True ++ full = False ++ ++ for word in arg.split (" "): ++ if word == '': ++ continue ++ elif word == 'raw': ++ filter = False ++ elif word == 'full': ++ full = True ++ else: ++ count = int (word) ++ ++ # FIXME: provide option to start at selected frame ++ # However, should still number as if starting from newest ++ newest_frame = gdb.newest_frame() ++ iter = itertools.imap (FrameWrapper, ++ FrameIterator (newest_frame)) ++ if filter: ++ iter = gdb.backtrace.create_frame_filter (iter) ++ ++ # Now wrap in an iterator that numbers the frames. ++ iter = itertools.izip (itertools.count (0), iter) ++ ++ # Reverse if the user wanted that. ++ if self.reverse.value: ++ iter = self.reverse_iter (iter) ++ ++ # Extract sub-range user wants. ++ if count < 0: ++ iter = self.final_n (iter, count) ++ elif count > 0: ++ iter = itertools.islice (iter, 0, count) ++ ++ for pair in iter: ++ sys.stdout.write ("#%-2d" % pair[0]) ++ pair[1].describe (sys.stdout, full) ++ ++FilteringBacktrace() +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/ignore_errors.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/ignore_errors.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,37 @@ ++# Ignore errors in user commands. ++ ++# Copyright (C) 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 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 . ++ ++import gdb ++ ++class IgnoreErrorsCommand (gdb.Command): ++ """Execute a single command, ignoring all errors. ++Only one-line commands are supported. ++This is primarily useful in scripts.""" ++ ++ def __init__ (self): ++ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", ++ gdb.COMMAND_OBSCURE, ++ # FIXME... ++ gdb.COMPLETE_COMMAND) ++ ++ def invoke (self, arg, from_tty): ++ try: ++ gdb.execute (arg, from_tty) ++ except: ++ pass ++ ++IgnoreErrorsCommand () +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/pahole.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/pahole.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,75 @@ ++# pahole command for gdb ++ ++# Copyright (C) 2008, 2009 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 . ++ ++import gdb ++ ++class Pahole (gdb.Command): ++ """Show the holes in a structure. ++This command takes a single argument, a type name. ++It prints the type and displays comments showing where holes are.""" ++ ++ def __init__ (self): ++ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE, ++ gdb.COMPLETE_SYMBOL) ++ ++ def pahole (self, type, level, name): ++ if name is None: ++ name = '' ++ tag = type.tag ++ if tag is None: ++ tag = '' ++ print '%sstruct %s {' % (' ' * (2 * level), tag) ++ bitpos = 0 ++ for field in type.fields (): ++ # Skip static fields. ++ if not hasattr (field, ('bitpos')): ++ continue ++ ++ ftype = field.type.strip_typedefs() ++ ++ if bitpos != field.bitpos: ++ hole = field.bitpos - bitpos ++ print ' /* XXX %d bit hole, try to pack */' % hole ++ bitpos = field.bitpos ++ if field.bitsize > 0: ++ fieldsize = field.bitsize ++ else: ++ # TARGET_CHAR_BIT here... ++ fieldsize = 8 * ftype.sizeof ++ ++ # TARGET_CHAR_BIT ++ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), ++ bitpos = bitpos + fieldsize ++ ++ if ftype.code == gdb.TYPE_CODE_STRUCT: ++ self.pahole (ftype, level + 1, field.name) ++ else: ++ print ' ' * (2 + 2 * level), ++ print '%s %s' % (str (ftype), field.name) ++ ++ print ' ' * (14 + 2 * level), ++ print '} %s' % name ++ ++ def invoke (self, arg, from_tty): ++ type = gdb.lookup_type (arg) ++ type = type.strip_typedefs () ++ if type.code != gdb.TYPE_CODE_STRUCT: ++ raise TypeError, '%s is not a struct type' % arg ++ print ' ' * 14, ++ self.pahole (type, 0, '') ++ ++Pahole() +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/require.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/require.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,57 @@ ++# Demand-loading commands. ++ ++# Copyright (C) 2008, 2009 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 . ++ ++import gdb ++import os ++ ++class RequireCommand (gdb.Command): ++ """Prefix command for requiring features.""" ++ ++ def __init__ (self): ++ super (RequireCommand, self).__init__ ("require", ++ gdb.COMMAND_SUPPORT, ++ gdb.COMPLETE_NONE, ++ True) ++ ++class RequireSubcommand (gdb.Command): ++ """Demand-load a command by name.""" ++ ++ def __init__ (self, name): ++ self.__doc__ = "Demand-load a %s by name." % name ++ super (RequireSubcommand, self).__init__ ("require %s" % name, ++ gdb.COMMAND_SUPPORT) ++ self.name = name ++ ++ def invoke (self, arg, from_tty): ++ for cmd in arg.split(): ++ exec ('import gdb.' + self.name + '.' + cmd, globals ()) ++ ++ def complete (self, text, word): ++ dir = gdb.pythondir + '/gdb/' + self.name ++ result = [] ++ for file in os.listdir(dir): ++ if not file.startswith (word) or not file.endswith ('.py'): ++ continue ++ feature = file[0:-3] ++ if feature == 'require' or feature == '__init__': ++ continue ++ result.append (feature) ++ return result ++ ++RequireCommand() ++RequireSubcommand("command") ++RequireSubcommand("function") +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/command/upto.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/command/upto.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,129 @@ ++# upto command. ++ ++# Copyright (C) 2009 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 . ++ ++import gdb ++import re ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++ ++class UptoPrefix (gdb.Command): ++ def __init__ (self): ++ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK, ++ prefix = True) ++ ++class UptoImplementation (gdb.Command): ++ def __init__ (self, subcommand): ++ super (UptoImplementation, self).__init__ ("upto " + subcommand, ++ gdb.COMMAND_STACK) ++ ++ def search (self): ++ saved = gdb.selected_frame () ++ iter = FrameIterator (saved) ++ found = False ++ try: ++ for frame in iter: ++ frame.select () ++ try: ++ if self.filter (frame): ++ wrapper = FrameWrapper (frame) ++ wrapper.describe (sys.stdout, False) ++ return ++ except: ++ pass ++ except: ++ pass ++ saved.select () ++ raise RuntimeError, 'Could not find a matching frame' ++ ++ def invoke (self, arg, from_tty): ++ self.rx = re.compile (arg) ++ self.search () ++ ++class UptoSymbolCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on symbol. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose symbol matches the regular ++expression.""" ++ ++ def __init__ (self): ++ super (UptoSymbolCommand, self).__init__ ("symbol") ++ ++ def filter (self, frame): ++ name = frame.name () ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoSourceCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on source file. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose source file name matches the ++regular expression.""" ++ ++ def __init__ (self): ++ super (UptoSourceCommand, self).__init__ ("source") ++ ++ def filter (self, frame): ++ name = frame.find_sal ().symtab.filename ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoObjectCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on object file. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose object file name matches the ++regular expression.""" ++ ++ def __init__ (self): ++ super (UptoObjectCommand, self).__init__ ("object") ++ ++ def filter (self, frame): ++ name = frame.find_sal ().symtab.objfile.filename ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoWhereCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on expression. ++The argument is an expression. This command moves up the stack, ++parsing and evaluating the expression in each frame. This stops when ++the expression evaluates to a non-zero (true) value.""" ++ ++ def __init__ (self): ++ super (UptoWhereCommand, self).__init__ ("where") ++ ++ def filter (self, frame): ++ try: ++ if gdb.parse_and_eval (self.expression): ++ return True ++ except: ++ pass ++ return False ++ ++ def invoke (self, arg, from_tty): ++ self.expression = arg ++ self.search () ++ ++UptoPrefix () ++UptoSymbolCommand () ++UptoSourceCommand () ++UptoObjectCommand () ++UptoWhereCommand () +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/function/__init__.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/function/__init__.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1 @@ ++ +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/function/caller_is.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/function/caller_is.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,58 @@ ++# Caller-is functions. ++ ++# Copyright (C) 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 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 . ++ ++import gdb ++import re ++ ++class CallerIs (gdb.Function): ++ """Return True if the calling function's name is equal to a string. ++This function takes one or two arguments. ++The first argument is the name of a function; if the calling function's ++name is equal to this argument, this function returns True. ++The optional second argument tells this function how many stack frames ++to traverse to find the calling function. The default is 1.""" ++ ++ def __init__ (self): ++ super (CallerIs, self).__init__ ("caller_is") ++ ++ def invoke (self, name, nframes = 1): ++ frame = gdb.selected_frame () ++ while nframes > 0: ++ frame = frame.older () ++ nframes = nframes - 1 ++ return frame.name () == name.string () ++ ++class CallerMatches (gdb.Function): ++ """Return True if the calling function's name matches a string. ++This function takes one or two arguments. ++The first argument is a regular expression; if the calling function's ++name is matched by this argument, this function returns True. ++The optional second argument tells this function how many stack frames ++to traverse to find the calling function. The default is 1.""" ++ ++ def __init__ (self): ++ super (CallerMatches, self).__init__ ("caller_matches") ++ ++ def invoke (self, name, nframes = 1): ++ frame = gdb.selected_frame () ++ while nframes > 0: ++ frame = frame.older () ++ nframes = nframes - 1 ++ return re.match (name.string (), frame.name ()) is not None ++ ++CallerIs() ++CallerMatches() +Index: gdb-7.3.50.20110722/gdb/python/lib/gdb/function/in_scope.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/python/lib/gdb/function/in_scope.py 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,47 @@ ++# In-scope function. ++ ++# Copyright (C) 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 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 . ++ ++import gdb ++ ++class InScope (gdb.Function): ++ """Return True if all the given variables or macros are in scope. ++Takes one argument for each variable name to be checked.""" ++ ++ def __init__ (self): ++ super (InScope, self).__init__ ("in_scope") ++ ++ def invoke (self, *vars): ++ if len (vars) == 0: ++ raise TypeError, "in_scope takes at least one argument" ++ ++ # gdb.Value isn't hashable so it can't be put in a map. ++ # Convert to string first. ++ wanted = set (map (lambda x: x.string (), vars)) ++ found = set () ++ block = gdb.selected_frame ().block () ++ while block: ++ for sym in block: ++ if (sym.is_argument or sym.is_constant ++ or sym.is_function or sym.is_variable): ++ if sym.name in wanted: ++ found.add (sym.name) ++ ++ block = block.superblock ++ ++ return wanted == found ++ ++InScope () +Index: gdb-7.3.50.20110722/gdb/python/py-type.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/python/py-type.c 2011-06-24 21:47:37.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/python/py-type.c 2011-07-29 22:52:02.000000000 +0200 +@@ -29,6 +29,8 @@ + #include "language.h" + #include "vec.h" + #include "bcache.h" ++#include "observer.h" ++#include "gdb_assert.h" + + typedef struct pyty_type_object + { +@@ -37,11 +39,19 @@ typedef struct pyty_type_object + + /* If a Type object is associated with an objfile, it is kept on a + doubly-linked list, rooted in the objfile. This lets us copy the +- underlying struct type when the objfile is deleted. */ ++ underlying struct type when the objfile is deleted. ++ ++ With NULL objfile Type still can be doubly-linked in the list ++ PYTY_OBJECTS_DISCARDABLE. */ + struct pyty_type_object *prev; + struct pyty_type_object *next; + } type_object; + ++#if 0 ++/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */ ++static type_object *pyty_objects_discardable; ++#endif ++ + static PyTypeObject type_object_type; + + /* A Field object. */ +@@ -919,8 +929,63 @@ typy_richcompare (PyObject *self, PyObje + + + ++/* Key associated with each objfile pointing to the first element of ++ a doubly-linked list of Types associated with this objfile. */ + static const struct objfile_data *typy_objfile_data_key; + ++/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one ++ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types ++ do not get linked anywhere. */ ++static void ++typy_link (type_object *type_obj) ++{ ++ type_obj->prev = NULL; ++ ++ if (type_obj->type && TYPE_OBJFILE (type_obj->type)) ++ { ++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); ++ ++ type_obj->next = objfile_data (objfile, typy_objfile_data_key); ++ if (type_obj->next) ++ type_obj->next->prev = type_obj; ++ set_objfile_data (objfile, typy_objfile_data_key, type_obj); ++ } ++#if 0 ++ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type)) ++ { ++ type_obj->next = pyty_objects_discardable; ++ if (type_obj->next) ++ type_obj->next->prev = type_obj; ++ pyty_objects_discardable = type_obj; ++ } ++#endif ++ else ++ type_obj->next = NULL; ++} ++ ++/* Unlink TYPE_OBJ from its current list. Permanent types are not linked ++ anywhere and this function has no effect on them. */ ++static void ++typy_unlink (type_object *type_obj) ++{ ++ if (type_obj->prev) ++ type_obj->prev->next = type_obj->next; ++ else if (type_obj->type && TYPE_OBJFILE (type_obj->type)) ++ { ++ /* Must reset head of list. */ ++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); ++ ++ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next); ++ } ++#if 0 ++ else if (pyty_objects_discardable == type_obj) ++ pyty_objects_discardable = type_obj->next; ++#endif ++ ++ if (type_obj->next) ++ type_obj->next->prev = type_obj->prev; ++} ++ + static void + save_objfile_types (struct objfile *objfile, void *datum) + { +@@ -938,12 +1003,13 @@ save_objfile_types (struct objfile *objf + { + type_object *next = obj->next; + +- htab_empty (copied_types); ++ gdb_assert (TYPE_OBJFILE (obj->type) == objfile); ++ typy_unlink (obj); + +- obj->type = copy_type_recursive (objfile, obj->type, copied_types); ++ obj->type = copy_type_recursive (obj->type, copied_types); + +- obj->next = NULL; +- obj->prev = NULL; ++ gdb_assert (TYPE_OBJFILE (obj->type) == NULL); ++ typy_link (obj); + + obj = next; + } +@@ -954,43 +1020,28 @@ save_objfile_types (struct objfile *objf + } + + static void +-set_type (type_object *obj, struct type *type) ++typy_dealloc (PyObject *obj) + { +- obj->type = type; +- obj->prev = NULL; +- if (type && TYPE_OBJFILE (type)) +- { +- struct objfile *objfile = TYPE_OBJFILE (type); +- +- obj->next = objfile_data (objfile, typy_objfile_data_key); +- if (obj->next) +- obj->next->prev = obj; +- set_objfile_data (objfile, typy_objfile_data_key, obj); +- } +- else +- obj->next = NULL; ++ type_object *type_obj = (type_object *) obj; ++ ++ typy_unlink (type_obj); ++ ++ type_obj->ob_type->tp_free (obj); + } + ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + static void +-typy_dealloc (PyObject *obj) ++typy_types_mark_used (void) + { +- type_object *type = (type_object *) obj; +- +- if (type->prev) +- type->prev->next = type->next; +- else if (type->type && TYPE_OBJFILE (type->type)) +- { +- /* Must reset head of list. */ +- struct objfile *objfile = TYPE_OBJFILE (type->type); +- +- if (objfile) +- set_objfile_data (objfile, typy_objfile_data_key, type->next); +- } +- if (type->next) +- type->next->prev = type->prev; ++ type_object *type_obj; + +- type->ob_type->tp_free (type); ++ for (type_obj = pyty_objects_discardable; ++ type_obj != NULL; ++ type_obj = type_obj->next) ++ type_mark_used (type_obj->type); + } ++#endif + + /* Create a new Type referring to TYPE. */ + PyObject * +@@ -1000,7 +1051,10 @@ type_to_type_object (struct type *type) + + type_obj = PyObject_New (type_object, &type_object_type); + if (type_obj) +- set_type (type_obj, type); ++ { ++ type_obj->type = type; ++ typy_link (type_obj); ++ } + + return (PyObject *) type_obj; + } +@@ -1074,6 +1128,10 @@ gdbpy_initialize_types (void) + + Py_INCREF (&field_object_type); + PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type); ++ ++#if 0 ++ observer_attach_mark_used (typy_types_mark_used); ++#endif + } + + +Index: gdb-7.3.50.20110722/gdb/python/py-value.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/python/py-value.c 2011-06-27 21:21:51.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/python/py-value.c 2011-07-29 22:52:02.000000000 +0200 +@@ -28,6 +28,7 @@ + #include "infcall.h" + #include "expression.h" + #include "cp-abi.h" ++#include "observer.h" + + #ifdef HAVE_PYTHON + +@@ -1208,6 +1209,19 @@ gdbpy_is_value_object (PyObject *obj) + return PyObject_TypeCheck (obj, &value_object_type); + } + ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ ++ ++static void ++python_types_mark_used (void) ++{ ++ value_object *iter; ++ ++ for (iter = values_in_python; iter; iter = iter->next) ++ type_mark_used (value_type (iter->value)); ++} ++#endif ++ + void + gdbpy_initialize_values (void) + { +@@ -1218,6 +1232,10 @@ gdbpy_initialize_values (void) + PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); + + values_in_python = NULL; ++ ++#if 0 ++ observer_attach_mark_used (python_types_mark_used); ++#endif + } + + +Index: gdb-7.3.50.20110722/gdb/python/python.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/python/python.c 2011-07-21 13:03:47.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/python/python.c 2011-07-29 22:52:02.000000000 +0200 +@@ -49,9 +49,12 @@ static int gdbpy_should_print_stack = 0; + #include "linespec.h" + #include "source.h" + #include "version.h" ++#include "inferior.h" ++#include "gdbthread.h" + #include "target.h" + #include "gdbthread.h" + #include "observer.h" ++#include "event-top.h" + + static PyMethodDef GdbMethods[]; + +@@ -849,6 +852,53 @@ gdbpy_print_stack (void) + + /* Return the current Progspace. + There always is one. */ ++/* True if 'gdb -P' was used, false otherwise. */ ++static int running_python_script; ++ ++/* True if we are currently in a call to 'gdb.cli', false otherwise. */ ++static int in_cli; ++ ++/* Enter the command loop. */ ++ ++static PyObject * ++gdbpy_cli (PyObject *unused1, PyObject *unused2) ++{ ++ if (! running_python_script || in_cli) ++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); ++ ++ in_cli = 1; ++ cli_command_loop (); ++ in_cli = 0; ++ ++ Py_RETURN_NONE; ++} ++ ++/* Set up the Python argument vector and evaluate a script. This is ++ used to implement 'gdb -P'. */ ++ ++void ++run_python_script (int argc, char **argv) ++{ ++ FILE *input; ++ ++ /* We never free this, since we plan to exit at the end. */ ++ ensure_python_env (get_current_arch (), current_language); ++ ++ running_python_script = 1; ++ PySys_SetArgv (argc - 1, argv + 1); ++ input = fopen (argv[0], "r"); ++ if (! input) ++ { ++ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); ++ exit (1); ++ } ++ PyRun_SimpleFile (input, argv[0]); ++ fclose (input); ++ exit (0); ++} ++ ++ ++ + + static PyObject * + gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) +@@ -1333,6 +1383,8 @@ static PyMethodDef GdbMethods[] = + "Get a value from history" }, + { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, + "Execute a gdb command" }, ++ { "cli", gdbpy_cli, METH_NOARGS, ++ "Enter the gdb CLI" }, + { "parameter", gdbpy_parameter, METH_VARARGS, + "Return a gdb parameter's value" }, + +Index: gdb-7.3.50.20110722/gdb/python/python.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/python/python.h 2011-03-14 17:09:54.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/python/python.h 2011-07-29 22:52:02.000000000 +0200 +@@ -32,6 +32,8 @@ void eval_python_from_control_command (s + + void source_python_script (FILE *stream, const char *file); + ++void run_python_script (int argc, char **argv); ++ + int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, + int embedded_offset, CORE_ADDR address, + struct ui_file *stream, int recurse, +Index: gdb-7.3.50.20110722/gdb/somread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/somread.c 2011-03-07 17:17:29.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/somread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -439,6 +439,7 @@ static const struct sym_fns som_sym_fns + default_symfile_segments, /* Get segment information from a file. */ + NULL, + default_symfile_relocate, /* Relocate a debug section. */ ++ NULL, /* sym_get_probes */ + &psym_functions + }; + +Index: gdb-7.3.50.20110722/gdb/stack.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/stack.c 2011-06-27 21:21:50.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/stack.c 2011-07-29 22:52:02.000000000 +0200 +@@ -366,6 +366,7 @@ print_frame_args (struct symbol *func, s + { + const struct language_defn *language; + struct value_print_options opts; ++ struct cleanup *old_chain; + + /* Use the appropriate language to display our symbol, + unless the user forced the language to a specific +@@ -378,7 +379,13 @@ print_frame_args (struct symbol *func, s + get_raw_print_options (&opts); + opts.deref_ref = 0; + opts.summary = summary; ++ ++ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */ ++ old_chain = make_cleanup_restore_selected_frame (); ++ select_frame (frame); + common_val_print (val, stb->stream, 2, &opts, language); ++ do_cleanups (old_chain); ++ + ui_out_field_stream (uiout, "value", stb); + } + else +Index: gdb-7.3.50.20110722/gdb/stap-probe.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/stap-probe.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,2042 @@ ++/* SystemTap probe support for GDB. ++ ++ Copyright (C) 2011 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 . */ ++ ++#include "defs.h" ++#include "stap-probe.h" ++#include "vec.h" ++#include "ui-out.h" ++#include "gdb_regex.h" ++#include "objfiles.h" ++#include "arch-utils.h" ++#include "command.h" ++#include "filenames.h" ++#include "value.h" ++#include "exceptions.h" ++#include "ax.h" ++#include "ax-gdb.h" ++#include "user-regs.h" ++#include "complaints.h" ++#include "cli/cli-utils.h" ++#include "linespec.h" ++ ++#include ++ ++/* This define is used to inform whether we are compiling an agent ++ expression or not. */ ++ ++#define STAP_COMPILING_AGENT_EXPR_P(eval_info) \ ++ (eval_info->aexpr != NULL) ++ ++/* The various possibilities of bitness defined for a probe's argument. ++ ++ The relationship is: ++ ++ - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness. ++ - STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'. ++ - STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'. ++ - STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'. ++ - STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */ ++ ++enum stap_arg_bitness ++{ ++ STAP_ARG_BITNESS_UNDEFINED, ++ STAP_ARG_BITNESS_32BIT_UNSIGNED, ++ STAP_ARG_BITNESS_32BIT_SIGNED, ++ STAP_ARG_BITNESS_64BIT_UNSIGNED, ++ STAP_ARG_BITNESS_64BIT_SIGNED, ++}; ++ ++/* The following structure represents a single argument for the probe. */ ++ ++struct stap_probe_arg ++{ ++ /* The bitness of this argument. */ ++ enum stap_arg_bitness bitness; ++ ++ /* The string representing this argument. */ ++ char *arg_str; ++}; ++ ++/* The maximum number of arguments that a probe can have, ++ as defined in . */ ++ ++#define STAP_MAX_ARGS 10 ++ ++/* Structure that holds information about all arguments of a probe. */ ++ ++struct stap_args_info ++{ ++ /* The number of valid parsed arguments. */ ++ int n_args; ++ ++ /* The probe to which these arguments belong. */ ++ struct stap_probe *probe; ++ ++ /* Information about each argument. */ ++ struct stap_probe_arg *arg; ++}; ++ ++/* Structure that contains all the necessary information to evaluate ++ an expression. */ ++ ++struct stap_evaluation_info ++{ ++ /* The constant pointer which holds the expression. This is primarily ++ used for printing error messages. Evaluation functions should ++ not modify this pointer directly; instead, they should use the ++ EXP_BUFFER pointer below. */ ++ const char *saved_expr; ++ ++ /* Modifiable version of the above pointer. */ ++ char *exp_buf; ++ ++ /* The pointer to the current gdbarch. */ ++ struct gdbarch *gdbarch; ++ ++ /* The pointer to the current frame, used when accessing registers' ++ contents. */ ++ struct frame_info *frame; ++ ++ /* The bitness specified for this argument. */ ++ enum stap_arg_bitness bitness; ++ ++ /* If the above flag is true (one), this field will contain the ++ pointer to the agent expression. */ ++ struct agent_expr *aexpr; ++ ++ /* The value we are modifying (for agent expression). */ ++ struct axs_value *avalue; ++}; ++ ++/* This dummy variable is used when parsing a probe's argument fails. ++ In this case, the number of arguments for this probe is zero, so that's ++ why this variable is useful. */ ++ ++static struct stap_args_info dummy_stap_args_info = ++ { 0, NULL, NULL }; ++ ++static struct value *stap_evaluate_probe_argument_2 ++ (struct stap_evaluation_info *eval_info, ++ struct value *lhs, int prec); ++ ++static struct value *stap_evaluate_conditionally ++ (struct stap_evaluation_info *eval_info); ++ ++/* Helper function which decides to skip whitespaces or not in a probe's ++ argument string. Basically, if we are inside a parenthesis expression ++ (i.e., inside a subexpression), we can skip whitespaces; otherwise we ++ cannot. */ ++ ++static void ++stap_skip_whitespace_cond (char **s, int inside_paren) ++{ ++ if (inside_paren) ++ *s = skip_spaces (*s); ++} ++ ++/* Helper function which parses a single argument in a probe's argument ++ string, based on various rules (which can be learned from the `gas' ++ manual). It returns 1 on success, or 0 otherwise. */ ++ ++static int ++stap_parse_arg (const char **p) ++{ ++ char *cur = (char *) *p; ++ int done = 0; ++ int paren_open = 0; ++ ++ while (!done) ++ { ++ switch (*cur) ++ { ++ case ' ': case 0: ++ /* If we're here, then we have already parsed everything ++ from this argument. */ ++ if (paren_open) ++ return 0; ++ done = 1; ++ break; ++ ++ case '(': ++ ++paren_open; ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ break; ++ ++ case ')': ++ if (!paren_open) ++ return 0; ++ ++ --paren_open; ++ ++cur; ++ if (paren_open) ++ cur = skip_spaces (cur); ++ break; ++ ++ case '+': case '-': ++ case '*': case '/': ++ case '>': case '<': case '|': case '&': ++ case '^': case '!': ++ { ++ char c = *cur; ++ ++ ++cur; ++ switch (*cur) ++ { ++ case '>': ++ if (c != '<' && c != '>') ++ return 0; ++ ++ ++cur; ++ break; ++ ++ case '<': ++ if (c != '<') ++ return 0; ++ ++ ++cur; ++ break; ++ ++ case '=': ++ if (c != '=' && c != '<' && c != '>' && c != '!') ++ return 0; ++ ++ ++cur; ++ break; ++ ++ case '|': ++ if (c != '|') ++ return 0; ++ ++ ++cur; ++ break; ++ ++ case '&': ++ if (c != '&') ++ return 0; ++ ++ ++cur; ++ break; ++ ++ default: ++ break; ++ } ++ /* Infix operators take two arguments, one on either ++ side. Skipping the whitespaces that may happen on the ++ right side. */ ++ stap_skip_whitespace_cond (&cur, paren_open); ++ } ++ break; ++ ++ case '%': ++ { ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ if (*cur >= 'a' && *cur <= 'z') ++ { ++ /* We're dealing with a register name. */ ++ while (isalnum (*cur)) ++ ++cur; ++ ++ stap_skip_whitespace_cond (&cur, paren_open); ++ ++ /* Some registers (e.g. floating-point register stack ++ registers on Intel i386) have the following syntax: ++ ++ `%st(0)', `%st(1)', and so on. ++ ++ So it's ok to expect parenthesis here. */ ++ if (*cur == '(') ++ { ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ if (!isdigit (*cur)) ++ /* This is an error, since we only expect numbers ++ inside this parenthesis. */ ++ return 0; ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ if (*cur != ')') ++ /* We only expect one number. */ ++ return 0; ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ } ++ } ++ } ++ break; ++ ++ case '$': ++ { ++ /* This is an integer constant. */ ++ ++cur; ++ stap_skip_whitespace_cond (&cur, paren_open); ++ ++ while (isdigit (*cur)) ++ ++cur; ++ ++ stap_skip_whitespace_cond (&cur, paren_open); ++ } ++ break; ++ ++ case '0': case '1': case '2': case '3': case '4': ++ case '5': case '6': case '7': case '8': case '9': ++ { ++ char *old = cur; ++ ++ /* Number. */ ++ while (isdigit (*cur)) ++ ++cur; ++ ++ /* We have to do a lookahead here, because the user may ++ input `2 + 2' (with spaces), and this is not an error. */ ++ cur = skip_spaces (cur); ++ ++ switch (*cur) ++ { ++ case '+': case '-': ++ /* We may find the `@' sign, and it means that the ++ argument has finished, so we shouldn't advance the ++ pointer. */ ++ if (cur[1] && (cur[1] == '4' || cur[1] == '8') ++ && cur[2] && cur[2] == '@') ++ { ++ cur = old; ++ goto fin; ++ } ++ break; ++ ++ case '*': case '/': case '>': case '<': ++ case '|': case '&': case '^': case '!': ++ /* This is a binary operation, which means we'll ++ have to find another number after the operator. */ ++ break; ++ ++ case '(': ++ /* We may also have sentences in the form: ++ ++ `4 (%rax)' */ ++ break; ++ } ++ } ++fin: ++ break; ++ } ++ } ++ ++ *p = cur; ++ ++ return 1; ++} ++ ++/* Helper function which is responsible for freeing the space allocated to ++ hold information about a probe's arguments. */ ++ ++static void ++stap_free_args_info (void *args_info_ptr) ++{ ++ struct stap_args_info *a = (struct stap_args_info *) args_info_ptr; ++ int i; ++ ++ for (i = 0; i < a->n_args; i++) ++ xfree (a->arg[i].arg_str); ++ ++ xfree (a->arg); ++ xfree (a); ++} ++ ++/* Function which parses an argument string from PROBE, correctly splitting ++ the arguments and storing their information in properly ways. This function ++ only separates the arguments, but does not evaluate them. ++ ++ Consider the following argument string: ++ ++ `4@%eax 4@$10' ++ ++ We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness. ++ This function basically handles them, properly filling some structures with ++ this information. */ ++ ++static void ++stap_parse_probe_arguments (struct stap_probe *probe) ++{ ++ struct stap_args_info *args_info; ++ struct cleanup *back_to; ++ const char *cur = probe->args; ++ int current_arg = -1; ++ /* This is a state-machine parser, which means we will always be ++ in a known state when parsing an argument. The state could be ++ either `NEW_ARG' if we are parsing a new argument, `BITNESS' if ++ we are parsing the bitness-definition part (i.e., `4@'), or ++ `PARSE_ARG' if we are actually parsing the argument part. */ ++ enum ++ { ++ NEW_ARG, ++ BITNESS, ++ PARSE_ARG, ++ } current_state; ++ ++ /* For now, we assume everything is not going to work. */ ++ probe->parsed_args = &dummy_stap_args_info; ++ ++ if (!cur || !*cur || *cur == ':') ++ return; ++ ++ args_info = xmalloc (sizeof (struct stap_args_info)); ++ args_info->n_args = 0; ++ back_to = make_cleanup (stap_free_args_info, args_info); ++ args_info->arg = xcalloc (STAP_MAX_ARGS, sizeof (struct stap_probe_arg)); ++ ++ /* Ok, let's start. */ ++ current_state = NEW_ARG; ++ ++ while (*cur) ++ { ++ switch (current_state) ++ { ++ case NEW_ARG: ++ ++current_arg; ++ ++ if (current_arg >= STAP_MAX_ARGS) ++ { ++ complaint (&symfile_complaints, ++ _("probe `%s' has more arguments than the maximum " ++ "allowed"), probe->name); ++ do_cleanups (back_to); ++ return; ++ } ++ ++ current_state = BITNESS; ++ break; ++ ++ case BITNESS: ++ { ++ enum stap_arg_bitness b; ++ int got_minus = 0; ++ ++ /* We expect to find something like: ++ ++ N@OP ++ ++ Where `N' can be [+,-][4,8]. This is not mandatory, so ++ we check it here. If we don't find it, go to the next ++ state. */ ++ if ((*cur == '-' && cur[1] && cur[2] != '@') ++ && cur[1] != '@') ++ { ++ current_state = PARSE_ARG; ++ args_info->arg[current_arg].bitness ++ = STAP_ARG_BITNESS_UNDEFINED; ++ break; ++ } ++ ++ if (*cur == '-') ++ { ++ /* Discard the `-'. */ ++ ++cur; ++ got_minus = 1; ++ } ++ ++ if (*cur == '4') ++ b = got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED ++ : STAP_ARG_BITNESS_32BIT_UNSIGNED; ++ else if (*cur == '8') ++ b = got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED ++ : STAP_ARG_BITNESS_64BIT_UNSIGNED; ++ else ++ { ++ /* We have an error, because we don't expect anything ++ except 4 and 8. */ ++ complaint (&symfile_complaints, ++ _("unrecognized bitness `%c' for probe `%s'"), ++ *cur, probe->name); ++ do_cleanups (back_to); ++ return; ++ } ++ ++ args_info->arg[current_arg].bitness = b; ++ /* Discard the number and the `@' sign. */ ++ cur += 2; ++ /* Move on. */ ++ current_state = PARSE_ARG; ++ } ++ break; ++ ++ case PARSE_ARG: ++ { ++ const char *start = cur; ++ ++ if (!stap_parse_arg (&cur)) ++ { ++ /* We have tried to parse this argument, but it's ++ malformed. This is an error. */ ++ do_cleanups (back_to); ++ return; ++ } ++ ++ args_info->arg[current_arg].arg_str ++ = savestring (start, cur - start); ++ ++args_info->n_args; ++ /* Start it over again. */ ++ cur = skip_spaces ((char *) cur); ++ current_state = NEW_ARG; ++ } ++ break; ++ } ++ ++ if (!*cur && current_state != NEW_ARG) ++ { ++ /* We reached the end of the argument string, but we're ++ still in the middle of the process of parsing an argument. ++ It means the argument string is malformed. */ ++ complaint (&symfile_complaints, ++ _("malformed argument for probe `%s'"), ++ probe->name); ++ do_cleanups (back_to); ++ return; ++ } ++ } ++ ++ args_info->arg = xrealloc (args_info->arg, ++ args_info->n_args ++ * sizeof (struct stap_probe_arg)); ++ args_info->probe = probe; ++ ++ probe->parsed_args = args_info; ++ ++ discard_cleanups (back_to); ++} ++ ++/* See definition in stap-probe.h. */ ++ ++int ++stap_get_probe_argument_count (const struct stap_probe *probe) ++{ ++ if (!probe->parsed_args) ++ stap_parse_probe_arguments ((struct stap_probe *) probe); ++ ++ return probe->parsed_args->n_args; ++} ++ ++/* Returns the operator precedence level of OP, or zero if the operator ++ code was not recognized. ++ The levels were taken from the gas manual. */ ++ ++static int ++stap_get_operator_prec (enum exp_opcode op) ++{ ++ switch (op) ++ { ++ case BINOP_LOGICAL_OR: ++ return 1; ++ ++ case BINOP_LOGICAL_AND: ++ return 2; ++ ++ case BINOP_ADD: case BINOP_SUB: ++ case BINOP_EQUAL: case BINOP_NOTEQUAL: ++ case BINOP_LESS: case BINOP_LEQ: ++ case BINOP_GTR: case BINOP_GEQ: ++ return 3; ++ ++ case BINOP_BITWISE_IOR: case BINOP_BITWISE_AND: ++ case BINOP_BITWISE_XOR: case UNOP_LOGICAL_NOT: ++ return 4; ++ ++ case BINOP_MUL: case BINOP_DIV: case BINOP_REM: ++ case BINOP_LSH: case BINOP_RSH: ++ return 5; ++ ++ default: ++ return 0; ++ } ++} ++ ++/* Given S, this function reads the operator in it and fills the OP ++ pointer with its code. Returns 1 on success, zero if the operator ++ was not recognized. */ ++ ++static int ++stap_get_opcode (char **s, enum exp_opcode *op) ++{ ++ char c = **s; ++ int ret = 1; ++ ++ *s += 1; ++ ++ switch (c) ++ { ++ case '*': ++ *op = BINOP_MUL; ++ break; ++ ++ case '/': ++ *op = BINOP_DIV; ++ break; ++ ++ case '%': ++ { ++ if (isalpha (**s)) ++ { ++ /* Dealing with a register name. */ ++ ret = 0; ++ break; ++ } ++ ++ *op = BINOP_REM; ++ } ++ break; ++ ++ case '<': ++ *op = BINOP_LESS; ++ if (**s == '<') ++ { ++ *s += 1; ++ *op = BINOP_LSH; ++ } ++ else if (**s == '=') ++ { ++ *s += 1; ++ *op = BINOP_LEQ; ++ } ++ else if (**s == '>') ++ { ++ *s += 1; ++ *op = BINOP_NOTEQUAL; ++ } ++ break; ++ ++ case '>': ++ *op = BINOP_GTR; ++ if (**s == '>') ++ { ++ *s += 1; ++ *op = BINOP_RSH; ++ } ++ else if (**s == '=') ++ { ++ *s += 1; ++ *op = BINOP_GEQ; ++ } ++ break; ++ ++ case '|': ++ *op = BINOP_BITWISE_IOR; ++ if (**s == '|') ++ { ++ *s += 1; ++ *op = BINOP_LOGICAL_OR; ++ } ++ break; ++ ++ case '&': ++ *op = BINOP_BITWISE_AND; ++ if (**s == '&') ++ { ++ *s += 1; ++ *op = BINOP_LOGICAL_AND; ++ } ++ break; ++ ++ case '^': ++ *op = BINOP_BITWISE_XOR; ++ break; ++ ++ case '!': ++ *op = UNOP_LOGICAL_NOT; ++ break; ++ ++ case '+': ++ *op = BINOP_ADD; ++ break; ++ ++ case '-': ++ *op = BINOP_SUB; ++ break; ++ ++ case '=': ++ if (**s != '=') ++ { ++ ret = 0; ++ break; ++ } ++ *op = BINOP_EQUAL; ++ break; ++ ++ default: ++ /* We didn't find any operator. */ ++ *s -= 1; ++ return 0; ++ } ++ ++ return ret; ++} ++ ++/* Given the operator OPCODE, this function generates agent bytecode ++ for it. */ ++ ++static void ++stap_opcode_to_ax (struct stap_evaluation_info *eval_info, ++ enum exp_opcode opcode) ++{ ++ struct agent_expr *expr = eval_info->aexpr; ++ ++ switch (opcode) ++ { ++ case BINOP_MUL: ++ ax_simple (expr, aop_mul); ++ break; ++ ++ case BINOP_DIV: ++ ax_simple (expr, aop_div_signed); ++ break; ++ ++ case BINOP_REM: ++ ax_simple (expr, aop_rem_unsigned); ++ break; ++ ++ case BINOP_LESS: ++ ax_simple (expr, aop_less_signed); ++ break; ++ ++ case BINOP_LEQ: ++ /* A <= B is !(B < A) */ ++ ax_simple (expr, aop_swap); ++ ax_simple (expr, aop_less_signed); ++ ax_simple (expr, aop_log_not); ++ break; ++ ++ case BINOP_GTR: ++ /* A > B is B < A */ ++ ax_simple (expr, aop_swap); ++ ax_simple (expr, aop_less_signed); ++ break; ++ ++ case BINOP_GEQ: ++ /* A >= B is !(A < B) */ ++ ax_simple (expr, aop_less_signed); ++ ax_simple (expr, aop_log_not); ++ break; ++ ++ case BINOP_NOTEQUAL: ++ ax_simple (expr, aop_equal); ++ ax_simple (expr, aop_log_not); ++ break; ++ ++ case BINOP_LSH: ++ ax_simple (expr, aop_lsh); ++ break; ++ ++ case BINOP_RSH: ++ ax_simple (expr, aop_rsh_unsigned); ++ break; ++ ++ case BINOP_BITWISE_IOR: ++ ax_simple (expr, aop_bit_or); ++ break; ++ ++ case BINOP_LOGICAL_OR: ++ error (_("Operator logical-or (`||') not supported yet.")); ++ break; ++ ++ case BINOP_BITWISE_AND: ++ ax_simple (expr, aop_bit_and); ++ break; ++ ++ case BINOP_LOGICAL_AND: ++ error (_("Operator logical-and (`&&') not supported yet.")); ++ break; ++ ++ case BINOP_BITWISE_XOR: ++ ax_simple (expr, aop_bit_xor); ++ break; ++ ++ case UNOP_LOGICAL_NOT: ++ ax_simple (expr, aop_log_not); ++ break; ++ ++ case BINOP_ADD: ++ ax_simple (expr, aop_add); ++ break; ++ ++ case BINOP_SUB: ++ ax_simple (expr, aop_sub); ++ break; ++ ++ case BINOP_EQUAL: ++ ax_simple (expr, aop_equal); ++ break; ++ ++ default: ++ error (_("Invalid operator.")); ++ } ++} ++ ++/* Returns 1 if *S is an operator, zero otherwise. */ ++ ++static int ++stap_is_operator (char *s) ++{ ++ char op; ++ ++ if (!s || !*s) ++ return 0; ++ ++ op = *s; ++ ++ if (*s == '%' && isalpha (s[1])) ++ /* Register name. */ ++ return 0; ++ ++ return (op == '+' || op == '-' || op == '*' || op == '/' ++ || op == '>' || op == '<' || op == '!' || op == '^' ++ || op == '|' || op == '&' || op == '%' || op == '='); ++} ++ ++/* This function fetches the value of the register whose ++ name starts in the expression buffer. It also applies any register ++ displacements (e.g., `-4(%eax)'), and indirects the contents of the ++ register (e.g., `(%eax)'). It returns RET if the operation has succeeded, ++ or calls `error' otherwise. */ ++ ++static struct value * ++stap_fetch_reg_value (struct stap_evaluation_info *eval_info, ++ struct value *displacement) ++{ ++ const char *start; ++ char *s = eval_info->exp_buf; ++ struct gdbarch *gdbarch = eval_info->gdbarch; ++ struct frame_info *frame = eval_info->frame; ++ enum stap_arg_bitness bitness = eval_info->bitness; ++ char *regname; ++ int len, regnum, indirect_p = 0; ++ struct value *ret = NULL; ++ ++ /* The function which called us did not check if the expression ++ buffer was empty. */ ++ gdb_assert (s && *s); ++ ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ /* If we are compiling, we cannot return NULL because that would ++ lead to errors in future evaluations. That's why we just make ++ this dummy value, representing that the return value of this ++ function is not NULL. */ ++ ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); ++ ++ /* Valid register name on x86 platforms are: ++ ++ [paren]%{a-z0-9}[paren] ++ ++ Let's check for that here. */ ++ if (*s == '(') ++ { ++ ++s; ++ if (!*s || *s != '%' ++ || (*s == '%' && !isalpha (s[1]))) ++ error (_("Invalid register name on expression `%s'."), ++ eval_info->saved_expr); ++ ++s; ++ /* The presence of parenthesis means that we want to indirect ++ the register. */ ++ indirect_p = 1; ++ } ++ else if (*s == '%') ++ { ++ ++s; ++ if (!*s || !isalpha (*s)) ++ error (_("Invalid register name on expression `%s'."), ++ eval_info->saved_expr); ++ } ++ else ++ error (_("Invalid register name on expression `%s'."), ++ eval_info->saved_expr); ++ ++ if (displacement && !indirect_p) ++ /* We cannot apply displacement to non-indirect register access. */ ++ error (_("Trying to apply displacement without indirecting register " ++ "on expression `%s'."), eval_info->saved_expr); ++ ++ /* Ok, let's calculate the size of the register name. */ ++ start = s; ++ while (isalnum (*s)) ++ ++s; ++ ++ len = s - start; ++ ++ if (indirect_p && *s == ')') ++ ++s; ++ ++ regname = alloca (len + 1); ++ strncpy (regname, start, len); ++ regname[len] = '\0'; ++ ++ /* Translating the register name into the corresponding number. */ ++ regnum = user_reg_map_name_to_regnum (gdbarch, regname, len); ++ ++ if (regnum == -1) ++ error (_("Invalid register name `%s' on expression `%s'."), ++ regname, eval_info->saved_expr); ++ ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ ax_reg (eval_info->aexpr, regnum); ++ else ++ ret = value_of_register (regnum, frame); ++ ++ if (indirect_p) ++ { ++ struct type *t = NULL; ++ enum agent_op aop = aop_ref32; ++ ++ /* If the user has specified that the register must be indirected, ++ we should know what's the correct type to cast it before making ++ the indirection. This type corresponds to the bitness specified ++ before the `@' sign on the argument string, or it defaults to ++ `unsigned long' if the `@' were not present. */ ++ ++ switch (bitness) ++ { ++ case STAP_ARG_BITNESS_UNDEFINED: ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ { ++ if (gdbarch_addr_bit (gdbarch) == 32) ++ aop = aop_ref32; ++ else ++ aop = aop_ref64; ++ } ++ else ++ { ++ if (gdbarch_addr_bit (gdbarch) == 32) ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_uint32); ++ else ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_uint64); ++ } ++ break; ++ ++ case STAP_ARG_BITNESS_32BIT_SIGNED: ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ aop = aop_ref32; ++ else ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_int32); ++ break; ++ ++ case STAP_ARG_BITNESS_32BIT_UNSIGNED: ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ aop = aop_ref32; ++ else ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_uint32); ++ break; ++ ++ case STAP_ARG_BITNESS_64BIT_SIGNED: ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ aop = aop_ref64; ++ else ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_int64); ++ break; ++ ++ case STAP_ARG_BITNESS_64BIT_UNSIGNED: ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ aop = aop_ref64; ++ else ++ t = lookup_pointer_type ++ (builtin_type (gdbarch)->builtin_uint64); ++ break; ++ ++ default: ++ internal_error (__FILE__, __LINE__, ++ _("Undefined bitness for probe.")); ++ break; ++ } ++ ++ if (displacement) ++ { ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ { ++ ax_const_l (eval_info->aexpr, value_as_long (displacement)); ++ ax_simple (eval_info->aexpr, aop_add); ++ } ++ else ++ ret = value_ptradd (ret, value_as_long (displacement)); ++ } ++ ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ { ++ if (trace_kludge) ++ { ++ gdb_assert (aop == aop_ref32 || aop == aop_ref64); ++ ax_trace_quick (eval_info->aexpr, aop == aop_ref32 ? 4 : 8); ++ } ++ ax_simple (eval_info->aexpr, aop); ++ } ++ else ++ { ++ ret = value_cast (t, ret); ++ ret = value_ind (ret); ++ } ++ } ++ ++ /* Updating the expression buffer pointer, because we have made ++ some modifications to it before. */ ++ eval_info->exp_buf = s; ++ ++ return ret; ++} ++ ++/* This function tries to evaluate a single operand of the expression. ++ ++ Single operands can be: ++ ++ - unary operators `-' and `~'; ++ - integer constants (beginning with `$'); ++ - register access, with/out displacement and indirection. */ ++ ++static struct value * ++stap_evaluate_single_operand (struct stap_evaluation_info *eval_info) ++{ ++ struct gdbarch *gdbarch = eval_info->gdbarch; ++ struct frame_info *frame = eval_info->frame; ++ enum stap_arg_bitness bitness = eval_info->bitness; ++ struct value *res = NULL; ++ ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ /* If we are compiling, we cannot return NULL because that would ++ lead to errors in future evaluations. That's why we just make ++ this dummy value, representing that the return value of this ++ function is not NULL. */ ++ res = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); ++ ++ switch (*eval_info->exp_buf) ++ { ++ case '-': case '~': ++ { ++ char c = *eval_info->exp_buf; ++ ++ /* This is an unary operator (either `-' or `~'). ++ ++ If it is followed by a parenthesis, and this parenthesis ++ is NOT followed by a `%', then we are dealing with an expression ++ like `-(2 + 3)' or `~(2 + 3)'. We just have to treat separately ++ and return the result after applying the operation (`-' or `~'). ++ ++ If it is followed by a digit, then we have only one choice: it ++ is a displacement argument for a register access, like ++ `-4(%eax)'. It also means that the operator can *only* be `-', ++ and the characters immediately after the number *must* be `(%'. ++ ++ If it is followed by a `$', then it is an integer constant, and ++ we should apply the correct operation to it. */ ++ ++ ++eval_info->exp_buf; ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ if (*eval_info->exp_buf ++ && *eval_info->exp_buf == '(' ++ && eval_info->exp_buf[1] != '%') ++ { ++ struct value *tmp_res; ++ ++ /* We're not dealing with a register name, but with an ++ expression like `-(2 + 3)' or `~(2 + 3)'. We first have ++ to evaluate the right side of the expression (i.e., the ++ parenthesis), and then apply the specified operation ++ (either `-' or `~') to it. */ ++ tmp_res = stap_evaluate_conditionally (eval_info); ++ ++ if (c == '-') ++ { ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ { ++ /* We have to add `-1' to the stack, and multiply ++ the two values. */ ++ ax_const_l (eval_info->aexpr, -1); ++ ax_simple (eval_info->aexpr, aop_mul); ++ } ++ else ++ res = value_neg (tmp_res); ++ } ++ else ++ { ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ ax_simple (eval_info->aexpr, aop_bit_not); ++ else ++ res = value_complement (tmp_res); ++ } ++ } ++ else if (isdigit (*eval_info->exp_buf)) ++ { ++ int number; ++ ++ /* This is a number, so it MUST be a register displacement. ++ The only operator allowed here is `-', it MUST be ++ followed by a number, and the number MUST be followed by ++ `(%'. */ ++ if (c != '-') ++ error (_("Invalid operator `%c' for register displacement " ++ "on expression `%s'."), c, eval_info->saved_expr); ++ ++ number = strtol (eval_info->exp_buf, ++ &eval_info->exp_buf, 0) * -1; ++ ++ if (!*eval_info->exp_buf ++ || *eval_info->exp_buf != '(' ++ || (*eval_info->exp_buf == '(' ++ && eval_info->exp_buf[1] != '%')) ++ error (_("Invalid method of indirecting a register on " ++ "expression `%s'."), eval_info->saved_expr); ++ ++ res ++ = value_from_longest (builtin_type (gdbarch)->builtin_int, ++ number); ++ ++ res = stap_fetch_reg_value (eval_info, res); ++ } ++ else if (*eval_info->exp_buf == '$') ++ { ++ int number; ++ ++ /* Last case. We are dealing with an integer constant, so ++ we must read it and then apply the necessary operation, ++ either `-' or `~'. */ ++ ++eval_info->exp_buf; ++ number = strtol (eval_info->exp_buf, ++ &eval_info->exp_buf, 0); ++ ++ if (!STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ res ++ = value_from_longest (builtin_type (gdbarch)->builtin_int, ++ number); ++ else ++ ax_const_l (eval_info->aexpr, number); ++ ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ ++ if (c == '-') ++ { ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ ax_simple (eval_info->aexpr, aop_log_not); ++ else ++ res = value_neg (res); ++ } ++ else ++ { ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ ax_simple (eval_info->aexpr, aop_bit_not); ++ else ++ res = value_complement (res); ++ } ++ } ++ else ++ error (_("Invalid operand to unary operator `%c' on " ++ "expression `%s'."), c, eval_info->saved_expr); ++ } ++ break; ++ ++ case '0': case '1': case '2': case '3': case '4': ++ case '5': case '6': case '7': case '8': case '9': ++ { ++ int number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0); ++ ++ /* This is a register displacement with a positive value. We read ++ the number, and then check for the mandatory `(%' part. */ ++ if (!*eval_info->exp_buf ++ || !(*eval_info->exp_buf == '(' ++ && eval_info->exp_buf[1] == '%')) ++ error (_("Invalid register access on expression `%s'."), ++ eval_info->saved_expr); ++ ++ res = value_from_longest (builtin_type (gdbarch)->builtin_int, ++ number); ++ ++ res = stap_fetch_reg_value (eval_info, res); ++ } ++ break; ++ ++ case '$': ++ { ++ int number; ++ ++ /* This is an integer constant. We just have to read the number ++ and return it. */ ++ ++eval_info->exp_buf; ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ ++ number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0); ++ ++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info)) ++ ax_const_l (eval_info->aexpr, number); ++ else ++ res = value_from_longest (builtin_type (gdbarch)->builtin_int, ++ number); ++ ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ } ++ break; ++ ++ case '(': case '%': ++ { ++ /* Register access, with or without indirection. */ ++ res = stap_fetch_reg_value (eval_info, /*displacement=*/NULL); ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ } ++ break; ++ ++ default: ++ { ++ error (_("Operator `%c' not recognized on expression `%s'."), ++ *eval_info->exp_buf, eval_info->saved_expr); ++ } ++ } ++ ++ return res; ++} ++ ++/* This function is responsible for checking the necessary type of evaluation ++ depending on what is the next "thing" in the buffer. Valid values are: ++ ++ - Unary operators; ++ - Integer constants; ++ - Register displacement, indirection, and direct access; ++ - Parenthesized operand. */ ++ ++static struct value * ++stap_evaluate_conditionally (struct stap_evaluation_info *eval_info) ++{ ++ char *s = eval_info->exp_buf; ++ struct value *ret = NULL; ++ ++ if (*s == '-' || *s == '~' /* Unary operators. */ ++ || *s == '$' /* Number (integer constant). */ ++ || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */ ++ || (*s == '(' && s[1] == '%') /* Register indirection. */ ++ || (*s == '%' && isalpha (s[1]))) /* Register value. */ ++ /* This is a single operand, so just evaluate it and return. */ ++ ret = stap_evaluate_single_operand (eval_info); ++ else if (*s == '(') ++ { ++ /* We are dealing with a parenthesized operand. It means we ++ have to evaluate it as it was a separate expression, without ++ left-side or precedence. */ ++ ++eval_info->exp_buf; ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ ++ ret = stap_evaluate_probe_argument_2 (eval_info, ++ /*lhs=*/NULL, /*prec=*/0); ++ ++ if (*eval_info->exp_buf != ')') ++ error (_("Missign close-paren on expression `%s'."), ++ eval_info->saved_expr); ++ ++ ++eval_info->exp_buf; ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ } ++ else ++ error (_("Cannot evaluate expression `%s'."), ++ eval_info->saved_expr); ++ ++ return ret; ++} ++ ++/* Evaluation function for probe's argument expressions. LHS represents ++ the left side of the expression, and PREC is the precedence of the ++ last operator identified before calling the function. */ ++ ++static struct value * ++stap_evaluate_probe_argument_2 (struct stap_evaluation_info *eval_info, ++ struct value *lhs, int prec) ++{ ++ struct value *rhs = NULL; ++ int compiling_p = STAP_COMPILING_AGENT_EXPR_P (eval_info); ++ ++ /* This is an operator-precedence parser and evaluator. ++ ++ We work with left- and right-sides of expressions, and ++ evaluate them depending on the precedence of the operators ++ we find. */ ++ ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ ++ if (!lhs) ++ /* We were called without a left-side, either because this is the ++ first call, or because we were called to evaluate a parenthesized ++ expression. It doesn't really matter; we have to evaluate the ++ left-side in order to continue the process. */ ++ lhs = stap_evaluate_conditionally (eval_info); ++ ++ /* Start to evaluate the right-side, and to "join" left and right sides ++ depending on the operation specified. ++ ++ This loop shall continue until we run out of characters in the input, ++ or until we find a close-parenthesis, which means that we've reached ++ the end of a sub-expression. */ ++ while (eval_info->exp_buf ++ && *eval_info->exp_buf ++ && *eval_info->exp_buf != ')') ++ { ++ char *tmp_exp_buf; ++ enum exp_opcode opcode; ++ int cur_prec; ++ ++ if (!stap_is_operator (eval_info->exp_buf)) ++ error (_("Invalid operator `%c' on expression `%s'."), ++ *eval_info->exp_buf, eval_info->saved_expr); ++ ++ /* We have to save the current value of the expression buffer because ++ the `stap_get_opcode' modifies it in order to get the current ++ operator. If this operator's precedence is lower than PREC, we ++ should return and not advance the expression buffer pointer. */ ++ tmp_exp_buf = eval_info->exp_buf; ++ stap_get_opcode (&tmp_exp_buf, &opcode); ++ ++ cur_prec = stap_get_operator_prec (opcode); ++ if (cur_prec < prec) ++ /* If the precedence of the operator that we are seeing now is ++ lower than the precedence of the first operator seen before ++ this evaluation process began, it means we should stop evaluating ++ and return. */ ++ break; ++ ++ eval_info->exp_buf = tmp_exp_buf; ++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf); ++ ++ /* Evaluate the right-side of the expression. */ ++ rhs = stap_evaluate_conditionally (eval_info); ++ ++ /* While we still have operators, try to evaluate another ++ right-side, but using the current right-side as a left-side. */ ++ while (*eval_info->exp_buf ++ && stap_is_operator (eval_info->exp_buf)) ++ { ++ enum exp_opcode lookahead_opcode; ++ int lookahead_prec; ++ ++ /* Saving the current expression buffer position. The explanation ++ is the same as above. */ ++ tmp_exp_buf = eval_info->exp_buf; ++ stap_get_opcode (&tmp_exp_buf, &lookahead_opcode); ++ lookahead_prec = stap_get_operator_prec (lookahead_opcode); ++ ++ if (lookahead_prec <= prec) ++ /* If we are dealing with an operator whose precedence is lower ++ than the first one, just abandon the attempt. */ ++ break; ++ ++ rhs = stap_evaluate_probe_argument_2 (eval_info, ++ rhs, lookahead_prec); ++ } ++ ++ /* Now, "join" both left and right sides into one left-side, using ++ the specified operator. */ ++ if (compiling_p) ++ stap_opcode_to_ax (eval_info, opcode); ++ else ++ lhs = value_binop (lhs, rhs, opcode); ++ } ++ ++ return lhs; ++} ++ ++/* This function fills the necessary arguments for the evaluation function ++ to work. */ ++ ++static struct value * ++stap_evaluate_probe_argument_1 (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct frame_info *frame, ++ int n) ++{ ++ struct stap_evaluation_info eval_info; ++ char *s = (char *) probe->parsed_args->arg[n].arg_str; ++ struct value *res, *vs[4]; ++ ++ /* Filling necessary information for evaluation function. */ ++ eval_info.saved_expr = s; ++ eval_info.exp_buf = s; ++ eval_info.gdbarch = get_objfile_arch (objfile); ++ eval_info.frame = frame; ++ eval_info.bitness = probe->parsed_args->arg[n].bitness; ++ /* We are not compiling to an agent expression. */ ++ eval_info.aexpr = NULL; ++ eval_info.avalue = NULL; ++ ++ res = stap_evaluate_probe_argument_2 (&eval_info, ++ /*lhs=*/NULL, /*prec=*/0); ++ ++ if (!res) ++ error (_("Could not evaluate expression `%s'."), ++ eval_info.saved_expr); ++ ++ return res; ++} ++ ++/* See definition in stap-probe.h. */ ++ ++struct value * ++stap_evaluate_probe_argument (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct frame_info *frame, ++ int n) ++{ ++ if (!probe->parsed_args) ++ stap_parse_probe_arguments ((struct stap_probe *) probe); ++ ++ if (!probe->parsed_args->arg ++ || n >= probe->parsed_args->n_args) ++ return NULL; ++ ++ return stap_evaluate_probe_argument_1 (objfile, probe, frame, n); ++} ++ ++/* Helper function which compiles the probe's argument N into an ++ agent expression, suitable for using with tracepoints. */ ++ ++static void ++stap_compile_to_ax_1 (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ int n) ++{ ++ struct stap_evaluation_info eval_info; ++ struct gdbarch *gdbarch = expr->gdbarch; ++ char *s = (char *) probe->parsed_args->arg[n].arg_str; ++ ++ /* Filling necessary information for evaluation function. */ ++ eval_info.saved_expr = s; ++ eval_info.exp_buf = s; ++ eval_info.gdbarch = expr->gdbarch; ++ eval_info.frame = NULL; ++ eval_info.bitness = probe->parsed_args->arg[n].bitness; ++ /* We are compiling to an agent expression. */ ++ eval_info.aexpr = expr; ++ eval_info.avalue = value; ++ ++ /* We can always use this kind. */ ++ value->kind = axs_rvalue; ++ ++ /* Figuring out the correct type for this axs_value. */ ++ switch (eval_info.bitness) ++ { ++ case STAP_ARG_BITNESS_UNDEFINED: ++ if (gdbarch_addr_bit (gdbarch) == 32) ++ value->type = builtin_type (gdbarch)->builtin_uint32; ++ else ++ value->type = builtin_type (gdbarch)->builtin_uint64; ++ break; ++ ++ case STAP_ARG_BITNESS_32BIT_SIGNED: ++ value->type = builtin_type (gdbarch)->builtin_int32; ++ break; ++ ++ case STAP_ARG_BITNESS_32BIT_UNSIGNED: ++ value->type = builtin_type (gdbarch)->builtin_uint32; ++ break; ++ ++ case STAP_ARG_BITNESS_64BIT_SIGNED: ++ value->type = builtin_type (gdbarch)->builtin_int64; ++ break; ++ ++ case STAP_ARG_BITNESS_64BIT_UNSIGNED: ++ value->type = builtin_type (gdbarch)->builtin_uint64; ++ break; ++ ++ default: ++ internal_error (__FILE__, __LINE__, ++ _("Undefined bitness for probe.")); ++ break; ++ } ++ ++ stap_evaluate_probe_argument_2 (&eval_info, ++ /*lhs=*/NULL, /*prec=*/0); ++} ++ ++/* See definition in stap-probe.h. */ ++ ++void ++stap_compile_to_ax (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ int n) ++{ ++ if (!probe->parsed_args) ++ stap_parse_probe_arguments ((struct stap_probe *) probe); ++ ++ if (!probe->parsed_args->arg ++ || n >= probe->parsed_args->n_args) ++ return; ++ ++ stap_compile_to_ax_1 (objfile, probe, expr, value, n); ++} ++ ++struct value * ++stap_safe_evaluate_at_pc (struct frame_info *frame, int n) ++{ ++ const struct stap_probe *probe; ++ struct objfile *objfile; ++ int n_probes; ++ ++ probe = find_probe_by_pc (get_frame_pc (frame), &objfile); ++ if (!probe) ++ return NULL; ++ gdb_assert (objfile->sf && objfile->sf->sym_probe_fns); ++ ++ n_probes ++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile, ++ probe); ++ if (n >= n_probes) ++ return NULL; ++ ++ return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile, ++ probe, ++ frame, ++ n); ++} ++ ++/* This function frees the space allocated to hold information about ++ the probe's parsed arguments. */ ++ ++void ++stap_free_parsed_args (struct stap_args_info *parsed_args) ++{ ++ int i; ++ ++ if (!parsed_args ++ || parsed_args == &dummy_stap_args_info ++ || parsed_args->n_args == 0) ++ return; ++ ++ for (i = 0; i < parsed_args->n_args; i++) ++ xfree (parsed_args->arg[i].arg_str); ++ ++ xfree (parsed_args->arg); ++ xfree (parsed_args); ++} ++ ++/* A utility structure. A VEC of these is built when handling "info ++ probes". */ ++ ++struct stap_probe_and_objfile ++{ ++ /* The probe. */ ++ const struct stap_probe *probe; ++ /* The probe's objfile. */ ++ struct objfile *objfile; ++}; ++ ++typedef struct stap_probe_and_objfile stap_entry; ++DEF_VEC_O (stap_entry); ++ ++/* A helper function for collect_probes that compiles a regexp and ++ throws an exception on error. This installs a cleanup to free the ++ resulting pattern on success. If RX is NULL, this does nothing. */ ++ ++static void ++compile_rx_or_error (regex_t *pattern, const char *rx, const char *message) ++{ ++ int code; ++ ++ if (!rx) ++ return; ++ ++ code = regcomp (pattern, rx, REG_NOSUB); ++ if (code == 0) ++ make_regfree_cleanup (pattern); ++ else ++ { ++ char *err = get_regcomp_error (code, pattern); ++ ++ make_cleanup (xfree, err); ++ error (_("%s: %s"), message, err); ++ } ++} ++ ++/* Make a vector of probes matching OBJNAME, PROVIDER, and PROBE. ++ Each argument is a regexp, or NULL, which matches anything. */ ++ ++static VEC (stap_entry) * ++collect_probes (char *objname, char *provider, char *probe) ++{ ++ struct objfile *objfile; ++ VEC (stap_entry) *result = NULL; ++ struct cleanup *cleanup; ++ regex_t obj_pat, prov_pat, probe_pat; ++ ++ cleanup = make_cleanup (VEC_cleanup (stap_entry), &result); ++ ++ compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp")); ++ compile_rx_or_error (&probe_pat, probe, _("Invalid probe regexp")); ++ compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp")); ++ ++ ALL_OBJFILES (objfile) ++ { ++ const struct stap_probe *probes; ++ int i, num_probes; ++ ++ if (! objfile->sf || ! objfile->sf->sym_probe_fns) ++ continue; ++ ++ if (objname) ++ { ++ if (regexec (&obj_pat, objfile->name, 0, NULL, 0) != 0) ++ continue; ++ } ++ ++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes); ++ for (i = 0; i < num_probes; ++i) ++ { ++ stap_entry entry; ++ ++ if (provider) ++ { ++ if (regexec (&prov_pat, probes[i].provider, 0, NULL, 0) != 0) ++ continue; ++ } ++ ++ if (probe) ++ { ++ if (regexec (&probe_pat, probes[i].name, 0, NULL, 0) != 0) ++ continue; ++ } ++ ++ entry.probe = &probes[i]; ++ entry.objfile = objfile; ++ VEC_safe_push (stap_entry, result, &entry); ++ } ++ } ++ ++ discard_cleanups (cleanup); ++ return result; ++} ++ ++/* A qsort comparison function for stap_entry objects. */ ++ ++static int ++compare_entries (const void *a, const void *b) ++{ ++ const stap_entry *ea = a; ++ const stap_entry *eb = b; ++ int v; ++ ++ v = strcmp (ea->probe->provider, eb->probe->provider); ++ if (v) ++ return v; ++ ++ v = strcmp (ea->probe->name, eb->probe->name); ++ if (v) ++ return v; ++ ++ if (ea->probe->address < eb->probe->address) ++ return -1; ++ if (ea->probe->address > eb->probe->address) ++ return 1; ++ ++ return strcmp (ea->objfile->name, eb->objfile->name); ++} ++ ++/* Implementation of the "info probes" command. */ ++ ++static void ++info_probes_command (char *arg, int from_tty) ++{ ++ char *provider, *probe = NULL, *objname = NULL; ++ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); ++ VEC (stap_entry) *items; ++ int i, addr_width, any_found; ++ stap_entry *entry; ++ ++ provider = extract_arg (&arg); ++ if (provider) ++ { ++ make_cleanup (xfree, provider); ++ ++ probe = extract_arg (&arg); ++ if (probe) ++ { ++ make_cleanup (xfree, probe); ++ ++ objname = extract_arg (&arg); ++ if (objname) ++ make_cleanup (xfree, objname); ++ } ++ } ++ ++ items = collect_probes (objname, provider, probe); ++ make_cleanup (VEC_cleanup (stap_entry), &items); ++ make_cleanup_ui_out_table_begin_end (uiout, 5, ++ VEC_length (stap_entry, items), ++ "SystemTapProbes"); ++ ++ if (! VEC_empty (stap_entry, items)) ++ qsort (VEC_address (stap_entry, items), ++ VEC_length (stap_entry, items), ++ sizeof (stap_entry), ++ compare_entries); ++ ++ addr_width = 4 + (gdbarch_ptr_bit (get_current_arch ()) / 4); ++ ++ ui_out_table_header (uiout, 10, ui_left, "provider", _("Provider")); ++ ui_out_table_header (uiout, 10, ui_left, "name", _("Name")); ++ ui_out_table_header (uiout, addr_width - 1, ui_left, "addr", _("Where")); ++ ui_out_table_header (uiout, addr_width - 1, ui_left, "semaphore", ++ _("Semaphore")); ++ ui_out_table_header (uiout, 30, ui_left, "object", _("Object")); ++ ui_out_table_body (uiout); ++ ++ for (i = 0; VEC_iterate (stap_entry, items, i, entry); ++i) ++ { ++ struct cleanup *inner; ++ ++ inner = make_cleanup_ui_out_tuple_begin_end (uiout, "probe"); ++ ++ ui_out_field_string (uiout, "provider", entry->probe->provider); ++ ui_out_field_string (uiout, "name", entry->probe->name); ++ ui_out_field_core_addr (uiout, "addr", get_current_arch (), ++ entry->probe->address); ++ if (entry->probe->sem_addr == 0) ++ ui_out_field_skip (uiout, "semaphore"); ++ else ++ ui_out_field_core_addr (uiout, "semaphore", get_current_arch (), ++ entry->probe->sem_addr); ++ ui_out_field_string (uiout, "object", entry->objfile->name); ++ ui_out_text (uiout, "\n"); ++ ++ do_cleanups (inner); ++ } ++ ++ any_found = ! VEC_empty (stap_entry, items); ++ do_cleanups (cleanup); ++ ++ if (! any_found) ++ ui_out_message (uiout, 0, _("No probes matched.\n")); ++} ++ ++ ++ ++/* See definition in stap-probe.h. */ ++ ++VEC (stap_probe_p) * ++find_probes_in_objfile (struct objfile *objfile, ++ const char *provider, ++ const char *name) ++{ ++ const struct stap_probe *probes; ++ int i, num_probes; ++ VEC (stap_probe_p) *result = NULL; ++ ++ if (! objfile->sf || ! objfile->sf->sym_probe_fns) ++ return NULL; ++ ++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes); ++ for (i = 0; i < num_probes; ++i) ++ { ++ if (strcmp (probes[i].provider, provider) != 0) ++ continue; ++ ++ if (strcmp (probes[i].name, name) != 0) ++ continue; ++ ++ VEC_safe_push (stap_probe_p, result, &probes[i]); ++ } ++ ++ return result; ++} ++ ++/* See definition in stap-probe.h. */ ++ ++struct symtabs_and_lines ++parse_stap_probe (char **argptr, struct linespec_result *canonical) ++{ ++ char *full_arg = extract_arg (argptr); ++ char *arg = xstrdup (full_arg); ++ char *objfile_name = NULL, *provider = NULL, *name, *p; ++ struct cleanup *cleanup; ++ struct symtabs_and_lines result; ++ struct objfile *objfile; ++ ++ result.sals = NULL; ++ result.nelts = 0; ++ ++ /* The caller ensured that this starts with 'probe:'. */ ++ gdb_assert (arg && strncmp (arg, "probe:", 6) == 0); ++ cleanup = make_cleanup (xfree, arg); ++ make_cleanup (xfree, full_arg); ++ arg += 6; ++ ++ /* Extract each word from the argument, separated by ":"s. */ ++ p = strchr (arg, ':'); ++ if (p == NULL) ++ { ++ /* This is `probe:name'. */ ++ name = arg; ++ } ++ else ++ { ++ char *hold = p + 1; ++ ++ *p = '\0'; ++ p = strchr (hold, ':'); ++ if (p == NULL) ++ { ++ /* This is `probe:provider:name'. */ ++ provider = arg; ++ name = hold; ++ } ++ else ++ { ++ /* This is `probe:objfile:provider:name'. */ ++ *p = '\0'; ++ objfile_name = arg; ++ provider = hold; ++ name = p + 1; ++ } ++ } ++ ++ if (*name == '\0') ++ error (_("no probe name specified")); ++ if (provider && *provider == '\0') ++ error (_("invalid provider name")); ++ if (objfile_name && *objfile_name == '\0') ++ error (_("invalid objfile name")); ++ ++ if (canonical) ++ canonical->canonical = NULL; ++ ++ ALL_OBJFILES (objfile) ++ { ++ const struct stap_probe *probes; ++ int i, num_probes; ++ ++ if (! objfile->sf || ! objfile->sf->sym_probe_fns) ++ continue; ++ ++ if (objfile_name ++ && FILENAME_CMP (objfile->name, objfile_name) != 0 ++ && FILENAME_CMP (lbasename (objfile->name), objfile_name) != 0) ++ continue; ++ ++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes); ++ for (i = 0; i < num_probes; ++i) ++ { ++ struct symtab_and_line *sal; ++ ++ if (provider && strcmp (probes[i].provider, provider) != 0) ++ continue; ++ ++ if (strcmp (probes[i].name, name) != 0) ++ continue; ++ ++ ++result.nelts; ++ result.sals = xrealloc (result.sals, ++ result.nelts * sizeof (struct symtab_and_line)); ++ sal = &result.sals[result.nelts - 1]; ++ ++ init_sal (sal); ++ ++ sal->pc = probes[i].address; ++ sal->explicit_pc = 1; ++ sal->section = find_pc_overlay (sal->pc); ++ sal->pspace = current_program_space; ++ sal->semaphore = probes[i].sem_addr; ++ ++ if (canonical) ++ { ++ canonical->canonical = xrealloc (canonical->canonical, ++ result.nelts * sizeof (char *)); ++ canonical->canonical[result.nelts - 1] = xstrdup (full_arg); ++ } ++ } ++ } ++ ++ if (result.nelts == 0) ++ { ++ throw_error (NOT_FOUND_ERROR, ++ _("No probe matching objfile=`%s', provider=`%s', name=`%s'"), ++ objfile_name ? objfile_name : _(""), ++ provider ? provider : _(""), ++ name); ++ } ++ ++ if (canonical) ++ { ++ canonical->special_display = 1; ++ canonical->pre_expanded = 1; ++ } ++ ++ do_cleanups (cleanup); ++ ++ return result; ++} ++ ++ ++ ++/* See definition in stap-probe.h. */ ++ ++const struct stap_probe * ++find_probe_by_pc (CORE_ADDR pc, struct objfile **objfile_out) ++{ ++ struct objfile *objfile; ++ ++ ALL_OBJFILES (objfile) ++ { ++ const struct stap_probe *probes; ++ int i, num_probes; ++ stap_entry entry; ++ ++ if (! objfile->sf || ! objfile->sf->sym_probe_fns) ++ continue; ++ ++ /* If this proves too inefficient, we can replace with a hash. */ ++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes); ++ for (i = 0; i < num_probes; ++i) ++ { ++ if (probes[i].address == pc) ++ { ++ *objfile_out = objfile; ++ return &probes[i]; ++ } ++ } ++ } ++ ++ return NULL; ++} ++ ++/* This is called to compute the value of one of the $_probe_arg* ++ convenience variables. */ ++ ++static struct value * ++compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar, ++ void *data) ++{ ++ struct frame_info *frame = get_selected_frame (_("No frame selected")); ++ CORE_ADDR pc = get_frame_pc (frame); ++ int sel = (int) (uintptr_t) data; ++ struct objfile *objfile; ++ const struct stap_probe *pc_probe; ++ int n_probes; ++ ++ /* SEL==10 means "_probe_argc". */ ++ gdb_assert (sel >= 0 && sel <= STAP_MAX_ARGS); ++ ++ pc_probe = find_probe_by_pc (pc, &objfile); ++ if (pc_probe == NULL) ++ error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc)); ++ ++ n_probes ++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile, ++ pc_probe); ++ if (sel == 10) ++ return value_from_longest (builtin_type (arch)->builtin_int, n_probes); ++ ++ if (sel >= n_probes) ++ error (_("Invalid probe argument %d -- probe has %d arguments available"), ++ sel, n_probes); ++ ++ return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile, ++ pc_probe, ++ frame, sel); ++} ++ ++/* This is called to compile one of the $_probe_arg* convenience ++ variables into an agent expression. */ ++ ++static void ++compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr, ++ struct axs_value *value, void *data) ++{ ++ CORE_ADDR pc = expr->scope; ++ int sel = (int) (uintptr_t) data; ++ struct objfile *objfile; ++ const struct stap_probe *pc_probe; ++ int n_probes; ++ ++ /* SEL==10 means "_probe_argc". */ ++ gdb_assert (sel >= 0 && sel <= 10); ++ ++ pc_probe = find_probe_by_pc (pc, &objfile); ++ if (pc_probe == NULL) ++ error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc)); ++ ++ n_probes ++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile, ++ pc_probe); ++ if (sel == 10) ++ { ++ value->kind = axs_rvalue; ++ value->type = builtin_type (expr->gdbarch)->builtin_int; ++ ax_const_l (expr, n_probes); ++ return; ++ } ++ ++ gdb_assert (sel >= 0); ++ if (sel >= n_probes) ++ error (_("Invalid probe argument %d -- probe has %d arguments available"), ++ sel, n_probes); ++ ++ objfile->sf->sym_probe_fns->sym_compile_to_ax (objfile, pc_probe, ++ expr, value, sel); ++} ++ ++ ++ ++/* Implementation of `$_probe_arg*' set of variables. */ ++ ++static const struct internalvar_funcs probe_funcs = ++{ ++ compute_probe_arg, ++ compile_probe_arg, ++ NULL ++}; ++ ++void ++_initialize_stap_probe (void) ++{ ++ add_info ("probes", info_probes_command, _("\ ++Show available static probes.\n\ ++Usage: info probes [PROVIDER [NAME [OBJECT]]]\n\ ++Each argument is a regular expression, used to select probes.\n\ ++PROVIDER matches probe provider names.\n\ ++NAME matches the probe names.\n\ ++OBJECT match the executable or shared library name.")); ++ ++ create_internalvar_type_lazy ("_probe_argc", &probe_funcs, ++ (void *) (uintptr_t) 10); ++ create_internalvar_type_lazy ("_probe_arg0", &probe_funcs, ++ (void *) (uintptr_t) 0); ++ create_internalvar_type_lazy ("_probe_arg1", &probe_funcs, ++ (void *) (uintptr_t) 1); ++ create_internalvar_type_lazy ("_probe_arg2", &probe_funcs, ++ (void *) (uintptr_t) 2); ++ create_internalvar_type_lazy ("_probe_arg3", &probe_funcs, ++ (void *) (uintptr_t) 3); ++ create_internalvar_type_lazy ("_probe_arg4", &probe_funcs, ++ (void *) (uintptr_t) 4); ++ create_internalvar_type_lazy ("_probe_arg5", &probe_funcs, ++ (void *) (uintptr_t) 5); ++ create_internalvar_type_lazy ("_probe_arg6", &probe_funcs, ++ (void *) (uintptr_t) 6); ++ create_internalvar_type_lazy ("_probe_arg7", &probe_funcs, ++ (void *) (uintptr_t) 7); ++ create_internalvar_type_lazy ("_probe_arg8", &probe_funcs, ++ (void *) (uintptr_t) 8); ++ create_internalvar_type_lazy ("_probe_arg9", &probe_funcs, ++ (void *) (uintptr_t) 9); ++} +Index: gdb-7.3.50.20110722/gdb/stap-probe.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/stap-probe.h 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,114 @@ ++/* SystemTap probe support for GDB. ++ ++ Copyright (C) 2011 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 . */ ++ ++#if !defined (STAP_PROBE_H) ++#define STAP_PROBE_H 1 ++ ++#include "vec.h" ++ ++struct stap_args_info; ++struct axs_value; ++struct linespec_result; ++ ++/* Main structure which holds information about a SystemTap probe. */ ++ ++struct stap_probe ++{ ++ /* The provider of this probe. */ ++ const char *provider; ++ ++ /* The name of the probe. */ ++ const char *name; ++ ++ /* The address where the probe is inserted. */ ++ CORE_ADDR address; ++ ++ /* The address of the probe's semaphore, or 0 if this probe does not ++ have an associated semaphore. */ ++ CORE_ADDR sem_addr; ++ ++ /* Probe's arguments. Users should generally not examine this, but ++ should instead extract information about the arguments using the ++ methods provided in sym_probe_fns. */ ++ const char *args; ++ ++ /* Probe's arguments after parsing. This is an opaque structure that ++ will hold information about the arguments pointed by ARGS. */ ++ struct stap_args_info *parsed_args; ++}; ++ ++typedef const struct stap_probe *stap_probe_p; ++DEF_VEC_P (stap_probe_p); ++ ++/* A helper for linespec that decodes a stap probe specification. It ++ returns a symtabs_and_lines object and updates *ARGPTR or throws an ++ error. */ ++ ++extern struct symtabs_and_lines parse_stap_probe (char **argptr, ++ struct linespec_result *canon); ++ ++/* Search OBJFILE for a probe with the given PROVIDER and NAME. ++ Return a VEC of all probes that were found. If no matching probe ++ is found, return NULL. The caller must free the VEC. */ ++ ++extern VEC (stap_probe_p) *find_probes_in_objfile (struct objfile *objfile, ++ const char *provider, ++ const char *name); ++ ++/* Given a PC, find an associated SystemTap probe. If a probe is ++ found, set *OBJFILE_OUT to the probe's objfile, and return the ++ probe. If no probe is found, return NULL. */ ++ ++extern const struct stap_probe *find_probe_by_pc (CORE_ADDR pc, ++ struct objfile **objfile_out); ++ ++/* Given PROBE, returns the number of arguments present in that probe's ++ argument string. */ ++ ++extern int stap_get_probe_argument_count (const struct stap_probe *probe); ++ ++/* Given PARSED_ARGS, frees the space allocated to hold information about ++ the probe's parsed arguments. */ ++ ++extern void stap_free_parsed_args (struct stap_args_info *parsed_args); ++ ++/* Evaluates the probe's argument N, returning a value corresponding ++ to it. */ ++ ++extern struct value *stap_evaluate_probe_argument (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct frame_info *frame, ++ int n); ++ ++/* Compile the probe's argument N to agent expression. */ ++ ++extern void stap_compile_to_ax (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ int n); ++ ++/* A convenience function that finds a probe at the PC in FRAME and ++ evaluates argument N. If there is no probe at that location, or if ++ the probe does not have enough arguments, this returns NULL. */ ++ ++extern struct value *stap_safe_evaluate_at_pc (struct frame_info *frame, ++ int n); ++ ++#endif /* !defined (STAP_PROBE_H) */ +Index: gdb-7.3.50.20110722/gdb/symfile.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symfile.h 2011-07-29 22:52:00.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symfile.h 2011-07-29 22:52:02.000000000 +0200 +@@ -31,6 +31,11 @@ struct objfile; + struct obj_section; + struct obstack; + struct block; ++struct stap_probe; ++struct value; ++struct frame_info; ++struct agent_expr; ++struct axs_value; + + /* Comparison function for symbol look ups. */ + +@@ -294,6 +299,52 @@ struct quick_symbol_functions + symbol_filename_ftype *fun, void *data); + }; + ++/* Structure of functions used for SystemTap probe support. If one of ++ these functions is provided, all must be. */ ++ ++struct sym_probe_fns ++{ ++ /* If non-NULL, return an array of SystemTap probe objects. The ++ number of objects is returned in *NUM_PROBES. */ ++ const struct stap_probe *(*sym_get_probes) (struct objfile *, ++ int *num_probes); ++ ++ /* Return the number of arguments available to PROBE. PROBE will ++ have come from a call to this objfile's sym_get_probes method. ++ If you provide an implementation of sym_get_probes, you must ++ implement this method as well. */ ++ int (*sym_get_probe_argument_count) (struct objfile *objfile, ++ const struct stap_probe *probe); ++ ++ /* Evaluate the Nth argument available to PROBE. PROBE will have ++ come from a call to this objfile's sym_get_probes method. N will ++ be between 0 and the number of arguments available to this probe. ++ FRAME is the frame in which the evaluation is done; the frame's ++ PC will match the address of the probe. If you provide an ++ implementation of sym_get_probes, you must implement this method ++ as well. */ ++ struct value *(*sym_evaluate_probe_argument) (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct frame_info *frame, ++ int n); ++ ++ /* Compile the Nth probe argument to an agent expression. PROBE ++ will have come from a call to this objfile's sym_get_probes ++ method. N will be between 0 and the number of arguments ++ available to this probe. EXPR and VALUE are the agent expression ++ that is being updated. */ ++ void (*sym_compile_to_ax) (struct objfile *objfile, ++ const struct stap_probe *probe, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ int n); ++ ++ /* Relocate the probe section of OBJFILE. */ ++ void (*sym_relocate_probe) (struct objfile *objfile, ++ struct section_offsets *new_offsets, ++ struct section_offsets *delta); ++}; ++ + /* Structure to keep track of symbol reading functions for various + object file types. */ + +@@ -364,6 +415,10 @@ struct sym_fns + + bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf); + ++ /* If non-NULL, this objfile has probe support, and all the probe ++ functions referred to here will be non-NULL. */ ++ const struct sym_probe_fns *sym_probe_fns; ++ + /* The "quick" (aka partial) symbol functions for this symbol + reader. */ + const struct quick_symbol_functions *qf; +Index: gdb-7.3.50.20110722/gdb/symtab.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symtab.c 2011-07-21 17:13:29.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symtab.c 2011-07-29 22:52:02.000000000 +0200 +@@ -776,6 +776,7 @@ init_sal (struct symtab_and_line *sal) + sal->end = 0; + sal->explicit_pc = 0; + sal->explicit_line = 0; ++ sal->semaphore = 0; + } + + +Index: gdb-7.3.50.20110722/gdb/symtab.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symtab.h 2011-06-30 00:19:24.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symtab.h 2011-07-29 22:52:02.000000000 +0200 +@@ -1115,6 +1115,10 @@ struct symtab_and_line + CORE_ADDR end; + int explicit_pc; + int explicit_line; ++ ++ /* If non-zero, the semaphore location associated with a SystemTap ++ probe. */ ++ CORE_ADDR semaphore; + }; + + extern void init_sal (struct symtab_and_line *sal); +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,457 @@ ++ .file "x86_64-vla-pointer.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-pointer.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++.Ldebug_relative: ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long .Ltype_int - .Ldebug_relative ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_pointer: ++ .uleb128 0x4 ++ .byte 0x8 /* DW_AT_byte_size */ ++ .long .Ltag_array_type - .debug_info /* DW_AT_type */ ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_pointer - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++.Ltype_int: ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long .Ltype_char - .Ldebug_relative ++ .long .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++#if 1 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++.Ltype_ulong: ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++.Ltype_char: ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* .Ltag_pointer abbrev */ ++ .uleb128 0x0f /* DW_TAG_pointer_type */ ++ .byte 0x0 ++ .uleb128 0x0b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-pointer.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,43 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++#if 0 ++ ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; ++ ++ for (i = 0; i < size; i++) ++ array[i] = i; ++ ++ array[0] = 0; /* break-here */ ++} ++ ++#else ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} ++ ++#endif +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,66 @@ ++# Copyright 2009 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 . ++ ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." ++ return ++} ++ ++set testfile x86_64-vla-pointer ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested x86_64-vla-pointer ++ return -1 ++} ++ ++gdb_breakpoint "break_here" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array" ++ ++gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array" ++gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array" ++ ++gdb_test "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array" ++ ++gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array" ++gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,455 @@ ++ .file "x86_64-vla-typedef.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-typedef.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long 0x83 ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_typedef: ++ .uleb128 0x4 ++ .long .LASF6 ++ .byte 0x1 ++ .byte 0x17 ++ .long .Ltag_array_type - .debug_info ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_typedef - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ ++ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++ .byte 0x6 /* DW_OP_deref */ ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x16 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-typedef.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,43 @@ ++/* 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 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 . */ ++ ++#if 0 ++ ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; ++ ++ for (i = 0; i < size; i++) ++ array[i] = i; ++ ++ array[0] = 0; /* break-here */ ++} ++ ++#else ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} ++ ++#endif +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,64 @@ ++# Copyright 2009 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 . ++ ++# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. ++ ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." ++ return ++} ++ ++set testfile x86_64-vla-typedef ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested x86_64-vla-typedef ++ return -1 ++} ++ ++gdb_breakpoint "break_here" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "first: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" ++ ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "second: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/arrayidx.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/arrayidx.c 2011-01-01 16:33:40.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/arrayidx.c 2011-07-29 22:52:02.000000000 +0200 +@@ -17,6 +17,13 @@ + + int array[] = {1, 2, 3, 4}; + ++#ifdef __GNUC__ ++struct ++ { ++ int a[0]; ++ } unbound; ++#endif ++ + int + main (void) + { +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/arrayidx.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/arrayidx.exp 2011-01-01 16:33:40.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/arrayidx.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -57,4 +57,12 @@ gdb_test "print array" \ + "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ + "Print array with array-indexes on" + +- ++set test "p unbound.a == &unbound.a\[0\]" ++gdb_test_multiple $test $test { ++ -re " = 1\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { ++ unsupported "$test (no GCC)" ++ } ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/default.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/default.exp 2011-05-20 16:37:20.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/default.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -607,6 +607,17 @@ gdb_test_list_exact "show convenience" " + {$_sdata = void} \ + {$_siginfo = void} \ + {$_thread = 0} \ ++ {$_probe_argc = } \ ++ {$_probe_arg0 = } \ ++ {$_probe_arg1 = } \ ++ {$_probe_arg2 = } \ ++ {$_probe_arg3 = } \ ++ {$_probe_arg4 = } \ ++ {$_probe_arg5 = } \ ++ {$_probe_arg6 = } \ ++ {$_probe_arg7 = } \ ++ {$_probe_arg8 = } \ ++ {$_probe_arg9 = } \ + } + + #test show directories +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/internal-var-field-address.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/internal-var-field-address.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,20 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++struct { ++ int field; ++} staticstruct = { 1 }; +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/internal-var-field-address.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/internal-var-field-address.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,26 @@ ++# Copyright 2009 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 . ++ ++set test internal-var-field-address ++set binfile ${test}.x ++if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++clean_restart $binfile ++ ++gdb_test {set $varstruct = staticstruct} ++gdb_test {p $varstruct.field} " = 1" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/stap-probe.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/stap-probe.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,69 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++#if USE_PROBES ++ ++#define _SDT_HAS_SEMAPHORES ++__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); ++#define TEST teste_user_semaphore ++ ++__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); ++#define TEST2 teste_two_semaphore ++ ++#else ++ ++#define TEST 1 ++#define TEST2 1 ++ ++#endif ++ ++#include ++ ++/* We only support SystemTap and only the v3 form. */ ++#if _SDT_NOTE_TYPE != 3 ++#error "not using SystemTap v3 probes" ++#endif ++ ++void ++m1 (void) ++{ ++ if (TEST2) ++ STAP_PROBE (teste, two); ++} ++ ++void ++m2 (void) ++{ ++ if (TEST2) ++ STAP_PROBE (teste, two); ++} ++ ++int ++f (int x) ++{ ++ if (TEST) ++ STAP_PROBE1(teste, user, x); ++ return x+5; ++} ++ ++int ++main() ++{ ++ f(f(23)); ++ m1(); ++ m2(); ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/stap-probe.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/stap-probe.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,72 @@ ++# Copyright (C) 2011 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 . ++ ++set testfile stap-probe ++ ++# Run the tests. We run the tests two different ways: once with a ++# plain probe, and once with a probe that has an associated semaphore. ++# This returns -1 on failure to compile or start, 0 otherwise. ++proc stap_test {{arg ""}} { ++ global testfile hex ++ ++ if {$arg != ""} { ++ set arg "additional_flags=$arg" ++ set addendum ", with semaphore" ++ } else { ++ set addendum ", no semaphore" ++ } ++ ++ if {[prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c \ ++ [concat $arg debug]]} { ++ return -1 ++ } ++ ++ if ![runto_main] { ++ return -1 ++ } ++ ++ gdb_test "print \$_probe_argc" "No SystemTap probe at PC $hex" \ ++ "check argument not at probe point$addendum" ++ ++ gdb_test "info probes" \ ++ "teste *user *$hex .*" \ ++ "info probes$addendum" ++ ++ if {[runto "probe:teste:user"]} { ++ pass "run to probe:teste:user$addendum" ++ } else { ++ fail "run to probe:teste:user$addendum" ++ } ++ ++ # Test probe arguments. ++ gdb_test "print \$_probe_argc" " = 1" "print \$_probe_argc$addendum" ++ gdb_test "print \$_probe_arg0 == x" " = 1" "check \$_probe_arg0$addendum" ++ gdb_test "print \$_probe_arg1" \ ++ "Invalid probe argument 1 -- probe has 1 arguments available" \ ++ "check \$_probe_arg1$addendum" ++ ++ # Set a breakpoint with multiple probe locations. ++ gdb_test "break probe:teste:two" \ ++ "Breakpoint .* at $hex.*2 locations.*" \ ++ "set multi-location probe breakpoint$addendum" ++ ++ return 0 ++} ++ ++if {[stap_test] == -1} { ++ untested stap-probe.exp ++ return -1 ++} ++stap_test "-DUSE_PROBES" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla-overflow.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla-overflow.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,30 @@ ++/* 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 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 . */ ++ ++#include ++ ++int ++main (int argc, char **argv) ++{ ++ int array[argc]; ++ ++ array[0] = array[0]; ++ ++ abort (); ++ ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla-overflow.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla-overflow.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,109 @@ ++# 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 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 . ++ ++# We could crash in: ++# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 ++# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 ++# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); ++# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 ++# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 ++# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 ++# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 ++# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 ++# ... ++# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 ++# ... ++# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 ++ ++set testfile vla-overflow ++set shfile ${objdir}/${subdir}/${testfile}-gdb.sh ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${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 ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++if { [runto_main] < 0 } { ++ untested vla-overflow ++ return -1 ++} ++ ++# Get the GDB memory size when we stay at 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] ++ ++# s390x with glibc-debuginfo.s390x installed used approx. 16MB. ++set mb_reserve 40 ++verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" ++set kb_found [expr $pages_found * $pagesize / 1024] ++set kb_permit [expr $kb_found + 1 * 1024 + $mb_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]] ++ ++# Check the size again after the second run. ++# We must not stop in main as it would cache `array' and never crash later. ++ ++gdb_run_cmd ++ ++verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" ++ ++gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" ++ ++verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" ++ ++# `abort' can get expressed as `*__GI_abort'. ++gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" ++ ++verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,55 @@ ++/* 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 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 . */ ++ ++#include ++ ++void ++marker (void) ++{ ++} ++ ++void ++bar (char *a, char *b, char *c, int size) ++{ ++ memset (a, '1', size); ++ memset (b, '2', size); ++ memset (c, '3', 48); ++} ++ ++void ++foo (int size) ++{ ++ char temp1[size]; ++ char temp3[48]; ++ ++ temp1[size - 1] = '\0'; ++ { ++ char temp2[size]; ++ ++ bar (temp1, temp2, temp3, size); ++ ++ marker (); /* break-here */ ++ } ++} ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/vla.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,62 @@ ++# 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 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 . ++ ++set testfile vla ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested vla ++ return -1 ++} ++ ++gdb_breakpoint [gdb_get_line_number "break-here"] ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "first: print temp1" ++gdb_test "p temp2" " = '2' " "first: print temp2" ++gdb_test "p temp3" " = '3' " "first: print temp3" ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "second: print temp1" ++gdb_test "p temp2" " = '2' " "second: print temp2" ++gdb_test "p temp3" " = '3' " "second: print temp3" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.cp/nextoverthrow.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.cp/nextoverthrow.exp 2011-01-01 16:33:44.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.cp/nextoverthrow.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -53,6 +53,17 @@ gdb_test_multiple "print _Unwind_DebugHo + } + } + if {!$ok} { ++ gdb_test_multiple "info probe" "check for stap probe in unwinder" { ++ -re ".*libgcc.*unwind.*\r\n$gdb_prompt $" { ++ pass "check for stap probe in unwinder" ++ set ok 1 ++ } ++ -re "\r\n$gdb_prompt $" { ++ } ++ } ++} ++ ++if {!$ok} { + unsupported "nextoverthrow.exp could not find _Unwind_DebugHook" + return -1 + } +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,246 @@ ++/* 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 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 . */ ++ ++/* Debug information */ ++ ++/* We will `break *main' at the very first instruction. */ ++#define main_length 1 ++ ++ .section .data ++vardata: ++ /* See DW_OP_lit3 + 1 (0-based). */ ++ .string "seennotseen" ++ ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lproducer /* DW_AT_producer */ ++ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ ++ .byte 4 /* DW_AT_language (C++) - */ ++ .4byte main /* DW_AT_low_pc */ ++ .byte main_length /* DW_AT_high_pc */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++.Larrayb_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++ /* DW_AT_upper_bound is referencing register. */ ++.Larrayreg_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .byte 2f - 1f /* DW_AT_upper_bound */ ++1: .byte 0x50 /* DW_OP_reg0 */ ++2: ++ .byte 0 /* End of children of die */ ++ ++.Luint_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Luint_str /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 7 /* DW_AT_encoding */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Lchar_str /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++.Llen_var: ++ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ ++ ++ /* optimized-out variable for b_string. */ ++.Llenb_var: ++ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "a_string" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "b_string" /* DW_AT_name */ ++ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing register. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "reg_string" /* DW_AT_name */ ++ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: ++ ++ .section .debug_loc ++.Lloclist: ++.Llen_loclist: ++ .4byte 0 # Location list begin address ++ .4byte main_length # Location list end address ++ .value 2f-1f # Location expression size ++1: .byte 0x33 # DW_OP_lit3 ++ .byte 0x9f # DW_OP_stack_value ++2: ++ .quad 0x0 # Location list terminator begin (*.LLST2) ++ .quad 0x0 # Location list terminator end (*.LLST2) ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x02 /* DW_AT_location */ ++ .uleb128 0x06 /* DW_FORM_data4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 7 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 8 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type with block */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ ++/* String table */ ++ .section .debug_str ++.Lproducer: ++ .string "GNU C 3.3.3" ++.Lchar_str: ++ .string "char" ++.Luint_str: ++ .string "unsigned int" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,54 @@ ++# 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 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 . ++ ++# Test printing variable with dynamic bounds which reference a different ++# (artificial in the GCC case) variable containing loclist as its location. ++# This testcase uses value (not address) of the referenced variable: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile dw2-bound-loclist ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { ++ return -1 ++} ++ ++# Verify it behaves at least as an unbound array without inferior. ++ ++gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"} ++gdb_test "ptype a_string" {type = char \[\]} ++ ++# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. ++if ![runto "*main"] { ++ return -1 ++} ++ ++gdb_test "p a_string" { = "seen"} ++gdb_test "ptype a_string" {type = char \[4\]} ++ ++gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} ++gdb_test "ptype b_string" {type = char \[\]} ++ ++# The register contains unpredictable value - the array size. ++gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-stripped.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,42 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2004 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. */ ++ ++ ++/* The function `func1' traced into must have debug info on offset > 0; ++ (DW_UNSND (attr)). This is the reason of `func0' existence. */ ++ ++void ++func0(int a, int b) ++{ ++} ++ ++/* `func1' being traced into must have some arguments to dump. */ ++ ++void ++func1(int a, int b) ++{ ++ func0 (a,b); ++} ++ ++int ++main(void) ++{ ++ func1 (1, 2); ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,79 @@ ++# 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. ++ ++# Minimal DWARF-2 unit test ++ ++# This test can only be run on targets which support DWARF-2. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-stripped" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile}.x ++ ++remote_exec build "rm -f ${binfile}" ++ ++# get the value of gcc_compiled ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++# This test can only be run on gcc as we use additional_flags=FIXME ++if {$gcc_compiled == 0} { ++ return 0 ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { ++ return -1 ++} ++ ++remote_exec build "objcopy -R .debug_loc ${binfile}" ++set strip_output [remote_exec build "objdump -h ${binfile}"] ++ ++set test "stripping test file preservation" ++if [ regexp ".debug_info " $strip_output] { ++ pass "$test (.debug_info preserved)" ++} else { ++ fail "$test (.debug_info got also stripped)" ++} ++ ++set test "stripping test file functionality" ++if [ regexp ".debug_loc " $strip_output] { ++ fail "$test (.debug_loc still present)" ++} else { ++ pass "$test (.debug_loc stripped)" ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# For C programs, "start" should stop in main(). ++ ++gdb_test "start" \ ++ ".*main \\(\\) at .*" \ ++ "start" ++gdb_test "step" \ ++ "func.* \\(.*\\) at .*" \ ++ "step" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++/* Debug information */ ++ ++ .section .debug_info ++.Lcu1_begin: ++ /* CU header */ ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF Version */ ++ .4byte .Labbrev1_begin /* Offset into abbrev section */ ++ .byte 4 /* Pointer size */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ ++ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ ++ .byte 1 /* DW_AT_language (C) */ ++ ++.Ltype_uchar: ++ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ ++ .ascii "some_struct\0" /* DW_AT_name */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_member */ ++ .ascii "field\0" /* DW_AT_name */ ++ .byte 0 /* DW_AT_data_member_location */ ++ ++ .byte 0 /* End of children of some_struct */ ++ ++ .byte 0 /* End of children of CU */ ++ ++.Lcu1_end: ++ ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x13 /* DW_TAG_structure_type */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x0d /* DW_TAG_member */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x38 /* DW_AT_data_member_location */ ++ .uleb128 0x0b /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,37 @@ ++# Copyright 2009 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-struct-member-data-location" ++set srcfile ${testfile}.S ++set binfile ${testfile}.x ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } { ++ return -1 ++} ++ ++clean_restart $binfile ++ ++gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dwarf-stride.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,42 @@ ++# Copyright 2009 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 file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. Array element stride must not be ++# specified in the number of elements but in a number of bytes instead. ++# Original problem: ++# (gdb) p c40pt(1) ++# $1 = '0-hello', ' ' ++# (gdb) p c40pt(2) ++# warning: Fortran array stride not divisible by the element size ++ ++set testfile dwarf-stride ++set srcfile ${testfile}.f90 ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 ++} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "break-here"] ++gdb_continue_to_breakpoint "break-here" ".*break-here.*" ++gdb_test "p c40pt(1)" " = '0-hello.*" ++gdb_test "p c40pt(2)" " = '1-hello.*" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dwarf-stride.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,40 @@ ++! Copyright 2009 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. ++! ++! File written by Alan Matsuoka. ++ ++program repro ++ ++ type small_stride ++ character*40 long_string ++ integer small_pad ++ end type small_stride ++ ++ type(small_stride), dimension (20), target :: unpleasant ++ character*40, pointer, dimension(:):: c40pt ++ ++ integer i ++ ++ do i = 0,19 ++ unpleasant(i+1)%small_pad = i+1 ++ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' ++ end do ++ ++ c40pt => unpleasant%long_string ++ ++ print *, c40pt ! break-here ++ ++end program repro +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,24 @@ ++! 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine bar ++ real :: dummy ++ dummy = 1 ++end subroutine bar +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,37 @@ ++# 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. ++ ++set testfile "dynamic-other-frame" ++set srcfile1 ${testfile}.f90 ++set srcfile2 ${testfile}-stub.f90 ++set objfile2 ${objdir}/${subdir}/${testfile}-stub.o ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != "" ++ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } { ++ untested "Couldn't compile ${srcfile1} or ${srcfile2}" ++ return -1 ++} ++ ++clean_restart ${executable} ++ ++if ![runto bar_] then { ++ perror "couldn't run to bar_" ++ continue ++} ++ ++gdb_test "bt" {foo \(string='hello'.*} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,36 @@ ++! 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine foo (string) ++ interface ++ subroutine bar ++ end subroutine ++ end interface ++ character string*(*) ++ call bar ! stop-here ++end subroutine foo ++program test ++ interface ++ subroutine foo (string) ++ character string*(*) ++ end subroutine ++ end interface ++ call foo ('hello') ++end +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,145 @@ ++# 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. ++ ++# This file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. It contains tests for dynamically ++# allocated Fortran arrays. ++# It depends on the GCC dynamic Fortran arrays DWARF support: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 ++ ++set testfile "dynamic" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "varx-init"] ++gdb_continue_to_breakpoint "varx-init" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated" ++gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated" ++ ++gdb_breakpoint [gdb_get_line_number "varx-allocated"] ++gdb_continue_to_breakpoint "varx-allocated" ++# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" ++ ++gdb_breakpoint [gdb_get_line_number "varx-filled"] ++gdb_continue_to_breakpoint "varx-filled" ++gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" ++gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" ++gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" ++gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated" ++ ++gdb_breakpoint [gdb_get_line_number "varv-associated"] ++gdb_continue_to_breakpoint "varv-associated" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" ++# Intel Fortran Compiler 10.1.008 uses the pointer type. ++gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" ++ ++gdb_breakpoint [gdb_get_line_number "varv-filled"] ++gdb_continue_to_breakpoint "varv-filled" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" ++ ++gdb_breakpoint [gdb_get_line_number "varv-deassociated"] ++gdb_continue_to_breakpoint "varv-deassociated" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" ++gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++ ++gdb_breakpoint [gdb_get_line_number "varx-deallocated"] ++gdb_continue_to_breakpoint "varx-deallocated" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated" ++ ++gdb_breakpoint [gdb_get_line_number "vary-passed"] ++gdb_continue_to_breakpoint "vary-passed" ++# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) ++gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" ++ ++gdb_breakpoint [gdb_get_line_number "vary-filled"] ++gdb_continue_to_breakpoint "vary-filled" ++gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" ++gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" ++gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" ++gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" ++# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" ++ ++gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] ++gdb_continue_to_breakpoint "varw-almostfilled" ++gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" ++gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" ++# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" ++# "up" works with GCC but other Fortran compilers may copy the values into the ++# outer function only on the exit of the inner function. ++# We need both variants as depending on the arch we optionally may still be ++# executing the caller line or not after `finish'. ++gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" ++gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" ++gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" ++gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" ++gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" ++ ++gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] ++gdb_continue_to_breakpoint "varz-almostfilled" ++# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. ++gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" ++# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) ++# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. ++gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" ++gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p varz(3)" "\\$\[0-9\]* = 4" ++# maps to foo::vary(1,1) ++gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" ++# maps to foo::vary(2,2) ++gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" ++# maps to foo::vary(1,3) ++gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/dynamic.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,98 @@ ++! 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine baz ++ real, target, allocatable :: varx (:, :, :) ++ real, pointer :: varv (:, :, :) ++ real, target :: varu (1, 2, 3) ++ logical :: l ++ allocate (varx (1:6, 5:15, 17:28)) ! varx-init ++ l = allocated (varx) ++ varx(:, :, :) = 6 ! varx-allocated ++ varx(1, 5, 17) = 7 ++ varx(2, 6, 18) = 8 ++ varx(6, 15, 28) = 9 ++ varv => varx ! varx-filled ++ l = associated (varv) ++ varv(3, 7, 19) = 10 ! varv-associated ++ varv => null () ! varv-filled ++ l = associated (varv) ++ deallocate (varx) ! varv-deassociated ++ l = allocated (varx) ++ varu(:, :, :) = 10 ! varx-deallocated ++ allocate (varv (1:6, 5:15, 17:28)) ++ l = associated (varv) ++ varv(:, :, :) = 6 ++ varv(1, 5, 17) = 7 ++ varv(2, 6, 18) = 8 ++ varv(6, 15, 28) = 9 ++ deallocate (varv) ++ l = associated (varv) ++ varv => varu ++ varv(1, 1, 1) = 6 ++ varv(1, 2, 3) = 7 ++ l = associated (varv) ++end subroutine baz ++subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ vary(:, :) = 4 ! vary-passed ++ vary(1, 1) = 8 ++ vary(2, 2) = 9 ++ vary(1, 3) = 10 ++ varw(:, :, :) = 5 ! vary-filled ++ varw(1, 1, 1) = 6 ++ varw(2, 2, 2) = 7 ! varw-almostfilled ++end subroutine foo ++subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ varz(1:3) = 4 ++ varz(2) = 5 ! varz-almostfilled ++ vart(2,7) = vart(2,7) ++end subroutine bar ++program test ++ interface ++ subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ end subroutine ++ end interface ++ interface ++ subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ end subroutine ++ end interface ++ real :: x (10, 10), y (5), z(8, 8, 8) ++ x(:,:) = 1 ++ y(:) = 2 ++ z(:,:,:) = 3 ++ call baz ++ call foo (x, z(2:6, 4:7, 6:8)) ++ call bar (y, x) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (1, 3) .ne. 10) call abort ++ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort ++ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort ++ call foo (transpose (x), z) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (3, 1) .ne. 10) call abort ++end +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/string.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/string.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,59 @@ ++# 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. ++ ++# This file was written by Jan Kratochvil . ++ ++# This file is part of the gdb testsuite. It contains tests for Fortran ++# strings with dynamic length. ++ ++set testfile "string" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "var-init"] ++gdb_continue_to_breakpoint "var-init" ++gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" ++gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" ++gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" ++gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" ++gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." ++gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" ++gdb_test "p c" "\\$\[0-9\]* = 'c'" ++gdb_test "p d" "\\$\[0-9\]* = 'd '" ++gdb_test "p e" "\\$\[0-9\]* = 'g '" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" ++gdb_test "p *e" "Attempt to take contents of a non-pointer value." ++gdb_test "p *f" "Attempt to take contents of a non-pointer value." ++ ++gdb_breakpoint [gdb_get_line_number "var-finish"] ++gdb_continue_to_breakpoint "var-finish" ++gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/string.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/string.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,37 @@ ++! 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine foo (e, f) ++ character (len=1) :: c ++ character (len=8) :: d ++ character (len=*) :: e ++ character (len=*) :: f (1:7, 8:10) ++ c = 'c' ++ d = 'd' ++ e = 'e' ! var-init ++ f = 'f' ++ f(1,9) = 'f2' ++ c = 'c' ! var-finish ++end subroutine foo ++ character (len=4) :: g, h (1:7, 8:10) ++ g = 'g' ++ h = 'h' ++ call foo (g, h) ++end +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/subrange.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/subrange.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,60 @@ ++# Copyright 2011 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 . ++ ++if { [skip_fortran_tests] } { return -1 } ++ ++set testfile "subrange" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 ++} ++ ++if ![runto MAIN__] { ++ perror "Couldn't run to MAIN__" ++ continue ++} ++ ++# Depending on the compiler version being used, the name of the 4-byte integer ++# and real types can be printed differently. For instance, gfortran-4.1 uses ++# "int4" whereas gfortran-4.3 uses "int(kind=4)". ++set int4 "(int4|integer\\(kind=4\\))" ++ ++gdb_breakpoint [gdb_get_line_number "break-static"] ++gdb_continue_to_breakpoint "break-static" ".*break-static.*" ++ ++foreach var {a alloc ptr} { ++ global pf_prefix ++ set old_prefix $pf_prefix ++ lappend pf_prefix "$var:" ++ ++ gdb_test "p $var (2, 2:3)" { = \(22, 32\)} ++ gdb_test "p $var (2:3, 3)" { = \(32, 33\)} ++ gdb_test "p $var (1, 2:)" { = \(21, 31\)} ++ gdb_test "p $var (2, :2)" { = \(12, 22\)} ++ gdb_test "p $var (3, 2:2)" { = \(23\)} ++ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)" ++ gdb_test "p $var (4, :)" { = \(14, 24, 34\)} ++ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)} ++ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)" ++ gdb_test "p $var (:)" "Wrong number of subscripts" ++ gdb_test "p $var (:, :, :)" "Wrong number of subscripts" ++ ++ set pf_prefix $old_prefix ++} ++ ++gdb_test_no_output {set $a=a} ++delete_breakpoints ++gdb_unload ++gdb_test {p $a (3, 2:2)} { = \(23\)} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/subrange.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/subrange.f90 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,28 @@ ++! Copyright 2011 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 . ++ ++program test ++ integer, target :: a (4, 3) ++ integer, allocatable :: alloc (:, :) ++ integer, pointer :: ptr (:, :) ++ do 1 i = 1, 4 ++ do 1 j = 1, 3 ++ a (i, j) = j * 10 + i ++1 continue ++ allocate (alloc (4, 3)) ++ alloc = a ++ ptr => a ++ write (*,*) a ! break-static ++end +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.gdb/selftest.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.gdb/selftest.exp 2011-07-29 22:52:00.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.gdb/selftest.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} { + set description "step over ttyarg initialization" + set command "step" + } ++ -re ".*python_script = 0.*$gdb_prompt $" { ++ set description "step over python_script initialization" ++ set command "step" ++ } + -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { + set description "next over make_command_stats_cleanup and everything it calls" + set command "next" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-var-stale-type.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-var-stale-type.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,26 @@ ++/* Copyright 2011 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 . */ ++ ++int ++main (int argc, char **argv) ++{ ++ char vla[argc]; ++ ++ vla[0] = 0; /* break-here */ ++ ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,57 @@ ++# Copyright 2011 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 . ++ ++load_lib mi-support.exp ++set MIFLAGS "-i=mi2" ++ ++gdb_exit ++if [mi_gdb_start] { ++ continue ++} ++ ++set testfile "mi2-var-stale-type" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { ++ return -1 ++} ++ ++mi_delete_breakpoints ++mi_gdb_reinitialize_dir $srcdir/$subdir ++mi_gdb_load ${binfile} ++ ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \ ++ {\^done} \ ++ "maintenance set internal-error quit yes" ++ ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \ ++ {\^done} \ ++ "maintenance set internal-error corefile yes" ++ ++set line [gdb_get_line_number "break-here"] ++set func "main" ++ ++mi_gdb_test "-break-insert -t $srcfile:$line" \ ++ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" \ ++ "breakpoint at $func" ++ ++if { [mi_run_cmd] < 0 } { ++ return -1 ++} ++mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla" ++ ++mi_create_varobj "vla" "vla" "create local variable vla" ++ ++mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.multi/watchpoint-multi.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.multi/watchpoint-multi.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,59 @@ ++/* 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 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 . */ ++ ++#include ++#include ++ ++static volatile int a, b, c; ++ ++static void ++marker_exit1 (void) ++{ ++ a = 1; ++} ++ ++/* Workaround PR breakpoints/12272 by two different breakpoint locations. */ ++static void ++marker_exit2 (void) ++{ ++ a = 1; ++} ++ ++static void * ++start (void *arg) ++{ ++ b = 2; ++ c = 3; ++ ++ return NULL; ++} ++ ++int ++main (void) ++{ ++ pthread_t thread; ++ int i; ++ ++ i = pthread_create (&thread, NULL, start, NULL); ++ assert (i == 0); ++ i = pthread_join (thread, NULL); ++ assert (i == 0); ++ ++ marker_exit1 (); ++ marker_exit2 (); ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.multi/watchpoint-multi.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.multi/watchpoint-multi.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,113 @@ ++# 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 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 . ++ ++if { [is_remote target] || ![isnative] } then { ++ continue ++} ++ ++set testfile "watchpoint-multi" ++ ++set executable ${testfile} ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++if ![runto_main] { ++ return ++} ++# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug. ++delete_breakpoints ++ ++gdb_test "add-inferior" "Added inferior 2" ++gdb_test "inferior 2" "witching to inferior 2 .*" ++gdb_load $binfile ++ ++if ![runto_main] { ++ return ++} ++delete_breakpoints ++ ++# Simulate non-stop+target-async which also uses breakpoint always-inserted. ++gdb_test_no_output "set breakpoint always-inserted on" ++# displaced-stepping is also needed as other GDB sometimes still removes the ++# breakpoints, even with always-inserted on. ++gdb_test_no_output "set displaced-stepping on" ++ ++# Debugging of this testcase: ++#gdb_test_no_output "maintenance set show-debug-regs on" ++#gdb_test_no_output "set debug infrun 1" ++ ++# Do not use simple hardware watchpoint ("watch") as its false hit may be ++# unnoticed by GDB if it reads it still has the same value. ++gdb_test "awatch c" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c" ++# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug. ++# Use `*' to workaround a multi-inferior bug. ++set test "hbreak *marker_exit2" ++gdb_test_multiple $test $test { ++ -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" { ++ pass $test ++ untested ${testfile}.exp ++ return ++ } ++} ++ ++gdb_test "inferior 1" "witching to inferior 1 .*" ++ ++gdb_test "awatch b" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b" ++gdb_test "hbreak *marker_exit1" {Hardware assisted breakpoint [0-9]+ at .*} ++ ++gdb_test "inferior 2" "witching to inferior 2 .*" ++ ++# FAIL would be a hit on watchpoint for `b' - that one is for the other ++# inferior. ++gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" "catch c" ++ ++set test "catch marker_exit2" ++gdb_test_multiple "continue" $test { ++ -re "Breakpoint \[0-9\]+, marker_exit2 .*\r\n$gdb_prompt $" { ++ setup_kfail breakpoints/12312 *-*-* ++ pass $test ++ } ++ -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nValue = 3\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" { ++ setup_kfail breakpoints/12312 *-*-* ++ fail $test ++ } ++} ++ ++gdb_test "inferior 1" "witching to inferior 1 .*" ++ ++gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nOld value = 0\r\nNew value = 2\r\n.*" "catch b" ++ ++set test "catch marker_exit1" ++gdb_test_multiple "continue" $test { ++ -re "Breakpoint \[0-9\]+, marker_exit1 .*\r\n$gdb_prompt $" { ++ setup_kfail breakpoints/12312 *-*-* ++ pass $test ++ } ++ -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nValue = 2\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" { ++ setup_kfail breakpoints/12312 *-*-* ++ fail $test ++ } ++} ++ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register-func.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register-func.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,22 @@ ++/* This file is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++int ++func (int *arr) ++{ ++ return arr[0]; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,28 @@ ++/* This file is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++extern int func (int *arr); ++ ++int ++main (void) ++{ ++ int arr[] = { 42 }; ++ ++ func (arr); ++ ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.opt/array-from-register.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,33 @@ ++# Copyright 2009 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 file is part of the gdb testsuite. ++ ++if { [prepare_for_testing array-from-register.exp "array-from-register" \ ++ {array-from-register.c array-from-register-func.c} \ ++ {debug optimize=-O2}] } { ++ return -1 ++} ++ ++if ![runto func] then { ++ return -1 ++} ++ ++gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" ++ ++# Seen regression: ++# Address requested for identifier "arr" which is in register $rdi ++gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.pascal/arrays.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.pascal/arrays.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,104 @@ ++# Copyright 2008, 2009 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 . ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++load_lib "pascal.exp" ++ ++set testfile "arrays" ++set srcfile ${testfile}.pas ++set binfile ${objdir}/${subdir}/${testfile}$EXEEXT ++ ++# These tests only work with fpc, using the -gw3 compile-option ++pascal_init ++if { $pascal_compiler_is_fpc != 1 } { ++ return -1 ++} ++ ++# Detect if the fpc version is below 2.3.0 ++set fpc_generates_dwarf_for_dynamic_arrays 1 ++if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { ++ set fpc_generates_dwarf_for_dynamic_arrays 0 ++} ++ ++ ++if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] ++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] ++ ++ ++if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { ++ pass "setting breakpoint 1" ++} ++if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { ++ pass "setting breakpoint 2" ++} ++ ++# Verify that "start" lands inside the right procedure. ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++ ++gdb_test "" ".* at .*${srcfile}.*" "start" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" ++ ++gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" ++gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" ++ ++gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" ++gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" ++ ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" ++ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.pascal/arrays.pas +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.pascal/arrays.pas 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,82 @@ ++{ ++ Copyright 2008, 2009 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 . ++} ++ ++program arrays; ++ ++{$mode objfpc}{$h+} ++ ++uses sysutils; ++ ++type TStatArrInt= array[0..11] of integer; ++ TDynArrInt= array of integer; ++ TStatArrStr= array[0..12] of string; ++ TDynArrStr= array of string; ++ TDynArrChar = array of char; ++ TStatArrChar = array [0..11] of char; ++ ++ TStat2dArrInt = array[0..11,0..4] of integer; ++ ++var StatArrInt: TStatArrInt; ++ StatArrInt_: Array[0..11] of integer; ++ DynArrInt: TDynArrInt; ++ DynArrInt_: Array of integer; ++ StatArrStr: TStatArrStr; ++ DynArrStr: TDynArrStr; ++ StatArrChar: TStatArrChar; ++ DynArrChar: TDynArrChar; ++ ++ Stat2dArrInt: TStat2dArrInt; ++ ++ s: string; ++ ++ i,j : integer; ++ ++begin ++ for i := 0 to 11 do ++ begin ++ StatArrInt[i]:= i+50; ++ StatArrInt_[i]:= i+50; ++ StatArrChar[i]:= chr(ord('a')+i); ++ for j := 0 to 4 do ++ Stat2dArrInt[i,j]:=i+j; ++ end; ++ writeln(StatArrInt_[0]); ++ writeln(StatArrInt[0]); { set breakpoint 1 here } ++ writeln(StatArrChar[0]); ++ writeln(Stat2dArrInt[0,0]); ++ ++ setlength(DynArrInt,13); ++ setlength(DynArrInt_,13); ++ setlength(DynArrStr,13); ++ setlength(DynArrChar,13); ++ for i := 0 to 12 do ++ begin ++ DynArrInt[i]:= i+50; ++ DynArrInt_[i]:= i+50; ++ DynArrChar[i]:= chr(ord('a')+i); ++ StatArrStr[i]:='str'+inttostr(i); ++ DynArrStr[i]:='dstr'+inttostr(i); ++ end; ++ writeln(DynArrInt_[1]); ++ writeln(DynArrInt[1]); ++ writeln(DynArrStr[1]); ++ writeln(StatArrStr[1]); ++ writeln(DynArrChar[1]); ++ ++ s := 'test'#0'string'; ++ writeln(s); { set breakpoint 2 here } ++end. +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.python/py-frame.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.python/py-frame.exp 2011-02-26 15:06:28.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.python/py-frame.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -78,8 +78,6 @@ gdb_test "python print bframe == gdb.new + + gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" + gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" +-gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" +-gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" + gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" + gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" + gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" +@@ -94,3 +92,5 @@ gdb_test "python print 'result =', f0.re + gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" + + gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" ++ ++gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.python/py-value.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.python/py-value.exp 2011-04-24 11:04:38.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.python/py-value.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -319,6 +319,15 @@ proc test_value_after_death {} { + "print value's type" + } + ++# Regression test for a cast failure. The bug was that if we cast a ++# value to its own type, gdb could crash. This happened because we ++# could end up double-freeing a struct value. ++proc test_cast_regression {} { ++ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" ++ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" ++ gdb_test "python print v" "5" "print value for cast test" ++} ++ + # Regression test for invalid subscript operations. The bug was that + # the type of the value was not being checked before allowing a + # subscript operation to proceed. +@@ -456,6 +465,7 @@ test_value_in_inferior + test_inferior_function_call + test_lazy_strings + test_value_after_death ++test_cast_regression + + # The following test recompiles the binary to test either C or C++ + # values. +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-child.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-child.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,127 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++ Copyright 2008, 2009, 2010 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 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 ++#include ++#include ++#include ++#include ++#include ++ ++#include "watchpoint-fork.h" ++ ++static volatile int usr1_got; ++ ++static void ++handler_usr1 (int signo) ++{ ++ usr1_got++; ++} ++ ++void ++forkoff (int nr) ++{ ++ pid_t child, save_parent = getpid (); ++ int i; ++ struct sigaction act, oldact; ++#ifdef THREAD ++ void *thread_result; ++#endif ++ ++ memset (&act, 0, sizeof act); ++ act.sa_flags = SA_RESTART; ++ act.sa_handler = handler_usr1; ++ sigemptyset (&act.sa_mask); ++ i = sigaction (SIGUSR1, &act, &oldact); ++ assert (i == 0); ++ ++ child = fork (); ++ switch (child) ++ { ++ case -1: ++ assert (0); ++ default: ++ printf ("parent%d: %d\n", nr, (int) child); ++ ++ /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB ++ tracing the child fork with no longer valid thread/lwp entries of the ++ parent. */ ++ ++ i = sleep (2); ++ assert (i == 0); ++ ++ /* We must not get caught here (against a forgotten breakpoint). */ ++ ++ var++; ++ marker (); ++ ++#ifdef THREAD ++ /* And neither got caught our thread. */ ++ ++ step = 99; ++ i = pthread_join (thread, &thread_result); ++ assert (i == 0); ++ assert (thread_result == (void *) 99UL); ++#endif ++ ++ /* Be sure our child knows we did not get caught above. */ ++ ++ i = kill (child, SIGUSR1); ++ assert (i == 0); ++ ++ /* Sleep for a while to check GDB's `info threads' no longer tracks us in ++ the child fork. */ ++ ++ i = sleep (2); ++ assert (i == 0); ++ ++ _exit (0); ++ case 0: ++ printf ("child%d: %d\n", nr, (int) getpid ()); ++ ++ /* Let the parent signal us about its success. Be careful of races. */ ++ ++ for (;;) ++ { ++ /* Parent either died (and USR1_GOT is zero) or it succeeded. */ ++ if (getppid () != save_parent) ++ break; ++ if (kill (getppid (), 0) != 0) ++ break; ++ /* Parent succeeded? */ ++ if (usr1_got) ++ break; ++ ++#ifdef THREAD ++ i = pthread_yield (); ++ assert (i == 0); ++#endif ++ } ++ assert (usr1_got); ++ ++ /* We must get caught here (against a false watchpoint removal). */ ++ ++ marker (); ++ } ++ ++ i = sigaction (SIGUSR1, &oldact, NULL); ++ assert (i == 0); ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,174 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++ Copyright 2008, 2009, 2010 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 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 ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#define gettid() syscall (__NR_gettid) ++ ++#include "watchpoint-fork.h" ++ ++/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP ++ variable. Hit-comments need to be duplicite there to catch both at-stops ++ and behind-stops, depending on the target. */ ++ ++volatile int var; ++ ++void ++marker (void) ++{ ++} ++ ++static void ++empty (void) ++{ ++} ++ ++static void ++mark_exit (void) ++{ ++} ++ ++pthread_t thread; ++volatile int step; ++ ++static void * ++start (void *arg) ++{ ++ int i; ++ ++ if (step >= 3) ++ goto step_3; ++ ++ while (step != 1) ++ { ++ i = pthread_yield (); ++ assert (i == 0); ++ } ++ ++ var++; /* validity-thread-B */ ++ empty (); /* validity-thread-B */ ++ step = 2; ++ while (step != 3) ++ { ++ if (step == 99) ++ goto step_99; ++ ++ i = pthread_yield (); ++ assert (i == 0); ++ } ++ ++step_3: ++ if (step >= 5) ++ goto step_5; ++ ++ var++; /* after-fork1-B */ ++ empty (); /* after-fork1-B */ ++ step = 4; ++ while (step != 5) ++ { ++ if (step == 99) ++ goto step_99; ++ ++ i = pthread_yield (); ++ assert (i == 0); ++ } ++ ++step_5: ++ var++; /* after-fork2-B */ ++ empty (); /* after-fork2-B */ ++ return (void *) 5UL; ++ ++step_99: ++ /* We must not get caught here (against a forgotten breakpoint). */ ++ var++; ++ marker (); ++ return (void *) 99UL; ++} ++ ++int ++main (void) ++{ ++ int i; ++ void *thread_result; ++ ++ setbuf (stdout, NULL); ++ printf ("main: %d\n", (int) gettid ()); ++ ++ /* General hardware breakpoints and watchpoints validity. */ ++ marker (); ++ var++; /* validity-first */ ++ empty (); /* validity-first */ ++ ++ i = pthread_create (&thread, NULL, start, NULL); ++ assert (i == 0); ++ ++ var++; /* validity-thread-A */ ++ empty (); /* validity-thread-A */ ++ step = 1; ++ while (step != 2) ++ { ++ i = pthread_yield (); ++ assert (i == 0); ++ } ++ ++ /* Hardware watchpoints got disarmed here. */ ++ forkoff (1); ++ ++ var++; /* after-fork1-A */ ++ empty (); /* after-fork1-A */ ++ step = 3; ++#ifdef FOLLOW_CHILD ++ /* Spawn new thread as it was deleted in the child of FORK. */ ++ i = pthread_create (&thread, NULL, start, NULL); ++ assert (i == 0); ++#endif ++ while (step != 4) ++ { ++ i = pthread_yield (); ++ assert (i == 0); ++ } ++ ++ /* A sanity check for double hardware watchpoints removal. */ ++ forkoff (2); ++ ++ var++; /* after-fork2-A */ ++ empty (); /* after-fork2-A */ ++ step = 5; ++#ifdef FOLLOW_CHILD ++ /* Spawn new thread as it was deleted in the child of FORK. */ ++ i = pthread_create (&thread, NULL, start, NULL); ++ assert (i == 0); ++#endif ++ ++ i = pthread_join (thread, &thread_result); ++ assert (i == 0); ++ assert (thread_result == (void *) 5UL); ++ ++ mark_exit (); ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,74 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++ Copyright 2008, 2009, 2010 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 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 ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "watchpoint-fork.h" ++ ++void ++forkoff (int nr) ++{ ++ pid_t child, pid_got; ++ int exit_code = 42 + nr; ++ int status, i; ++ ++ child = fork (); ++ switch (child) ++ { ++ case -1: ++ assert (0); ++ case 0: ++ printf ("child%d: %d\n", nr, (int) getpid ()); ++ /* Delay to get both the "child%d" and "parent%d" message printed without ++ a race breaking expect by its endless wait on `$gdb_prompt$': ++ Breakpoint 3, marker () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33 ++ 33 } ++ (gdb) parent2: 14223 */ ++ i = sleep (1); ++ assert (i == 0); ++ ++ /* We must not get caught here (against a forgotten breakpoint). */ ++ var++; ++ marker (); ++ ++ _exit (exit_code); ++ default: ++ printf ("parent%d: %d\n", nr, (int) child); ++ /* Delay to get both the "child%d" and "parent%d" message printed, see ++ above. */ ++ i = sleep (1); ++ assert (i == 0); ++ ++ pid_got = wait (&status); ++ assert (pid_got == child); ++ assert (WIFEXITED (status)); ++ assert (WEXITSTATUS (status) == exit_code); ++ ++ /* We must get caught here (against a false watchpoint removal). */ ++ marker (); ++ } ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-st.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork-st.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,61 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++ Copyright 2008, 2009, 2010 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 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 ++#include ++#include ++#include ++#include ++ ++#include "watchpoint-fork.h" ++ ++volatile int var; ++ ++void ++marker (void) ++{ ++} ++ ++static void ++mark_exit (void) ++{ ++} ++ ++int ++main (void) ++{ ++ setbuf (stdout, NULL); ++ printf ("main: %d\n", (int) getpid ()); ++ ++ /* General hardware breakpoints and watchpoints validity. */ ++ marker (); ++ var++; ++ /* Hardware watchpoints got disarmed here. */ ++ forkoff (1); ++ /* This watchpoint got lost before. */ ++ var++; ++ /* A sanity check for double hardware watchpoints removal. */ ++ forkoff (2); ++ var++; ++ ++ mark_exit (); ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,149 @@ ++# Copyright 2008, 2009, 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 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 . ++ ++# Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++proc test {type symbol} { ++ global objdir subdir srcdir gdb_prompt ++ ++ set testfile watchpoint-fork ++ ++ global pf_prefix ++ set prefix_test $pf_prefix ++ lappend pf_prefix "$type:" ++ set prefix_mt $pf_prefix ++ ++ set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c ++ ++ ++ # no threads ++ ++ set pf_prefix $prefix_mt ++ lappend pf_prefix "singlethreaded:" ++ ++ set executable ${testfile}-${type}-st ++ set srcfile_main ${srcdir}/${subdir}/${testfile}-st.c ++ if { [gdb_compile "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } { ++ untested ${testfile}.exp ++ return ++ } ++ clean_restart $executable ++ ++ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on\\." ++ gdb_test_no_output "set follow-fork-mode $type" ++ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"\\." ++ # Testcase uses it for the `follow-fork-mode child' type. ++ gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" ++ ++ if ![runto_main] { ++ return ++ } ++ ++ gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" ++ ++ # It is never hit but it should not be left over in the fork()ed-off child. ++ set hbreak "hbreak" ++ set test "hbreak marker" ++ gdb_test_multiple $test $test { ++ -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" { ++ pass $test ++ set hbreak "break" ++ gdb_test "break marker" ++ } ++ } ++ ++ gdb_breakpoint "mark_exit" ++ ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "breakpoint after the second fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*mark_exit \\(\\);" "watchpoint after the second fork" ++ gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" ++ ++ ++ # threads ++ ++ set pf_prefix $prefix_mt ++ lappend pf_prefix "multithreaded:" ++ ++ set executable ${testfile}-${type}-mt ++ set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c ++ if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } { ++ untested ${testfile}.exp ++ return ++ } ++ clean_restart $executable ++ ++ gdb_test_no_output "set follow-fork-mode $type" ++ # Testcase uses it for the `follow-fork-mode child' type. ++ gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" ++ ++ if ![runto_main] { ++ return ++ } ++ ++ gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" ++ ++ # It should not be left over in the fork()ed-off child. ++ gdb_test "$hbreak marker" {reakpoint [0-9]+.*} ++ ++ gdb_breakpoint "mark_exit" ++ ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B" ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the first fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork" ++ gdb_test "continue" \ ++ "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the second fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork" ++ gdb_test "continue" \ ++ "atchpoint \[0-9\]+: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork" ++ gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" ++ ++ ++ # cleanup ++ set pf_prefix $prefix_test ++} ++ ++test parent FOLLOW_PARENT ++ ++# Only GNU/Linux is known to support `set follow-fork-mode child'. ++if {[istarget "*-*-linux*"] && ![is_remote target]} { ++ test child FOLLOW_CHILD ++} else { ++ untested "child" ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/watchpoint-fork.h 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,32 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++ ++ Copyright 2008, 2009, 2010 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 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. */ ++ ++#ifdef THREAD ++#include ++ ++extern volatile int step; ++extern pthread_t thread; ++#endif /* THREAD */ ++ ++extern volatile int var; ++ ++extern void marker (void); ++extern void forkoff (int nr); +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.trace/stap-trace.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.trace/stap-trace.c 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,71 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++#if USE_PROBES ++ ++#define _SDT_HAS_SEMAPHORES ++__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); ++#define TEST teste_user_semaphore ++ ++__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); ++#define TEST2 teste_two_semaphore ++ ++#else ++ ++#define TEST 1 ++#define TEST2 1 ++ ++#endif /* USE_PROBES */ ++ ++#include ++ ++/* We only support SystemTap and only the v3 form. */ ++#if _SDT_NOTE_TYPE != 3 ++#error "not using SystemTap v3 probes" ++#endif ++ ++void ++m1 (int x) ++{ ++ if (TEST2) ++ STAP_PROBE1 (teste, two, x); ++} ++ ++int ++f (int x) ++{ ++ if (TEST) ++ STAP_PROBE1(teste, user, x); ++ return x+5; ++} ++ ++void ++nothing (void) ++{ ++ int a = 1 + 1; ++ return; ++} ++ ++int ++main() ++{ ++ f (f (23)); ++ m1 (46); ++ nothing (); /* end-here */ ++ ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.trace/stap-trace.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.trace/stap-trace.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -0,0 +1,129 @@ ++# Copyright 2011 ++# 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 . ++ ++load_lib "trace-support.exp" ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile "stap-trace" ++set srcfile ${testfile}.c ++set executable $testfile ++set binfile $objdir/$subdir/$executable ++ ++set ws "\[\r\n\t \]+" ++set cr "\[\r\n\]+" ++ ++# Only x86 and x86_64 targets are supported for now. ++ ++if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } { ++ continue ++} ++ ++proc compile_stap_bin {{ arg "" }} { ++ global srcfile ++ global binfile ++ global srcdir ++ global subdir ++ ++ if { $arg != "" } { ++ set arg "additional_flags=$arg" ++ } ++ ++ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ ++ executable [concat $arg debug nowarnings]] != "" } { ++ untested "Could not compile ${srcfile}" ++ return -1 ++ } ++} ++ ++proc prepare_for_trace_test {} { ++ global executable ++ ++ clean_restart $executable ++ ++ if { ![runto_main] } { ++ perror "Could not run to `main'." ++ continue ++ } ++ ++ gdb_breakpoint [gdb_get_line_number "end-here"] ++} ++ ++proc run_trace_experiment { test_probe msg } { ++ global gdb_prompt ++ ++ set test "collect $msg: start trace experiment" ++ gdb_test_multiple "tstart" "$test" { ++ -re "^tstart\r\n$gdb_prompt $" { ++ pass "$test" ++ } ++ } ++ ++ gdb_test "continue" \ ++ "Continuing.*Breakpoint \[0-9\]+.*" \ ++ "collect $msg: run trace experiment" ++ gdb_test "tstop" \ ++ "\[\r\n\]+" \ ++ "collect $msg: stop trace experiment" ++ gdb_test "tfind start" \ ++ "#0 .*" \ ++ "collect $msg: tfind test frame" ++} ++ ++proc gdb_collect_probe_arg { msg probe val_arg0 } { ++ global gdb_prompt ++ global cr ++ ++ prepare_for_trace_test ++ ++ gdb_test "trace $probe" \ ++ "Tracepoint \[0-9\]+ at .*" \ ++ "collect $msg: set tracepoint" ++ gdb_trace_setactions "collect $msg: define actions" \ ++ "" \ ++ "collect \$_probe_arg0" "^$" ++ ++ # Begin the test. ++ run_trace_experiment $msg $probe ++ ++ gdb_test "print \$_probe_arg0" \ ++ "\\$\[0-9\]+ = $val_arg0$cr" \ ++ "collect $msg: collected probe arg0" ++} ++ ++compile_stap_bin "" ++ ++clean_restart $executable ++if { ![runto_main] } { ++ perror "Could not run to `main'." ++ continue ++} ++ ++if { ![gdb_target_supports_trace] } { ++ # Test cannot run on this target. ++ return 1; ++} ++ ++gdb_collect_probe_arg "probe args without semaphore" "probe:user" "23" ++gdb_exit ++ ++compile_stap_bin "-DUSE_PROBES" ++gdb_collect_probe_arg "probe args with semaphore" "probe:two" "46" ++ ++# Finished! ++gdb_test "tfind none" ".*" "" +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/gdb.exp 2011-07-15 16:11:22.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -141,6 +141,11 @@ proc gdb_unload {} { + send_gdb "y\n" + exp_continue + } ++ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\ ++ { send_gdb "y\n" ++ verbose "\t\tUnloading symbols for program being debugged" ++ exp_continue ++ } + -re "Discard symbol table from .*y or n.*$" { + send_gdb "y\n" + exp_continue +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/pascal.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/pascal.exp 2011-01-01 16:33:52.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/pascal.exp 2011-07-29 22:52:02.000000000 +0200 +@@ -37,6 +37,9 @@ proc pascal_init {} { + global pascal_compiler_is_fpc + global gpc_compiler + global fpc_compiler ++ global fpcversion_major ++ global fpcversion_minor ++ global fpcversion_release + global env + + if { $pascal_init_done == 1 } { +@@ -64,6 +67,20 @@ proc pascal_init {} { + set pascal_compiler_is_fpc 1 + verbose -log "Free Pascal compiler found" + } ++ ++ # Detect the fpc-version ++ if { $pascal_compiler_is_fpc == 1 } { ++ set fpcversion_major 1 ++ set fpcversion_minor 0 ++ set fpcversion_release 0 ++ set fpcversion [ remote_exec host $fpc_compiler "-iV" ] ++ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] { ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release ++ } ++ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release" ++ } + } + set pascal_init_done 1 + } +Index: gdb-7.3.50.20110722/gdb/thread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/thread.c 2011-05-30 20:04:32.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/thread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1441,7 +1441,8 @@ update_thread_list (void) + no thread is selected, or no threads exist. */ + + static struct value * +-thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var) ++thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var, ++ void *ignore) + { + struct thread_info *tp = find_thread_ptid (inferior_ptid); + +@@ -1452,6 +1453,15 @@ thread_id_make_value (struct gdbarch *gd + /* Commands with a prefix of `thread'. */ + struct cmd_list_element *thread_cmd_list = NULL; + ++/* Implementation of `thread' variable. */ ++ ++static struct internalvar_funcs thread_funcs = ++{ ++ thread_id_make_value, ++ NULL, ++ NULL ++}; ++ + void + _initialize_thread (void) + { +@@ -1497,5 +1507,5 @@ Show printing of thread events (such as + show_print_thread_events, + &setprintlist, &showprintlist); + +- create_internalvar_type_lazy ("_thread", thread_id_make_value); ++ create_internalvar_type_lazy ("_thread", &thread_funcs, NULL); + } +Index: gdb-7.3.50.20110722/gdb/top.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/top.c 2011-07-21 13:03:45.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/top.c 2011-07-29 22:52:02.000000000 +0200 +@@ -347,6 +347,9 @@ prepare_execute_command (void) + + mark = value_mark (); + cleanup = make_cleanup_value_free_to_mark (mark); ++#if 0 ++ free_all_types (); ++#endif + + /* With multiple threads running while the one we're examining is + stopped, the dcache can get stale without us being able to detect +Index: gdb-7.3.50.20110722/gdb/tracepoint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/tracepoint.c 2011-07-07 15:32:55.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/tracepoint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1609,6 +1609,8 @@ start_tracing (void) + + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++) + { ++ struct bp_location *loc; ++ + if ((t->type == bp_fast_tracepoint + ? !may_insert_fast_tracepoints + : !may_insert_tracepoints)) +@@ -1617,6 +1619,9 @@ start_tracing (void) + t->number_on_target = 0; + target_download_tracepoint (t); + t->number_on_target = t->number; ++ ++ for (loc = t->loc; loc; loc = loc->next) ++ modify_semaphore (loc, 1); + } + VEC_free (breakpoint_p, tp_vec); + +@@ -1678,7 +1683,28 @@ trace_stop_command (char *args, int from + void + stop_tracing (void) + { ++ VEC(breakpoint_p) *tp_vec = NULL; ++ int ix; ++ struct breakpoint *t; ++ + target_trace_stop (); ++ ++ tp_vec = all_tracepoints (); ++ for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++) ++ { ++ struct bp_location *loc; ++ ++ if ((t->type == bp_fast_tracepoint ++ ? !may_insert_fast_tracepoints ++ : !may_insert_tracepoints)) ++ continue; ++ ++ for (loc = t->loc; loc; loc = loc->next) ++ modify_semaphore (loc, 0); ++ } ++ ++ VEC_free (breakpoint_p, tp_vec); ++ + /* Should change in response to reply? */ + current_trace_status ()->running = 0; + } +@@ -4521,7 +4547,8 @@ info_static_tracepoint_markers_command ( + available. */ + + static struct value * +-sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var) ++sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, ++ void *ignore) + { + LONGEST size; + gdb_byte *buf; +@@ -4700,6 +4727,15 @@ traceframe_available_memory (VEC(mem_ran + return 0; + } + ++/* Implementation of `sdata' variable. */ ++ ++static const struct internalvar_funcs sdata_funcs = ++{ ++ sdata_make_value, ++ NULL, ++ NULL ++}; ++ + /* module initialization */ + void + _initialize_tracepoint (void) +@@ -4710,7 +4746,7 @@ _initialize_tracepoint (void) + value with a void typed value, and when we get here, gdbarch + isn't initialized yet. At this point, we're quite sure there + isn't another convenience variable of the same name. */ +- create_internalvar_type_lazy ("_sdata", sdata_make_value); ++ create_internalvar_type_lazy ("_sdata", &sdata_funcs, NULL); + + traceframe_number = -1; + tracepoint_number = -1; +Index: gdb-7.3.50.20110722/gdb/typeprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/typeprint.c 2011-01-11 22:53:25.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/typeprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -36,6 +36,7 @@ + #include "gdb_string.h" + #include "exceptions.h" + #include "valprint.h" ++#include "dwarf2loc.h" + #include + + extern void _initialize_typeprint (void); +@@ -77,6 +78,9 @@ void + type_print (struct type *type, char *varstring, struct ui_file *stream, + int show) + { ++ if (show >= 0) ++ type = check_typedef (type); ++ + LA_PRINT_TYPE (type, varstring, stream, show, 0); + } + +@@ -115,7 +119,8 @@ whatis_exp (char *exp, int show) + { + struct expression *expr; + struct value *val; +- struct cleanup *old_chain = NULL; ++ /* Required at least for the object_address_set call. */ ++ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); + struct type *real_type = NULL; + struct type *type; + int full = 0; +@@ -126,12 +131,13 @@ whatis_exp (char *exp, int show) + if (exp) + { + expr = parse_expression (exp); +- old_chain = make_cleanup (free_current_contents, &expr); ++ make_cleanup (free_current_contents, &expr); + val = evaluate_type (expr); + } + else + val = access_value_history (0); + ++ object_address_set (value_raw_address (val)); + type = value_type (val); + + get_user_print_options (&opts); +@@ -168,8 +174,7 @@ whatis_exp (char *exp, int show) + type_print (type, "", gdb_stdout, show); + printf_filtered ("\n"); + +- if (exp) +- do_cleanups (old_chain); ++ do_cleanups (old_chain); + } + + static void +Index: gdb-7.3.50.20110722/gdb/utils.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/utils.c 2011-07-22 01:46:09.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/utils.c 2011-07-29 22:52:02.000000000 +0200 +@@ -1874,6 +1874,36 @@ set_batch_flag_and_make_cleanup_restore_ + return back_to; + } + ++/* Helper for make_cleanup_restore_page_info. */ ++ ++static void ++do_restore_selected_frame_cleanup (void *arg) ++{ ++ struct frame_id *frame_idp = arg; ++ ++ select_frame (frame_find_by_id (*frame_idp)); ++ ++ xfree (frame_idp); ++} ++ ++/* Provide cleanup for restoring currently selected frame. Use frame_id for ++ the case the current frame becomes stale in the meantime. */ ++ ++struct cleanup * ++make_cleanup_restore_selected_frame (void) ++{ ++ struct frame_id *frame_idp; ++ ++ /* get_selected_frame->get_current_frame would error otherwise. */ ++ if (!has_stack_frames ()) ++ return make_cleanup (null_cleanup, NULL); ++ ++ frame_idp = xmalloc (sizeof (*frame_idp)); ++ *frame_idp = get_frame_id (get_selected_frame (NULL)); ++ ++ return make_cleanup (do_restore_selected_frame_cleanup, frame_idp); ++} ++ + /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */ + + static void +Index: gdb-7.3.50.20110722/gdb/valarith.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/valarith.c 2011-02-18 20:10:46.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/valarith.c 2011-07-29 22:52:02.000000000 +0200 +@@ -198,7 +198,10 @@ value_subscripted_rvalue (struct value * + struct type *array_type = check_typedef (value_type (array)); + struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); + unsigned int elt_size = TYPE_LENGTH (elt_type); +- unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); ++ unsigned int elt_stride ++ = (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)) == 0 ++ ? elt_size : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type))); ++ unsigned int elt_offs = elt_stride * longest_to_int (index - lowerbound); + struct value *v; + + if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) +@@ -298,6 +301,10 @@ int + binop_user_defined_p (enum exp_opcode op, + struct value *arg1, struct value *arg2) + { ++ /* FIXME: We should support user defined ops for dynamic types. */ ++ if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2))) ++ return 0; ++ + return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2)); + } + +Index: gdb-7.3.50.20110722/gdb/valops.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/valops.c 2011-07-14 17:00:20.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/valops.c 2011-07-29 22:52:02.000000000 +0200 +@@ -47,6 +47,7 @@ + #include "objfiles.h" + #include "symtab.h" + #include "exceptions.h" ++#include "dwarf2loc.h" + + extern int overload_debug; + /* Local functions. */ +@@ -915,6 +916,65 @@ value_one (struct type *type, enum lval_ + return val; + } + ++/* object_address_set must be already called before this function. */ ++ ++const char * ++object_address_data_not_valid (struct type *type) ++{ ++ /* Attributes are present only at the target type of a typedef. Make the ++ call conditional as it would otherwise loop through type_length_get. */ ++ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) ++ CHECK_TYPEDEF (type); ++ ++ /* DW_AT_associated has a preference over DW_AT_allocated. */ ++ if (TYPE_NOT_ASSOCIATED (type) ++ || (TYPE_ASSOCIATED (type) != NULL ++ && 0 == dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (type)))) ++ return N_("object is not associated"); ++ ++ if (TYPE_NOT_ALLOCATED (type) ++ || (TYPE_ALLOCATED (type) != NULL ++ && 0 == dwarf_locexpr_baton_eval (TYPE_ALLOCATED (type)))) ++ return N_("object is not allocated"); ++ ++ return NULL; ++} ++ ++/* Return non-NULL check_typedef result on TYPE if the variable is valid. If ++ it is valid the function may store the data address (DW_AT_DATA_LOCATION) of ++ TYPE at *ADDRESS_RETURN. You must set *ADDRESS_RETURN from ++ value_raw_address (VAL) before calling this function. If no ++ DW_AT_DATA_LOCATION is present for TYPE the address at *ADDRESS_RETURN is ++ left unchanged. ADDRESS_RETURN must not be NULL, use ++ object_address_data_not_valid () for just the data validity check. */ ++ ++struct type * ++object_address_get_data (struct type *type, CORE_ADDR *address_return) ++{ ++ gdb_assert (address_return != NULL); ++ ++ object_address_set (*address_return); ++ ++ /* TYPE_DATA_LOCATION_DWARF_BLOCK / TYPE_DATA_LOCATION_ADDR are present only ++ at the target type of a typedef. */ ++ CHECK_TYPEDEF (type); ++ ++ if (object_address_data_not_valid (type) != NULL) ++ { ++ /* Do not try to evaluate DW_AT_data_location as it may even crash ++ (it would just return the value zero in the gfortran case). */ ++ return NULL; ++ } ++ ++ if (TYPE_DATA_LOCATION_IS_ADDR (type)) ++ *address_return = TYPE_DATA_LOCATION_ADDR (type); ++ else if (TYPE_DATA_LOCATION_DWARF_BLOCK (type) != NULL) ++ *address_return ++ = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type)); ++ ++ return type; ++} ++ + /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */ + + static struct value * +@@ -1011,12 +1071,20 @@ value_fetch_lazy (struct value *val) + } + else if (VALUE_LVAL (val) == lval_memory) + { +- CORE_ADDR addr = value_address (val); +- int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val))); ++ CORE_ADDR addr = value_raw_address (val); + +- if (length) +- read_value_memory (val, 0, value_stack (val), +- addr, value_contents_all_raw (val), length); ++ if (object_address_get_data (value_type (val), &addr)) ++ { ++ struct type *type = value_enclosing_type (val); ++ int length = TYPE_LENGTH (check_typedef (type)); ++ ++ if (length) ++ { ++ addr += value_offset (val); ++ read_value_memory (val, 0, value_stack (val), ++ addr, value_contents_all_raw (val), length); ++ } ++ } + } + else if (VALUE_LVAL (val) == lval_register) + { +@@ -1528,7 +1596,18 @@ address_of_variable (struct symbol *var, + if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) + || TYPE_CODE (type) == TYPE_CODE_FUNC) + { +- CORE_ADDR addr = value_address (val); ++ CORE_ADDR addr; ++ ++ if (VALUE_LVAL (val) == lval_memory) ++ { ++ addr = value_raw_address (val); ++ if (!object_address_get_data (type, &addr)) ++ error (_("Can't take address of memory lvalue \"%s\"."), ++ SYMBOL_PRINT_NAME (var)); ++ set_value_address (val, addr); ++ } ++ ++ addr = value_address (val); + + return value_from_pointer (lookup_pointer_type (type), addr); + } +@@ -1635,6 +1714,7 @@ struct value * + value_coerce_array (struct value *arg1) + { + struct type *type = check_typedef (value_type (arg1)); ++ CORE_ADDR address; + + /* If the user tries to do something requiring a pointer with an + array that has not yet been pushed to the target, then this would +@@ -1644,8 +1724,12 @@ value_coerce_array (struct value *arg1) + if (VALUE_LVAL (arg1) != lval_memory) + error (_("Attempt to take address of value not located in memory.")); + ++ address = value_raw_address (arg1); ++ if (!object_address_get_data (type, &address)) ++ error (_("Attempt to take address of non-valid value.")); ++ + return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)), +- value_address (arg1)); ++ address + value_offset (arg1)); + } + + /* Given a value which is a function, return a value which is a pointer +@@ -3676,6 +3760,8 @@ value_slice (struct value *array, int lo + TYPE_TARGET_TYPE (range_type), + lowbound, + lowbound + length - 1); ++ TYPE_BYTE_STRIDE (slice_range_type) = TYPE_BYTE_STRIDE (range_type); ++ + if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING) + { + int i; +Index: gdb-7.3.50.20110722/gdb/valprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/valprint.c 2011-06-29 17:32:39.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/valprint.c 2011-07-29 22:52:02.000000000 +0200 +@@ -39,6 +39,7 @@ + #include "gdb_obstack.h" + #include "charset.h" + #include ++#include "dwarf2loc.h" + + #include + +@@ -242,7 +243,6 @@ scalar_type_p (struct type *type) + case TYPE_CODE_STRUCT: + case TYPE_CODE_UNION: + case TYPE_CODE_SET: +- case TYPE_CODE_STRING: + case TYPE_CODE_BITSTRING: + return 0; + default: +@@ -1196,6 +1196,7 @@ val_print_array_elements (struct type *t + { + unsigned int things_printed = 0; + unsigned len; ++ struct type *saved_type = type; + struct type *elttype, *index_type; + unsigned eltlen; + /* Position of the array element we are examining to see +@@ -1204,9 +1205,33 @@ val_print_array_elements (struct type *t + /* Number of repetitions we have detected so far. */ + unsigned int reps; + LONGEST low_bound, high_bound; ++ struct cleanup *back_to; ++ CORE_ADDR saved_address = address; ++ ++ back_to = make_cleanup (null_cleanup, 0); ++ type = object_address_get_data (type, &address); ++ if (!type) ++ { ++ fputs_filtered (object_address_data_not_valid (type), stream); ++ do_cleanups (back_to); ++ return; ++ } ++ if (address != saved_address) ++ { ++ size_t length = TYPE_LENGTH (type); + +- elttype = TYPE_TARGET_TYPE (type); +- eltlen = TYPE_LENGTH (check_typedef (elttype)); ++ valaddr = xmalloc (length); ++ make_cleanup (xfree, (gdb_byte *) valaddr); ++ read_memory (address, (gdb_byte *) valaddr, length); ++ } ++ ++ /* Skip typedefs but do not resolve TYPE_DYNAMIC. */ ++ elttype = saved_type; ++ while (TYPE_CODE (elttype) == TYPE_CODE_TYPEDEF) ++ elttype = TYPE_TARGET_TYPE (elttype); ++ elttype = TYPE_TARGET_TYPE (elttype); ++ ++ eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type); + index_type = TYPE_INDEX_TYPE (type); + + if (get_array_bounds (type, &low_bound, &high_bound)) +@@ -1293,6 +1318,8 @@ val_print_array_elements (struct type *t + { + fprintf_filtered (stream, "..."); + } ++ ++ do_cleanups (back_to); + } + + /* Read LEN bytes of target memory at address MEMADDR, placing the +Index: gdb-7.3.50.20110722/gdb/value.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/value.c 2011-07-14 17:00:20.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/value.c 2011-07-29 22:52:02.000000000 +0200 +@@ -43,6 +43,7 @@ + #include "python/python.h" + #include + #include "tracepoint.h" ++#include "observer.h" + + /* Prototypes for exported functions. */ + +@@ -1354,12 +1355,15 @@ void + set_value_component_location (struct value *component, + const struct value *whole) + { ++ CORE_ADDR addr; ++ + if (whole->lval == lval_internalvar) + VALUE_LVAL (component) = lval_internalvar_component; + else + VALUE_LVAL (component) = whole->lval; + + component->location = whole->location; ++ + if (whole->lval == lval_computed) + { + const struct lval_funcs *funcs = whole->location.computed.funcs; +@@ -1367,6 +1371,12 @@ set_value_component_location (struct val + if (funcs->copy_closure) + component->location.computed.closure = funcs->copy_closure (whole); + } ++ ++ addr = value_raw_address (component); ++ object_address_get_data (value_type (whole), &addr); ++ if (component->lval != lval_internalvar ++ && component->lval != lval_internalvar_component) ++ set_value_address (component, addr); + } + + +@@ -1500,6 +1510,31 @@ show_values (char *num_exp, int from_tty + num_exp[1] = '\0'; + } + } ++ ++/* Sanity check for memory leaks and proper types reference counting. */ ++ ++static void ++value_history_cleanup (void *unused) ++{ ++ while (value_history_chain) ++ { ++ struct value_history_chunk *chunk = value_history_chain; ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE (chunk->values); i++) ++ value_free (chunk->values[i]); ++ ++ value_history_chain = chunk->next; ++ xfree (chunk); ++ } ++ value_history_count = 0; ++ ++ /* Free the unreferenced types above. */ ++ free_all_values (); ++#if 0 ++ free_all_types (); ++#endif ++} + + /* Internal variables. These are variables within the debugger + that hold values assigned by debugger commands. +@@ -1545,7 +1580,14 @@ struct internalvar + struct value *value; + + /* The call-back routine used with INTERNALVAR_MAKE_VALUE. */ +- internalvar_make_value make_value; ++ struct ++ { ++ /* The functions to call. */ ++ const struct internalvar_funcs *functions; ++ ++ /* The function's user-data. */ ++ void *data; ++ } make_value; + + /* The internal function used with INTERNALVAR_FUNCTION. */ + struct +@@ -1644,18 +1686,39 @@ create_internalvar (const char *name) + /* Create an internal variable with name NAME and register FUN as the + function that value_of_internalvar uses to create a value whenever + this variable is referenced. NAME should not normally include a +- dollar sign. */ ++ dollar sign. DATA is passed uninterpreted to FUN when it is ++ called. CLEANUP, if not NULL, is called when the internal variable ++ is destroyed. It is passed DATA as its only argument. */ + + struct internalvar * +-create_internalvar_type_lazy (char *name, internalvar_make_value fun) ++create_internalvar_type_lazy (const char *name, ++ const struct internalvar_funcs *funcs, ++ void *data) + { + struct internalvar *var = create_internalvar (name); + + var->kind = INTERNALVAR_MAKE_VALUE; +- var->u.make_value = fun; ++ var->u.make_value.functions = funcs; ++ var->u.make_value.data = data; + return var; + } + ++/* See documentation in value.h. */ ++ ++int ++compile_internalvar_to_ax (struct internalvar *var, ++ struct agent_expr *expr, ++ struct axs_value *value) ++{ ++ if (var->kind != INTERNALVAR_MAKE_VALUE ++ || var->u.make_value.functions->compile_to_ax == NULL) ++ return 0; ++ ++ var->u.make_value.functions->compile_to_ax (var, expr, value, ++ var->u.make_value.data); ++ return 1; ++} ++ + /* Look up an internal variable with name NAME. NAME should not + normally include a dollar sign. + +@@ -1728,7 +1791,8 @@ value_of_internalvar (struct gdbarch *gd + break; + + case INTERNALVAR_MAKE_VALUE: +- val = (*var->u.make_value) (gdbarch, var); ++ val = (*var->u.make_value.functions->make_value) (gdbarch, var, ++ var->u.make_value.data); + break; + + default: +@@ -1924,6 +1988,11 @@ clear_internalvar (struct internalvar *v + xfree (var->u.string); + break; + ++ case INTERNALVAR_MAKE_VALUE: ++ if (var->u.make_value.functions->destroy != NULL) ++ var->u.make_value.functions->destroy (var->u.make_value.data); ++ break; ++ + default: + break; + } +@@ -1978,6 +2047,38 @@ call_internal_function (struct gdbarch * + return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); + } + ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ ++ ++static void ++value_types_mark_used (void) ++{ ++ struct internalvar *var; ++ struct value_history_chunk *chunk; ++ ++ for (var = internalvars; var != NULL; var = var->next) ++ switch (var->kind) ++ { ++ case INTERNALVAR_VALUE: ++ type_mark_used (value_type (var->u.value)); ++ break; ++ ++ case INTERNALVAR_INTEGER: ++ type_mark_used (var->u.integer.type); ++ break; ++ } ++ ++ for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next) ++ { ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE (chunk->values); i++) ++ if (chunk->values[i]) ++ type_mark_used (value_type (chunk->values[i])); ++ } ++} ++#endif ++ + /* The 'function' command. This does nothing -- it is just a + placeholder to let "help function NAME" work. This is also used as + the implementation of the sub-command that is created when +@@ -2025,11 +2126,10 @@ preserve_one_value (struct value *value, + htab_t copied_types) + { + if (TYPE_OBJFILE (value->type) == objfile) +- value->type = copy_type_recursive (objfile, value->type, copied_types); ++ value->type = copy_type_recursive (value->type, copied_types); + + if (TYPE_OBJFILE (value->enclosing_type) == objfile) +- value->enclosing_type = copy_type_recursive (objfile, +- value->enclosing_type, ++ value->enclosing_type = copy_type_recursive (value->enclosing_type, + copied_types); + } + +@@ -2044,7 +2144,7 @@ preserve_one_internalvar (struct interna + case INTERNALVAR_INTEGER: + if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile) + var->u.integer.type +- = copy_type_recursive (objfile, var->u.integer.type, copied_types); ++ = copy_type_recursive (var->u.integer.type, copied_types); + break; + + case INTERNALVAR_VALUE: +@@ -2095,14 +2195,22 @@ show_convenience (char *ignore, int from + get_user_print_options (&opts); + for (var = internalvars; var; var = var->next) + { ++ volatile struct gdb_exception e; ++ + if (!varseen) + { + varseen = 1; + } + printf_filtered (("$%s = "), var->name); +- value_print (value_of_internalvar (gdbarch, var), gdb_stdout, +- &opts); +- printf_filtered (("\n")); ++ ++ TRY_CATCH (e, RETURN_MASK_ERROR) ++ { ++ value_print (value_of_internalvar (gdbarch, var), gdb_stdout, ++ &opts); ++ printf_filtered (("\n")); ++ } ++ if (e.reason < 0) ++ printf_filtered (_("\n"), e.message); + } + if (!varseen) + printf_unfiltered (_("No debugger convenience variables now defined.\n" +@@ -3075,7 +3183,24 @@ value_from_history_ref (char *h, char ** + struct value * + coerce_ref (struct value *arg) + { +- struct type *value_type_arg_tmp = check_typedef (value_type (arg)); ++ struct type *value_type_arg_tmp; ++ ++ if (TYPE_DYNAMIC (value_type (arg))) ++ { ++ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); ++ CORE_ADDR address; ++ ++ value_type_arg_tmp = value_type (arg); ++ address = value_raw_address (arg); ++ value_type_arg_tmp = object_address_get_data (value_type_arg_tmp, ++ &address); ++ if (! value_type_arg_tmp) ++ error (_("Attempt to coerce non-valid value.")); ++ arg = value_at_lazy (value_type_arg_tmp, address); ++ do_cleanups (cleanups); ++ } ++ else ++ value_type_arg_tmp = check_typedef (value_type (arg)); + + if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) + arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), +@@ -3173,4 +3298,10 @@ VARIABLE is already initialized.")); + add_prefix_cmd ("function", no_class, function_command, _("\ + Placeholder command for showing help on convenience functions."), + &functionlist, "function ", 0, &cmdlist); ++ ++ make_final_cleanup (value_history_cleanup, NULL); ++ ++#if 0 ++ observer_attach_mark_used (value_types_mark_used); ++#endif + } +Index: gdb-7.3.50.20110722/gdb/value.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/value.h 2011-07-14 17:00:20.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/value.h 2011-07-29 22:52:02.000000000 +0200 +@@ -475,6 +475,10 @@ extern struct value *value_from_decfloat + const gdb_byte *decbytes); + extern struct value *value_from_history_ref (char *, char **); + ++extern const char *object_address_data_not_valid (struct type *type); ++extern struct type *object_address_get_data (struct type *type, ++ CORE_ADDR *address_return); ++ + extern struct value *value_at (struct type *type, CORE_ADDR addr); + extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); + +@@ -700,10 +704,52 @@ extern struct internalvar *lookup_only_i + + extern struct internalvar *create_internalvar (const char *name); + +-typedef struct value * (*internalvar_make_value) (struct gdbarch *, +- struct internalvar *); ++/* An internalvar can be dynamically computed by supplying a vector of ++ function pointers to perform various operations. */ ++ ++struct internalvar_funcs ++{ ++ /* Compute the value of the variable. The DATA argument passed to ++ the function is the same argument that was passed to ++ `create_internalvar_type_lazy'. */ ++ ++ struct value *(*make_value) (struct gdbarch *arch, ++ struct internalvar *var, ++ void *data); ++ ++ /* Update the agent expression EXPR with bytecode to compute the ++ value. VALUE is the agent value we are updating. The DATA ++ argument passed to this function is the same argument that was ++ passed to `create_internalvar_type_lazy'. If this pointer is ++ NULL, then the internalvar cannot be compiled to an agent ++ expression. */ ++ ++ void (*compile_to_ax) (struct internalvar *var, ++ struct agent_expr *expr, ++ struct axs_value *value, ++ void *data); ++ ++ /* If non-NULL, this is called to destroy DATA. The DATA argument ++ passed to this function is the same argument that was passed to ++ `create_internalvar_type_lazy'. */ ++ ++ void (*destroy) (void *data); ++}; ++ + extern struct internalvar * +- create_internalvar_type_lazy (char *name, internalvar_make_value fun); ++create_internalvar_type_lazy (const char *name, ++ const struct internalvar_funcs *funcs, ++ void *data); ++ ++/* Compile an internal variable to an agent expression. VAR is the ++ variable to compile; EXPR and VALUE are the agent expression we are ++ updating. This will return 0 if there is no known way to compile ++ VAR, and 1 if VAR was successfully compiled. It may also throw an ++ exception on error. */ ++ ++extern int compile_internalvar_to_ax (struct internalvar *var, ++ struct agent_expr *expr, ++ struct axs_value *value); + + extern struct internalvar *lookup_internalvar (const char *name); + +Index: gdb-7.3.50.20110722/gdb/windows-tdep.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/windows-tdep.c 2011-07-14 17:00:20.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/windows-tdep.c 2011-07-29 22:52:02.000000000 +0200 +@@ -268,7 +268,7 @@ static const struct lval_funcs tlb_value + if there's no object available. */ + + static struct value * +-tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var) ++tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) + { + if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid)) + { +@@ -425,6 +425,15 @@ init_w32_command_list (void) + } + } + ++/* Implementation of `tlb' variable. */ ++ ++static const struct internalvar_funcs tlb_funcs = ++{ ++ tlb_make_value, ++ NULL, ++ NULL ++}; ++ + void + _initialize_windows_tdep (void) + { +@@ -451,5 +460,5 @@ even if their meaning is unknown."), + value with a void typed value, and when we get here, gdbarch + isn't initialized yet. At this point, we're quite sure there + isn't another convenience variable of the same name. */ +- create_internalvar_type_lazy ("_tlb", tlb_make_value); ++ create_internalvar_type_lazy ("_tlb", &tlb_funcs, NULL); + } +Index: gdb-7.3.50.20110722/gdb/xcoffread.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/xcoffread.c 2011-07-29 22:52:00.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/xcoffread.c 2011-07-29 22:52:02.000000000 +0200 +@@ -3125,6 +3125,7 @@ static const struct sym_fns xcoff_sym_fn + default_symfile_segments, /* Get segment information from a file. */ + aix_process_linenos, + default_symfile_relocate, /* Relocate a debug section. */ ++ NULL, /* sym_probe_fns */ + &psym_functions + }; + diff --git a/gdb/patches/gdb-bz533176-fortran-omp-step.patch b/gdb/patches/gdb-bz533176-fortran-omp-step.patch new file mode 100644 index 000000000..2cddac3ca --- /dev/null +++ b/gdb/patches/gdb-bz533176-fortran-omp-step.patch @@ -0,0 +1,121 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4 + +I find it a bug in DWARF and gdb behaves correctly according to it. From the +current DWARF's point of view the is a function call which you skip by "next". + +If you hide any /usr/lib/debug such as using: +gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44' +and use "step" command instead of "next" there it will work. +(You need to hide debuginfo from libgomp as you would step into libgomp sources +to maintain the threads for execution.) + +There should be some DWARF extension for it, currently tried to detect +substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not +consider such sub-function as a skippable by "next". + +Another problem is that with "set scheduler-locking" being "off" (default +upstream) or "step" (default in F/RHEL) the simultaneous execution of the +threads is inconvenient. Setting it to "on" will lockup the debugging as the +threads need to get synchronized at some point. This is a more general +debugging problem of GOMP outside of the scope of this Bug. + + + +Index: gdb-7.2.50.20101231/gdb/infrun.c +=================================================================== +--- gdb-7.2.50.20101231.orig/gdb/infrun.c 2011-01-01 01:02:45.000000000 +0100 ++++ gdb-7.2.50.20101231/gdb/infrun.c 2011-01-01 01:10:22.000000000 +0100 +@@ -4585,6 +4585,12 @@ infrun: not switching back to stepped th + + if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL) + { ++ struct symbol *stop_fn = find_pc_function (stop_pc); ++ ++ if (stop_fn == NULL ++ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL) ++{ /* ".omp_fn." */ ++ + /* We're doing a "next". + + Normal (forward) execution: set a breakpoint at the +@@ -4612,6 +4618,7 @@ infrun: not switching back to stepped th + + keep_going (ecs); + return; ++} /* ".omp_fn." */ + } + + /* If we are in a function call trampoline (a stub between the +Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp 2011-01-01 01:09:58.000000000 +0100 +@@ -0,0 +1,31 @@ ++# Copyright 2009 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 . ++ ++set testfile "omp-step" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } { ++ return -1 ++} ++ ++if ![runto [gdb_get_line_number "start-here"]] { ++ perror "Couldn't run to start-here" ++ return 0 ++} ++ ++gdb_test "next" {!\$omp parallel} "step closer" ++gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp" ++ ++gdb_breakpoint [gdb_get_line_number "success"] ++gdb_continue_to_breakpoint "success" ".*success.*" +Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90 2011-01-01 01:09:58.000000000 +0100 +@@ -0,0 +1,32 @@ ++! Copyright 2009 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 . ++ ++ use omp_lib ++ integer nthreads, i, a(1000) ++ nthreads = omp_get_num_threads() ++ if (nthreads .gt. 1000) call abort ++ ++ do i = 1, nthreads ++ a(i) = 0 ++ end do ++ print *, "start-here" ++!$omp parallel ++ a(omp_get_thread_num() + 1) = 1 ++!$omp end parallel ++ do i = 1, nthreads ++ if (a(i) .ne. 1) call abort ++ end do ++ print *, "success" ++ end diff --git a/gdb/patches/gdb-bz541866-rwatch-before-run.patch b/gdb/patches/gdb-bz541866-rwatch-before-run.patch new file mode 100644 index 000000000..a81d627bc --- /dev/null +++ b/gdb/patches/gdb-bz541866-rwatch-before-run.patch @@ -0,0 +1,151 @@ +Index: gdb-7.3.50.20110722/gdb/config/i386/linux64.mh +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/config/i386/linux64.mh 2011-07-22 01:46:10.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/config/i386/linux64.mh 2011-07-22 19:32:41.000000000 +0200 +@@ -3,7 +3,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \ + i386-nat.o amd64-nat.o amd64-linux-nat.o \ + linux-nat.o linux-osdata.o \ + proc-service.o linux-thread-db.o linux-fork.o +-NAT_FILE= config/nm-linux.h ++NAT_FILE= nm-linux64.h + NAT_CDEPS = $(srcdir)/proc-service.list + + # The dynamically loaded libthread_db needs access to symbols in the +Index: gdb-7.3.50.20110722/gdb/config/i386/linux.mh +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/config/i386/linux.mh 2011-07-22 01:46:10.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/config/i386/linux.mh 2011-07-22 19:32:21.000000000 +0200 +@@ -1,6 +1,6 @@ + # Host: Intel 386 running GNU/Linux. + +-NAT_FILE= config/nm-linux.h ++NAT_FILE= nm-linux.h + NATDEPFILES= inf-ptrace.o fork-child.o \ + i386-nat.o i386-linux-nat.o \ + proc-service.o linux-thread-db.o \ +Index: gdb-7.3.50.20110722/gdb/config/i386/nm-linux.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/config/i386/nm-linux.h 2011-07-22 19:32:21.000000000 +0200 +@@ -0,0 +1,28 @@ ++/* Native support for GNU/Linux i386. ++ ++ Copyright 2010 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 . */ ++ ++#ifndef NM_LINUX_H ++#define NM_LINUX_H ++ ++#include "config/nm-linux.h" ++ ++/* Red Hat backward compatibility with gdb-6.8. */ ++#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 ++ ++#endif /* NM_LINUX64_H */ +Index: gdb-7.3.50.20110722/gdb/config/i386/nm-linux64.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/config/i386/nm-linux64.h 2011-07-22 19:32:21.000000000 +0200 +@@ -0,0 +1,28 @@ ++/* Native support for GNU/Linux amd64. ++ ++ Copyright 2010 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 . */ ++ ++#ifndef NM_LINUX64_H ++#define NM_LINUX64_H ++ ++#include "config/nm-linux.h" ++ ++/* Red Hat backward compatibility with gdb-6.8. */ ++#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 ++ ++#endif /* NM_LINUX64_H */ +Index: gdb-7.3.50.20110722/gdb/target.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/target.h 2011-06-06 14:47:07.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/target.h 2011-07-22 19:32:21.000000000 +0200 +@@ -1349,8 +1349,10 @@ extern char *target_thread_name (struct + bp_hardware_breakpoint. CNT is the number of such watchpoints used so far + (including this one?). OTHERTYPE is who knows what... */ + ++#ifndef target_can_use_hardware_watchpoint + #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \ + (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE); ++#endif + + /* Returns the number of debug registers needed to watch the given + memory region, or zero if not supported. */ +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2011-07-22 19:32:21.000000000 +0200 +@@ -0,0 +1,40 @@ ++# Copyright 2009, 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 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 . ++ ++# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set. ++if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] ++ && ![istarget "ia64-*-*"]) ++ || [target_info exists gdb,no_hardware_watchpoints]} then { ++ verbose "Skipping watchpoint-hw-before-run test." ++ return ++} ++ ++set test watchpoint-hw-before-run ++set srcfile watchpoint-hw-hit-once.c ++if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } { ++ return -1 ++} ++ ++gdb_test "rwatch watchee" "ardware read watchpoint 1: watchee" ++ ++# `runto_main' or `runto main' would delete the watchpoint created above. ++ ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++gdb_test "" "main .* at .*" "start" ++ ++gdb_test "continue" "Continuing.\r\nHardware read watchpoint \[0-9\]+: watchee\r\n\r\nValue = 0\r\n.*" diff --git a/gdb/patches/gdb-bz562763-pretty-print-2d-vectors.patch b/gdb/patches/gdb-bz562763-pretty-print-2d-vectors.patch new file mode 100644 index 000000000..0e3d216c6 --- /dev/null +++ b/gdb/patches/gdb-bz562763-pretty-print-2d-vectors.patch @@ -0,0 +1,398 @@ +2010-05-31 Chris Moller + + * python/py-prettyprint.c (print_children): Add formatting for + matrices. (apply_val_pretty_printer): Detect and deal with matrix + hints. + + +2010-05-31 Chris Moller + + * gdb.python/Makefile.in (EXECUTABLES): Added pr10659. + * gdb.python/pr10659.cc: New file. + * gdb.python/pr10659.exp. New file. + * gdb.python/pr10659.py: New file. + +Index: gdb-7.2.50.20110218/gdb/valprint.h +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/valprint.h 2011-02-14 12:35:45.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/valprint.h 2011-02-18 10:44:32.000000000 +0100 +@@ -90,6 +90,9 @@ struct value_print_options + + /* If nonzero, print the value in "summary" form. */ + int summary; ++ ++ /* Affects pretty printing of matrices. */ ++ int prettyprint_matrix; + }; + + /* The global print options set by the user. In general this should +Index: gdb-7.2.50.20110218/gdb/python/py-prettyprint.c +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/python/py-prettyprint.c 2011-02-14 12:10:53.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/python/py-prettyprint.c 2011-02-18 10:45:02.000000000 +0100 +@@ -501,7 +501,7 @@ print_children (PyObject *printer, const + + /* Use the prettyprint_arrays option if we are printing an array, + and the pretty option otherwise. */ +- if (is_array) ++ if (is_array || options->prettyprint_matrix) + pretty = options->prettyprint_arrays; + else + { +@@ -521,6 +521,9 @@ print_children (PyObject *printer, const + goto done; + } + make_cleanup_py_decref (frame); ++ ++ if (options->prettyprint_matrix && recurse == 0) ++ fputs_filtered ("\n", stream); + + done_flag = 0; + for (i = 0; i < options->print_max; ++i) +@@ -555,12 +558,23 @@ print_children (PyObject *printer, const + 3. Other. Always print a ",". */ + if (i == 0) + { +- if (is_py_none) +- fputs_filtered ("{", stream); +- else +- fputs_filtered (" = {", stream); ++ if (options->prettyprint_matrix && recurse == 0) ++ print_spaces_filtered (2 + 2 * recurse, stream); ++ if (is_py_none) ++ { ++ if (options->prettyprint_matrix && strcmp (hint, "array")) ++ { ++ fputs_filtered ("{\n", stream); ++ print_spaces_filtered (4 + 2 * recurse, stream); ++ } ++ else ++ fputs_filtered ("{", stream); ++ } ++ else ++ fputs_filtered (" = {", stream); + } +- ++ else if (options->prettyprint_matrix) ++ print_spaces_filtered (4 + 2 * recurse, stream); + else if (! is_map || i % 2 == 0) + fputs_filtered (pretty ? "," : ", ", stream); + +@@ -589,6 +603,10 @@ print_children (PyObject *printer, const + + if (is_map && i % 2 == 0) + fputs_filtered ("[", stream); ++ else if (options->prettyprint_matrix) ++ { ++ /* Force a do-nothing. */ ++ } + else if (is_array) + { + /* We print the index, not whatever the child method +@@ -667,7 +685,12 @@ print_children (PyObject *printer, const + fputs_filtered ("\n", stream); + print_spaces_filtered (2 * recurse, stream); + } +- fputs_filtered ("}", stream); ++ if (options->prettyprint_matrix) ++ { ++ print_spaces_filtered (4 * recurse, stream); ++ fputs_filtered ("}\n", stream); ++ } ++ else fputs_filtered ("}", stream); + } + + done: +@@ -689,6 +712,7 @@ apply_val_pretty_printer (struct type *t + char *hint = NULL; + struct cleanup *cleanups; + int result = 0; ++ struct value_print_options *options_copy; + enum string_repr_result print_result; + + /* No pretty-printer support for unavailable values. */ +@@ -726,9 +750,21 @@ apply_val_pretty_printer (struct type *t + + /* If we are printing a map, we want some special formatting. */ + hint = gdbpy_get_display_hint (printer); ++ ++ if (recurse == 0) ++ { ++ options_copy = alloca (sizeof (struct value_print_options)); ++ memcpy (options_copy, options, sizeof (struct value_print_options)); ++ options_copy->prettyprint_matrix = hint && !strcmp (hint, "matrix"); ++ } ++ else options_copy = (struct value_print_options *)options; ++ + make_cleanup (free_current_contents, &hint); + + /* Print the section */ ++ if (options_copy->prettyprint_matrix) ++ print_result = string_repr_none; ++else /* Red Hat 2D matrix patch */ + print_result = print_string_repr (printer, hint, stream, recurse, + options, language, gdbarch); + if (print_result != string_repr_error) +Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.cc 2011-02-18 10:44:32.000000000 +0100 +@@ -0,0 +1,43 @@ ++#include ++#include // /usr/include/c++/4.4.1/bits/vector.tcc ++#include ++ ++using namespace std; ++ ++int use_windows = 9999; ++ ++int ++main(){ ++ vector test1(2,0); ++ test1[0]=8; ++ test1[1]=9; ++ ++ vector< vector > test2(3, vector(2,0)); ++ test2[0][0]=0; ++ test2[0][1]=1; ++ test2[1][0]=2; ++ test2[1][1]=3; ++ test2[2][0]=4; ++ test2[2][1]=5; ++ ++#define NR_ROWS 2 ++#define NR_COLS 3 ++#define NR_PLANES 4 ++ vector rows(NR_ROWS, 0); ++ vector< vector > columns(NR_COLS, rows); ++ vector< vector < vector > > test3(NR_PLANES, columns); ++ ++ cout << "rows.size() = " << rows.size() ++ << ", columns.size() = " << columns.size() ++ << ", test3.size() = " << test3.size() << "\n"; ++ ++ for (int i = 0; i < rows.size(); i++) { ++ for (int j = 0; j < columns.size(); j++) { ++ for (int k = 0; k < test3.size(); k++) { ++ test3[k][j][i] = k * 100 + j * 10 + i; ++ } ++ } ++ } ++ ++ return 0; // break ++} +Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.exp 2011-02-18 10:44:32.000000000 +0100 +@@ -0,0 +1,82 @@ ++#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 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 . ++ ++set nl "\[\r\n\]+" ++ ++set testfile pr10659 ++set srcfile ${testfile}.cc ++if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { ++ return -1 ++} ++ ++#if { [skip_python_tests] } { continue } ++ ++gdb_test "python execfile(\"$srcdir/$subdir/pr10659.py\")" "" ++gdb_test "python gdb.pretty_printers = \[lookup_function\]" "" ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "break"] ++gdb_continue_to_breakpoint "break" ++ ++gdb_test "p test1" "vector of length 2, capacity 2 =.*" ++ ++gdb_test "p test2" "= $nl {$nl {.*" ++ ++# Complete result is: ++# ++# (gdb) p test2 ++# $2 = ++# { ++# {0 1 } ++# {2 3 } ++# {4 5 } ++# } ++ ++ ++gdb_test "p test3" "= $nl {$nl {$nl {.*" ++ ++# Complete result is: ++# ++# (gdb) p test3 ++# $3 = ++# { ++# { ++# {0 1 } ++# {10 11 } ++# {20 21 } ++# } ++# { ++# {100 101 } ++# {110 111 } ++# {120 121 } ++# } ++# { ++# {200 201 } ++# {210 211 } ++# {220 221 } ++# } ++# { ++# {300 301 } ++# {310 311 } ++# {320 321 } ++# } ++# } ++# ++ ++ +Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.py 2011-02-18 10:44:32.000000000 +0100 +@@ -0,0 +1,109 @@ ++# Copyright (C) 2008, 2009 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 . ++ ++import gdb ++import itertools ++import re ++ ++vector_sig = 'std::vector' ++vector_regex = re.compile('^' + vector_sig + '<.*>$') ++ ++class FakeVectorPrinter: ++ "Print a std::vector" ++ ++ class _iterator: ++ def __init__ (self, start, finish): ++ self.item = start ++ self.finish = finish ++ self.count = 0 ++ ++ def __iter__(self): ++ return self ++ ++ def next(self): ++ if self.item == self.finish: ++ raise StopIteration ++ count = self.count ++ self.count = self.count + 1 ++ elt = self.item.dereference() ++ self.item = self.item + 1 ++ return ('[%d]' % count, elt) ++ ++ def __init__(self, typename, val): ++ self.typename = typename ++ self.val = val ++ ++ def children(self): ++ return self._iterator(self.val['_M_impl']['_M_start'], ++ self.val['_M_impl']['_M_finish']) ++ ++ def to_string(self): ++ start = self.val['_M_impl']['_M_start'] ++ finish = self.val['_M_impl']['_M_finish'] ++ end = self.val['_M_impl']['_M_end_of_storage'] ++ return ('std::vector of length %d, capacity %d' ++ % (int (finish - start), int (end - start))) ++ ++ def display_hint(self): ++ itype0 = self.val.type.template_argument(0) ++ itag = itype0.tag ++ if itag and re.match(vector_regex, itag): ++ rc = 'matrix' ++ else: ++ rc = 'array' ++ return rc ++ ++def register_libstdcxx_printers (obj): ++ "Register libstdc++ pretty-printers with objfile Obj." ++ ++ if obj == None: ++ obj = gdb ++ ++ obj.pretty_printers.append (lookup_function) ++ ++def lookup_function (val): ++ "Look-up and return a pretty-printer that can print val." ++ ++ # Get the type. ++ type = val.type; ++ ++ # If it points to a reference, get the reference. ++ if type.code == gdb.TYPE_CODE_REF: ++ type = type.target () ++ ++ # Get the unqualified type, stripped of typedefs. ++ type = type.unqualified ().strip_typedefs () ++ ++ # Get the type name. ++ typename = type.tag ++ if typename == None: ++ return None ++ ++ # Iterate over local dictionary of types to determine ++ # if a printer is registered for that type. Return an ++ # instantiation of the printer if found. ++ for function in fake_pretty_printers_dict: ++ if function.search (typename): ++ return fake_pretty_printers_dict[function] (val) ++ ++ # Cannot find a pretty printer. Return None. ++ return None ++ ++def build_libfakecxx_dictionary (): ++ fake_pretty_printers_dict[vector_regex] = lambda val: FakeVectorPrinter(vector_sig, val) ++ ++fake_pretty_printers_dict = {} ++ ++build_libfakecxx_dictionary () +Index: gdb-7.2.50.20110218/gdb/valprint.c +=================================================================== +--- gdb-7.2.50.20110218.orig/gdb/valprint.c 2011-02-18 10:44:16.000000000 +0100 ++++ gdb-7.2.50.20110218/gdb/valprint.c 2011-02-18 10:44:32.000000000 +0100 +@@ -85,7 +85,8 @@ struct value_print_options user_print_op + 1, /* static_field_print */ + 1, /* pascal_static_field_print */ + 0, /* raw */ +- 0 /* summary */ ++ 0, /* summary */ ++ 0 /* prettyprint_matrix */ + }; + + /* Initialize *OPTS to be a copy of the user print options. */ diff --git a/gdb/patches/gdb-bz568248-oom-is-error.patch b/gdb/patches/gdb-bz568248-oom-is-error.patch new file mode 100644 index 000000000..045d34eb9 --- /dev/null +++ b/gdb/patches/gdb-bz568248-oom-is-error.patch @@ -0,0 +1,68 @@ +http://sourceware.org/ml/gdb-patches/2010-06/msg00005.html +Subject: [rfc patch] nomem: internal_error -> error + +Hi, + +unfortunately I see this problem reproducible only with the +archer-jankratochvil-vla branch (VLA = Variable Length Arrays - char[var]). +OTOH this branch I hopefully submit in some form for FSF GDB later. + +In this case (a general problem but tested for example on Fedora 13 i686): + +int +main (int argc, char **argv) +{ + char a[argc]; + return a[0]; +} + +(gdb) start +(gdb) print a +../../gdb/utils.c:1251: internal-error: virtual memory exhausted: can't allocate 4294951689 bytes. + +It is apparently because boundary for the variable `a' is not initialized +there. Users notice it due to Eclipse-CDT trying to automatically display all +the local variables on each step. + + +Apparentl no regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. +But is anone aware of the reasons to use internal_error there? +I find simple error as a perfectly reasonable there. +(history only tracks it since the initial import) + +IIRC this idea has been discussed with Tom Tromey, not sure of its origin. + +I understand it may be offtopic for FSF GDB but from some GDB crashes I am not +sure if it can happen only due to the VLA variables. + + +Thanks, +Jan + + +gdb/ +2010-06-01 Jan Kratochvil + Tom Tromey + + * utils.c (nomem): Change internal_error to error. + +Index: gdb-7.3.50.20110722/gdb/utils.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/utils.c 2011-07-22 19:28:58.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/utils.c 2011-07-22 19:34:25.000000000 +0200 +@@ -1219,13 +1219,11 @@ malloc_failure (long size) + { + if (size > 0) + { +- internal_error (__FILE__, __LINE__, +- _("virtual memory exhausted: can't allocate %ld bytes."), +- size); ++ error (_("virtual memory exhausted: can't allocate %ld bytes."), size); + } + else + { +- internal_error (__FILE__, __LINE__, _("virtual memory exhausted.")); ++ error (_("virtual memory exhausted.")); + } + } + diff --git a/gdb/patches/gdb-bz592031-siginfo-lost-4of5.patch b/gdb/patches/gdb-bz592031-siginfo-lost-4of5.patch new file mode 100644 index 000000000..639b37d26 --- /dev/null +++ b/gdb/patches/gdb-bz592031-siginfo-lost-4of5.patch @@ -0,0 +1,992 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00360.html +Subject: [patch 3/4]#3 linux-nat: Do not respawn signals + +Hi, + +linux-nat.c is fixed to never respawn signals; possibly keeping SIGSTOP +pending, as is done in current in FSF gdbserver and as suggested by Pedro: + http://sourceware.org/ml/gdb-patches/2010-08/msg00544.html + +The last linux-nat.c removed patch chunk comes from the initial implementation +by Mark Kettenis: + [PATCH] New Linux threads support + http://sourceware.org/ml/gdb-patches/2000-09/msg00020.html + 92280a75e017683bf8e4f339f4f85640b0700509 +It gets in part reimplemented into the new stop_wait_callback step)> +part and partially just not needed as currently GDB never drops the signals as +it does not PTRACE_CONT the thread; signal is kept for processing: + "RC: Not resuming sibling %s (has pending)\n" + +In stop_wait_callback I believe breakpoints cancellation is not needed here, +it would be done later. + + +The testcase sigstep-threads.exp was written to catch a regression-like +appearance then the new step)> part of stop_wait_callback gets +removed. Still the tecase fails even with FSF HEAD: + +32 var++; /* step-1 */ +(gdb) step +Program received signal SIGUSR1, User defined signal 1. +Program received signal SIGUSR1, User defined signal 1. +31 { /* step-0 */ + +There is no reason why it shouldn't stop on line 33, between line 32 and line +33 no signal would occur. Stepping of the current thread should not be +affected by whatever happens in the other threads as select_event_lwp has: + /* Give preference to any LWP that is being single-stepped. */ + +There is a problem that with FSF HEAD GDB does PTRACE_SINGLESTEP for thread A, +PTRACE_CONT for thread B (because of set scheduler-locking off), thread B hits +SIGUSR1, so GDB tkills thread A with SIGSTOP and it can receive SIGSTOP for +thread A before the SIGTRAP for completed PTRACE_SINGLESTEP. At that moment +select_event_lwp. forgets it was stepping thread A because there is no pending +SIGTRAP event. currently_stepping still remembers thread A was stepping so it +will later stop but as thread A was PTRACE_CONT-ed in the meantime it is too +late. + +There is the new step)> part of stop_wait_callback to always track +thread A is stepping. Due to different scheduling without this part the +changed GDB would very rarely stop in this testcase otherwise, making it look +as a regression. + +I have some another patch I may post separately as if multiple signals happen +besides SIGTRAP GDB still may switch from thread A away (as not considering it +stepping) to thread B for SIGUSR and accidentally PTRACE_CONT thread A. +But I do not find this as a prerequisite for this patchset. + + + +Thanks, +Jan + + +gdb/ +2010-09-20 Jan Kratochvil + + * linux-nat.c (stop_wait_callback): New gdb_assert. Remove signals + respawning; keep TP with SIGNALLED. New debugging message "SWC: + Delayed SIGSTOP caught for %s.". Catch next signal if SIGSTOP has + been caught and LP->STEP is set. + (linux_nat_wait_1) signalled>: Remove. + +gdb/testsuite/ +2010-09-20 Jan Kratochvil + + * gdb.threads/siginfo-threads.exp: New file. + * gdb.threads/siginfo-threads.c: New file. + * gdb.threads/sigstep-threads.exp: New file. + * gdb.threads/sigstep-threads.c: New file. + +Index: gdb-7.2.50.20110117/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/linux-nat.c 2011-01-17 15:53:14.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/linux-nat.c 2011-01-17 16:05:57.000000000 +0100 +@@ -2803,6 +2803,8 @@ stop_wait_callback (struct lwp_info *lp, + { + int status; + ++ gdb_assert (lp->resumed); ++ + status = wait_lwp (lp); + if (status == 0) + return 0; +@@ -2828,110 +2830,61 @@ stop_wait_callback (struct lwp_info *lp, + + if (WSTOPSIG (status) != SIGSTOP) + { +- if (linux_nat_status_is_event (status)) +- { +- /* If a LWP other than the LWP that we're reporting an +- event for has hit a GDB breakpoint (as opposed to +- some random trap signal), then just arrange for it to +- hit it again later. We don't keep the SIGTRAP status +- and don't forward the SIGTRAP signal to the LWP. We +- will handle the current event, eventually we will +- resume all LWPs, and this one will get its breakpoint +- trap again. +- +- If we do not do this, then we run the risk that the +- user will delete or disable the breakpoint, but the +- thread will have already tripped on it. */ +- +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- +- save_sigtrap (lp); +- +- /* Now resume this LWP and get the SIGSTOP event. */ +- errno = 0; +- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "PTRACE_CONT %s, 0, 0 (%s)\n", +- target_pid_to_str (lp->ptid), +- errno ? safe_strerror (errno) : "OK"); +- +- fprintf_unfiltered (gdb_stdlog, +- "SWC: Candidate SIGTRAP event in %s\n", +- target_pid_to_str (lp->ptid)); +- } +- /* Hold this event/waitstatus while we check to see if +- there are any more (we still want to get that SIGSTOP). */ +- stop_wait_callback (lp, NULL); ++ /* The thread was stopped with a signal other than SIGSTOP. */ + +- /* Hold the SIGTRAP for handling by linux_nat_wait. If +- there's another event, throw it back into the +- queue. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "SWC: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str ((int) status)); +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); +- } ++ /* Save the trap's siginfo in case we need it later. */ ++ save_siginfo (lp); + +- /* Save the sigtrap event. */ +- lp->status = status; +- return 0; +- } +- else +- { +- /* The thread was stopped with a signal other than +- SIGSTOP, and didn't accidentally trip a breakpoint. */ ++ save_sigtrap (lp); + +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "SWC: Pending event %s in %s\n", +- status_to_str ((int) status), +- target_pid_to_str (lp->ptid)); +- } +- /* Now resume this LWP and get the SIGSTOP event. */ +- errno = 0; +- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "SWC: PTRACE_CONT %s, 0, 0 (%s)\n", +- target_pid_to_str (lp->ptid), +- errno ? safe_strerror (errno) : "OK"); +- +- /* Hold this event/waitstatus while we check to see if +- there are any more (we still want to get that SIGSTOP). */ +- stop_wait_callback (lp, NULL); ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: Pending event %s in %s\n", ++ status_to_str ((int) status), ++ target_pid_to_str (lp->ptid)); + +- /* If the lp->status field is still empty, use it to +- hold this event. If not, then this event must be +- returned to the event queue of the LWP. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "SWC: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str ((int) status)); +- } +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (status)); +- } +- else +- lp->status = status; +- return 0; +- } ++ /* Save the sigtrap event. */ ++ lp->status = status; ++ gdb_assert (! lp->stopped); ++ gdb_assert (lp->signalled); ++ lp->stopped = 1; + } + else + { + /* We caught the SIGSTOP that we intended to catch, so + there's no SIGSTOP pending. */ +- lp->stopped = 1; ++ ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: Delayed SIGSTOP caught for %s.\n", ++ target_pid_to_str (lp->ptid)); ++ ++ if (lp->step) ++ { ++ /* LP->STATUS is 0 here. That means SIGTRAP from ++ PTRACE_SINGLESTEP still has to be delivered for this inferior ++ stop. Catching the SIGTRAP event is important to prevent ++ starvation in select_event_lwp. */ ++ ++ registers_changed (); ++ linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), ++ 1, TARGET_SIGNAL_0); ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: %s %s, 0, 0 (discard SIGSTOP)\n", ++ "PTRACE_SINGLESTEP", ++ target_pid_to_str (lp->ptid)); ++ ++ lp->stopped = 0; ++ gdb_assert (lp->resumed); ++ stop_wait_callback (lp, NULL); ++ gdb_assert (lp->stopped); ++ } ++ else ++ lp->stopped = 1; ++ ++ /* Reset SIGNALLED only after the stop_wait_callback call above as ++ it does gdb_assert on SIGNALLED. */ + lp->signalled = 0; + } + } +@@ -3514,52 +3467,6 @@ retry: + lp = NULL; + } + +- if (lp && lp->signalled) +- { +- /* A pending SIGSTOP may interfere with the normal stream of +- events. In a typical case where interference is a problem, +- we have a SIGSTOP signal pending for LWP A while +- single-stepping it, encounter an event in LWP B, and take the +- pending SIGSTOP while trying to stop LWP A. After processing +- the event in LWP B, LWP A is continued, and we'll never see +- the SIGTRAP associated with the last time we were +- single-stepping LWP A. */ +- +- /* Resume the thread. It should halt immediately returning the +- pending SIGSTOP. */ +- registers_changed (); +- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), +- lp->step, TARGET_SIGNAL_0); +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "LLW: %s %s, 0, 0 (expect SIGSTOP)\n", +- lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", +- target_pid_to_str (lp->ptid)); +- lp->stopped = 0; +- gdb_assert (lp->resumed); +- +- /* Catch the pending SIGSTOP. */ +- status = lp->status; +- lp->status = 0; +- +- stop_wait_callback (lp, NULL); +- +- /* If the lp->status field isn't empty, we caught another signal +- while flushing the SIGSTOP. Return it back to the event +- queue of the LWP, as we already have an event to handle. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "LLW: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str (lp->status)); +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); +- } +- +- lp->status = status; +- } +- + if (!target_can_async_p ()) + { + /* Causes SIGINT to be passed on to the attached process. */ +Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.c 2011-01-17 16:02:40.000000000 +0100 +@@ -0,0 +1,447 @@ ++/* 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 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 . */ ++ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define gettid() syscall (__NR_gettid) ++#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, tgid, tid, sig) ++ ++/* Terminate always in the main task, it can lock up with SIGSTOPped GDB ++ otherwise. */ ++#define TIMEOUT (gettid () == getpid() ? 10 : 15) ++ ++static pid_t thread1_tid; ++static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER; ++static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++static int thread1_sigusr1_hit; ++static int thread1_sigusr2_hit; ++ ++static pid_t thread2_tid; ++static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER; ++static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++static int thread2_sigusr1_hit; ++static int thread2_sigusr2_hit; ++ ++static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ ++/* Do not use alarm as it would create a ptrace event which would hang up us if ++ we are being traced by GDB which we stopped ourselves. */ ++ ++static void timed_mutex_lock (pthread_mutex_t *mutex) ++{ ++ int i; ++ struct timespec start, now; ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &start); ++ assert (i == 0); ++ ++ do ++ { ++ i = pthread_mutex_trylock (mutex); ++ if (i == 0) ++ return; ++ assert (i == EBUSY); ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &now); ++ assert (i == 0); ++ assert (now.tv_sec >= start.tv_sec); ++ } ++ while (now.tv_sec - start.tv_sec < TIMEOUT); ++ ++ fprintf (stderr, "Timed out waiting for internal lock!\n"); ++ exit (EXIT_FAILURE); ++} ++ ++static void ++handler (int signo, siginfo_t *siginfo, void *exception) ++{ ++ int *varp; ++ ++ assert (siginfo->si_signo == signo); ++ assert (siginfo->si_code == SI_TKILL); ++ assert (siginfo->si_pid == getpid ()); ++ ++ if (gettid () == thread1_tid) ++ { ++ if (signo == SIGUSR1) ++ varp = &thread1_sigusr1_hit; ++ else if (signo == SIGUSR2) ++ varp = &thread1_sigusr2_hit; ++ else ++ assert (0); ++ } ++ else if (gettid () == thread2_tid) ++ { ++ if (signo == SIGUSR1) ++ varp = &thread2_sigusr1_hit; ++ else if (signo == SIGUSR2) ++ varp = &thread2_sigusr2_hit; ++ else ++ assert (0); ++ } ++ else ++ assert (0); ++ ++ if (*varp) ++ { ++ fprintf (stderr, "Signal %d for TID %lu has been already hit!\n", signo, ++ (unsigned long) gettid ()); ++ exit (EXIT_FAILURE); ++ } ++ *varp = 1; ++} ++ ++static void * ++thread1_func (void *unused) ++{ ++ int i; ++ ++ timed_mutex_lock (&thread1_tid_mutex); ++ ++ /* THREAD1_TID_MUTEX must be already locked to avoid race. */ ++ thread1_tid = gettid (); ++ ++ i = pthread_cond_signal (&thread1_tid_cond); ++ assert (i == 0); ++ i = pthread_mutex_unlock (&thread1_tid_mutex); ++ assert (i == 0); ++ ++ /* Be sure the "t (tracing stop)" test can proceed for both threads. */ ++ timed_mutex_lock (&terminate_mutex); ++ i = pthread_mutex_unlock (&terminate_mutex); ++ assert (i == 0); ++ ++ if (! thread1_sigusr1_hit) ++ { ++ fprintf (stderr, "Thread 1 signal SIGUSR1 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (! thread1_sigusr2_hit) ++ { ++ fprintf (stderr, "Thread 1 signal SIGUSR2 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ ++ return NULL; ++} ++ ++static void * ++thread2_func (void *unused) ++{ ++ int i; ++ ++ timed_mutex_lock (&thread2_tid_mutex); ++ ++ /* THREAD2_TID_MUTEX must be already locked to avoid race. */ ++ thread2_tid = gettid (); ++ ++ i = pthread_cond_signal (&thread2_tid_cond); ++ assert (i == 0); ++ i = pthread_mutex_unlock (&thread2_tid_mutex); ++ assert (i == 0); ++ ++ /* Be sure the "t (tracing stop)" test can proceed for both threads. */ ++ timed_mutex_lock (&terminate_mutex); ++ i = pthread_mutex_unlock (&terminate_mutex); ++ assert (i == 0); ++ ++ if (! thread2_sigusr1_hit) ++ { ++ fprintf (stderr, "Thread 2 signal SIGUSR1 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (! thread2_sigusr2_hit) ++ { ++ fprintf (stderr, "Thread 2 signal SIGUSR2 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ ++ return NULL; ++} ++ ++static const char * ++proc_string (const char *filename, const char *line) ++{ ++ FILE *f; ++ static char buf[LINE_MAX]; ++ size_t line_len = strlen (line); ++ ++ f = fopen (filename, "r"); ++ if (f == NULL) ++ { ++ fprintf (stderr, "fopen (\"%s\") for \"%s\": %s\n", filename, line, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ while (errno = 0, fgets (buf, sizeof (buf), f)) ++ { ++ char *s; ++ ++ s = strchr (buf, '\n'); ++ assert (s != NULL); ++ *s = 0; ++ ++ if (strncmp (buf, line, line_len) != 0) ++ continue; ++ ++ if (fclose (f)) ++ { ++ fprintf (stderr, "fclose (\"%s\") for \"%s\": %s\n", filename, line, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ ++ return &buf[line_len]; ++ } ++ if (errno != 0) ++ { ++ fprintf (stderr, "fgets (\"%s\": %s\n", filename, strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ fprintf (stderr, "\"%s\": No line \"%s\" found.\n", filename, line); ++ exit (EXIT_FAILURE); ++} ++ ++static unsigned long ++proc_ulong (const char *filename, const char *line) ++{ ++ const char *s = proc_string (filename, line); ++ long retval; ++ char *end; ++ ++ errno = 0; ++ retval = strtol (s, &end, 10); ++ if (retval < 0 || retval >= LONG_MAX || (end && *end)) ++ { ++ fprintf (stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ return retval; ++} ++ ++static void ++state_wait (pid_t process, const char *wanted) ++{ ++ char *filename; ++ int i; ++ struct timespec start, now; ++ const char *state; ++ ++ i = asprintf (&filename, "/proc/%lu/status", (unsigned long) process); ++ assert (i > 0); ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &start); ++ assert (i == 0); ++ ++ do ++ { ++ state = proc_string (filename, "State:\t"); ++ ++ /* torvalds/linux-2.6.git 464763cf1c6df632dccc8f2f4c7e50163154a2c0 ++ has changed "T (tracing stop)" to "t (tracing stop)". Make the GDB ++ testcase backward compatible with older Linux kernels. */ ++ if (strcmp (state, "T (tracing stop)") == 0) ++ state = "t (tracing stop)"; ++ ++ if (strcmp (state, wanted) == 0) ++ { ++ free (filename); ++ return; ++ } ++ ++ if (sched_yield ()) ++ { ++ perror ("sched_yield()"); ++ exit (EXIT_FAILURE); ++ } ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &now); ++ assert (i == 0); ++ assert (now.tv_sec >= start.tv_sec); ++ } ++ while (now.tv_sec - start.tv_sec < TIMEOUT); ++ ++ fprintf (stderr, "Timed out waiting for PID %lu \"%s\" (now it is \"%s\")!\n", ++ (unsigned long) process, wanted, state); ++ exit (EXIT_FAILURE); ++} ++ ++static volatile pid_t tracer = 0; ++static pthread_t thread1, thread2; ++ ++static void ++cleanup (void) ++{ ++ printf ("Resuming GDB PID %lu.\n", (unsigned long) tracer); ++ ++ if (tracer) ++ { ++ int i; ++ int tracer_save = tracer; ++ ++ tracer = 0; ++ ++ i = kill (tracer_save, SIGCONT); ++ assert (i == 0); ++ } ++} ++ ++int ++main (int argc, char **argv) ++{ ++ int i; ++ int standalone = 0; ++ struct sigaction act; ++ ++ if (argc == 2 && strcmp (argv[1], "-s") == 0) ++ standalone = 1; ++ else ++ assert (argc == 1); ++ ++ setbuf (stdout, NULL); ++ ++ timed_mutex_lock (&thread1_tid_mutex); ++ timed_mutex_lock (&thread2_tid_mutex); ++ ++ timed_mutex_lock (&terminate_mutex); ++ ++ errno = 0; ++ memset (&act, 0, sizeof (act)); ++ act.sa_sigaction = handler; ++ act.sa_flags = SA_RESTART | SA_SIGINFO; ++ i = sigemptyset (&act.sa_mask); ++ assert_perror (errno); ++ assert (i == 0); ++ i = sigaction (SIGUSR1, &act, NULL); ++ assert_perror (errno); ++ assert (i == 0); ++ i = sigaction (SIGUSR2, &act, NULL); ++ assert_perror (errno); ++ assert (i == 0); ++ ++ i = pthread_create (&thread1, NULL, thread1_func, NULL); ++ assert (i == 0); ++ ++ i = pthread_create (&thread2, NULL, thread2_func, NULL); ++ assert (i == 0); ++ ++ if (!standalone) ++ { ++ tracer = proc_ulong ("/proc/self/status", "TracerPid:\t"); ++ if (tracer == 0) ++ { ++ fprintf (stderr, "The testcase must be run by GDB!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (tracer != getppid ()) ++ { ++ fprintf (stderr, "The testcase parent must be our GDB tracer!\n"); ++ exit (EXIT_FAILURE); ++ } ++ } ++ ++ /* SIGCONT our debugger in the case of our crash as we would deadlock ++ otherwise. */ ++ ++ atexit (cleanup); ++ ++ printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer); ++ ++ if (tracer) ++ { ++ i = kill (tracer, SIGSTOP); ++ assert (i == 0); ++ state_wait (tracer, "T (stopped)"); ++ } ++ ++ /* Threads are now waiting at timed_mutex_lock (thread1_tid_mutex) and so ++ they could not trigger the signals before GDB gets unstopped later. ++ Threads get resumed at pthread_cond_wait below. Use `while' loops for ++ protection against spurious pthread_cond_wait wakeups. */ ++ ++ printf ("Waiting till the threads initialize their TIDs.\n"); ++ ++ while (thread1_tid == 0) ++ { ++ i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); ++ assert (i == 0); ++ } ++ ++ while (thread2_tid == 0) ++ { ++ i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); ++ assert (i == 0); ++ } ++ ++ printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n", ++ (unsigned long) thread1_tid, (unsigned long) thread2_tid, ++ (unsigned long) getpid ()); ++ ++ errno = 0; ++ i = tgkill (getpid (), thread1_tid, SIGUSR1); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread1_tid, SIGUSR2); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread2_tid, SIGUSR1); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread2_tid, SIGUSR2); ++ assert_perror (errno); ++ assert (i == 0); ++ ++ printf ("Waiting till the threads get trapped by the signals.\n"); ++ ++ if (tracer) ++ { ++ /* s390x-unknown-linux-gnu will fail with "R (running)". */ ++ ++ state_wait (thread1_tid, "t (tracing stop)"); ++ ++ state_wait (thread2_tid, "t (tracing stop)"); ++ } ++ ++ cleanup (); ++ ++ printf ("Joining the threads.\n"); ++ ++ i = pthread_mutex_unlock (&terminate_mutex); ++ assert (i == 0); ++ ++ i = pthread_join (thread1, NULL); ++ assert (i == 0); ++ ++ i = pthread_join (thread2, NULL); ++ assert (i == 0); ++ ++ printf ("Exiting.\n"); /* break-at-exit */ ++ ++ return EXIT_SUCCESS; ++} +Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.exp 2011-01-17 16:02:40.000000000 +0100 +@@ -0,0 +1,94 @@ ++# 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 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 . ++ ++set testfile "siginfo-threads" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list debug additional_flags=-lrt]] != "" } { ++ return -1 ++} ++ ++clean_restart $testfile ++ ++if ![runto_main] { ++ return -1 ++} ++ ++# `nostop noprint pass' could in some cases report false PASS due to the ++# (preempt 'handle') code path. ++ ++gdb_test "handle SIGUSR1 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++gdb_test "handle SIGUSR2 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR2\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++ ++gdb_breakpoint [gdb_get_line_number "break-at-exit"] ++ ++set test "get pid" ++gdb_test_multiple "p getpid ()" $test { ++ -re " = (\[0-9\]+)\r\n$gdb_prompt $" { ++ set pid $expect_out(1,string) ++ pass $test ++ } ++} ++ ++for {set sigcount 0} {$sigcount < 4} {incr sigcount} { ++ set test "catch signal $sigcount" ++ set sigusr "" ++ gdb_test_multiple "continue" $test { ++ -re "Program received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" { ++ set sigusr $expect_out(1,string) ++ pass $test ++ } ++ } ++ if {$sigusr == ""} { ++ return -1 ++ } ++ ++ set test "signal $sigcount si_signo" ++ if {$sigusr == 1} { ++ set signo 10 ++ } else { ++ set signo 12 ++ } ++ gdb_test_multiple {p $_siginfo.si_signo} $test { ++ -re " = $signo\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++ ++ set test "signal $sigcount si_code is SI_TKILL" ++ gdb_test_multiple {p $_siginfo.si_code} $test { ++ -re " = -6\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++ ++ set test "signal $sigcount si_pid" ++ gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test { ++ -re " = $pid\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++} ++ ++gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" +Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.c 2011-01-17 16:02:40.000000000 +0100 +@@ -0,0 +1,54 @@ ++/* 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 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 . */ ++ ++#include ++#include ++#include ++ ++#include ++#include ++#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, (tgid), (tid), (sig)) ++#define gettid() syscall (__NR_gettid) ++ ++static volatile int var; ++ ++static void ++handler (int signo) /* step-0 */ ++{ /* step-0 */ ++ var++; /* step-1 */ ++ tgkill (getpid (), gettid (), SIGUSR1); /* step-2 */ ++} ++ ++static void * ++start (void *arg) ++{ ++ signal (SIGUSR1, handler); ++ tgkill (getpid (), gettid (), SIGUSR1); ++ assert (0); ++ ++ return NULL; ++} ++ ++int ++main (void) ++{ ++ pthread_t thread; ++ ++ pthread_create (&thread, NULL, start, NULL); ++ start (NULL); /* main-start */ ++ return 0; ++} +Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.exp 2011-01-17 16:02:40.000000000 +0100 +@@ -0,0 +1,74 @@ ++# 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 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 . ++ ++set testfile sigstep-threads ++set srcfile ${testfile}.c ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++if ![runto_main] { ++ return -1; ++} ++ ++# `noprint' would not test the full logic of GDB. ++gdb_test "handle SIGUSR1 nostop print pass" "\r\nSIGUSR1\[ \t\]+No\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++ ++gdb_test_no_output "set scheduler-locking off" ++ ++gdb_breakpoint [gdb_get_line_number "step-1"] ++gdb_test_no_output {set $step1=$bpnum} ++gdb_continue_to_breakpoint "step-1" ".* step-1 .*" ++gdb_test_no_output {disable $step1} ++ ++# 1 as we are now stopped at the `step-1' label. ++set step_at 1 ++for {set i 0} {$i < 100} {incr i} { ++ set test "step $i" ++ # Presume this step failed - as in the case of a timeout. ++ set failed 1 ++ gdb_test_multiple "step" $test { ++ -re "\r\nProgram received signal SIGUSR1, User defined signal 1.\r\n" { ++ exp_continue -continue_timer ++ } ++ -re "step-(\[012\]).*\r\n$gdb_prompt $" { ++ set now $expect_out(1,string) ++ if {$step_at == 2 && $now == 1} { ++ set failed 0 ++ } elseif {$step_at == 1 && $now == 2} { ++ set failed 0 ++ # Continue over the re-signalling back to the handle entry. ++ gdb_test_no_output {enable $step1} "" ++ gdb_test "continue" " step-1 .*" "" ++ set now 1 ++ gdb_test_no_output {disable $step1} "" ++ } else { ++ fail $test ++ } ++ set step_at $now ++ } ++ } ++ if $failed { ++ return ++ } ++} ++# We can never reliably say the racy problematic case has been tested. ++pass "step" diff --git a/gdb/patches/gdb-bz592031-siginfo-lost-5of5.patch b/gdb/patches/gdb-bz592031-siginfo-lost-5of5.patch new file mode 100644 index 000000000..b8212bb3e --- /dev/null +++ b/gdb/patches/gdb-bz592031-siginfo-lost-5of5.patch @@ -0,0 +1,141 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00361.html +Subject: [patch 4/4]#3 Remove redundant lp->siginfo + +Hi, + +this is a simplification which should not affect GDB behavior. As linux-nat +now stops on each received signal without any reordering of them then +PTRACE_GETSIGINFO is enough to access siginfo, without any need to copy it in +advance. + + +Thanks, +Jan + + +gdb/ +2010-09-20 Jan Kratochvil + + * linux-nat.c (resume_callback) stopped && lp->status == 0> + (linux_nat_resume): Remove LP->SIGINFO clearing. + (save_siginfo): Remove. + (stop_wait_callback) + (linux_nat_filter_event) : Remove + the save_siginfo call. + (resume_stopped_resumed_lwps): Remove LP->SIGINFO clearing. + (linux_nat_set_siginfo_fixup): Use PTRACE_GETSIGINFO. + * linux-nat.h (struct lwp_info) : Remove. + +Index: gdb-7.2.50.20101116/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/linux-nat.c 2010-11-16 09:12:26.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/linux-nat.c 2010-11-16 09:13:21.000000000 +0100 +@@ -1850,7 +1850,6 @@ resume_callback (struct lwp_info *lp, vo + target_pid_to_str (lp->ptid)); + lp->stopped = 0; + lp->step = 0; +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + } + else if (lp->stopped && debug_linux_nat) +@@ -1993,7 +1992,6 @@ linux_nat_resume (struct target_ops *ops + ptid = pid_to_ptid (GET_LWP (lp->ptid)); + + linux_ops->to_resume (linux_ops, ptid, step, signo); +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + + if (debug_linux_nat) +@@ -2503,22 +2501,6 @@ wait_lwp (struct lwp_info *lp) + return status; + } + +-/* Save the most recent siginfo for LP. This is currently only called +- for SIGTRAP; some ports use the si_addr field for +- target_stopped_data_address. In the future, it may also be used to +- restore the siginfo of requeued signals. */ +- +-static void +-save_siginfo (struct lwp_info *lp) +-{ +- errno = 0; +- ptrace (PTRACE_GETSIGINFO, GET_LWP (lp->ptid), +- (PTRACE_TYPE_ARG3) 0, &lp->siginfo); +- +- if (errno != 0) +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); +-} +- + /* Send a SIGSTOP to LP. */ + + static int +@@ -2787,9 +2769,6 @@ stop_wait_callback (struct lwp_info *lp, + { + /* The thread was stopped with a signal other than SIGSTOP. */ + +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- + save_sigtrap (lp); + + if (debug_linux_nat) +@@ -3155,12 +3134,7 @@ linux_nat_filter_event (int lwpid, int s + } + + if (linux_nat_status_is_event (status)) +- { +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- +- save_sigtrap (lp); +- } ++ save_sigtrap (lp); + + /* Check if the thread has exited. */ + if ((WIFEXITED (status) || WIFSIGNALED (status)) +@@ -3763,7 +3737,6 @@ resume_stopped_resumed_lwps (struct lwp_ + linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), + lp->step, TARGET_SIGNAL_0); + lp->stopped = 0; +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + } + +@@ -5932,11 +5905,19 @@ linux_nat_set_siginfo_fixup (struct targ + struct siginfo * + linux_nat_get_siginfo (ptid_t ptid) + { +- struct lwp_info *lp = find_lwp_pid (ptid); ++ static struct siginfo siginfo; ++ int pid; + +- gdb_assert (lp != NULL); ++ pid = GET_LWP (ptid); ++ if (pid == 0) ++ pid = GET_PID (ptid); ++ ++ errno = 0; ++ ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo); ++ if (errno != 0) ++ memset (&siginfo, 0, sizeof (siginfo)); + +- return &lp->siginfo; ++ return &siginfo; + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.2.50.20101116/gdb/linux-nat.h +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/linux-nat.h 2010-11-16 07:54:36.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/linux-nat.h 2010-11-16 09:12:44.000000000 +0100 +@@ -58,10 +58,6 @@ struct lwp_info + /* The kind of stepping of this LWP. */ + enum resume_step step; + +- /* Non-zero si_signo if this LWP stopped with a trap. si_addr may +- be the address of a hardware watchpoint. */ +- struct siginfo siginfo; +- + /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data + watchpoint trap. */ + int stopped_by_watchpoint; diff --git a/gdb/patches/gdb-bz601887-dwarf4-rh-test.patch b/gdb/patches/gdb-bz601887-dwarf4-rh-test.patch new file mode 100644 index 000000000..4774bda55 --- /dev/null +++ b/gdb/patches/gdb-bz601887-dwarf4-rh-test.patch @@ -0,0 +1,240 @@ +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S 2010-06-09 15:22:57.000000000 +0200 +@@ -0,0 +1,167 @@ ++/* 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 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 . */ ++ ++ .file "rh-dwarf4-x86_64.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl main ++ .type main, @function ++main: ++.LFB0: ++ .file 1 "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:20 ++ .loc 1 20 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ movq %rsp, %rbp ++ .cfi_offset 6, -16 ++ .cfi_def_cfa_register 6 ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:21 ++ .loc 1 21 0 ++ movl $0, %eax ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:22 ++ .loc 1 22 0 ++ leave ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE0: ++ .size main, .-main ++.Letext0: ++ .section .debug_info ++ .long 0x4e # Length of Compilation Unit Info ++ .value 0x4 # DWARF version number ++ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section ++ .byte 0x8 # Pointer Size (in bytes) ++ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) ++ .long .LASF0 # DW_AT_producer: "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .byte 0x1 # DW_AT_language ++ .long .LASF1 # DW_AT_name: "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ .long .LASF2 # DW_AT_comp_dir ++ .quad .Ltext0 # DW_AT_low_pc ++ .quad .Letext0 # DW_AT_high_pc ++ .long .Ldebug_line0 # DW_AT_stmt_list ++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) ++ # DW_AT_external ++ .long .LASF3 # DW_AT_name: "main" ++ .byte 0x1 # DW_AT_decl_file (gdb.dwarf2/rh-dwarf4-x86_64.c) ++ .byte 0x13 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .long 0x4a # DW_AT_type ++ .quad .LFB0 # DW_AT_low_pc ++ .quad .LFE0 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_base_type) ++ .byte 0x4 # DW_AT_byte_size ++ .byte 0x5 # DW_AT_encoding ++ .ascii "int\0" # DW_AT_name ++ .byte 0x0 # end of children of DIE 0xb ++ .section .debug_abbrev ++ .uleb128 0x1 # (abbrev code) ++ .uleb128 0x11 # (TAG: DW_TAG_compile_unit) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x25 # (DW_AT_producer) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x13 # (DW_AT_language) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x1b # (DW_AT_comp_dir) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x10 # (DW_AT_stmt_list) ++ .uleb128 0x17 # (DW_FORM_sec_offset) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0x0 # DW_children_no ++ .uleb128 0x3f # (DW_AT_external) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0x0 # DW_children_no ++ .uleb128 0xb # (DW_AT_byte_size) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3e # (DW_AT_encoding) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x17 # Length of Public Names Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .long 0x52 # Compilation Unit Length ++ .long 0x2d # DIE offset ++ .ascii "main\0" # external name ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c # Length of Address Ranges Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .byte 0x8 # Size of Address ++ .byte 0x0 # Size of Segment Descriptor ++ .value 0x0 # Pad to 16 byte boundary ++ .value 0x0 ++ .quad .Ltext0 # Address ++ .quad .Letext0-.Ltext0 # Length ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF2: ++ .string "." ++.LASF0: ++ .string "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++.LASF1: ++ .string "gdb.dwarf2/rh-dwarf4-x86_64.c" ++.LASF3: ++ .string "main" ++ .ident "GCC: (GNU) 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .section .note.GNU-stack,"",@progbits +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c 2010-06-09 15:21:35.000000000 +0200 +@@ -0,0 +1,22 @@ ++/* 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 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 . */ ++ ++int ++main (void) ++{ ++ return 0; ++} +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp 2010-06-09 15:26:21.000000000 +0200 +@@ -0,0 +1,42 @@ ++# 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 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++if {![istarget x86_64-*]} { ++ return 0 ++} ++ ++set testfile "rh-dwarf4-x86_64" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test "ptype main" {type = int \(void\)} diff --git a/gdb/patches/gdb-bz623749-gcore-relro.patch b/gdb/patches/gdb-bz623749-gcore-relro.patch new file mode 100644 index 000000000..4015a7a6d --- /dev/null +++ b/gdb/patches/gdb-bz623749-gcore-relro.patch @@ -0,0 +1,169 @@ +gdb: +https://bugzilla.redhat.com/show_bug.cgi?id=623749 +kernel: +https://bugzilla.redhat.com/show_bug.cgi?id=636937 + +http://sourceware.org/ml/gdb-patches/2010-09/msg00395.html +Subject: Re: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804) + +gdb/testsuite/ +2010-09-22 Jan Kratochvil + + Fix gcore writer for -Wl,-z,relro. + * gdb.base/gcore-relro.exp: New file. + * gdb.base/gcore-relro-main.c: New file. + * gdb.base/gcore-relro-lib.c: New file. + +--- ./gdb/gcore.c 2010-09-23 20:14:56.000000000 +0200 ++++ ./gdb/gcore.c 2010-09-23 20:37:56.000000000 +0200 +@@ -401,6 +401,7 @@ gcore_create_callback (CORE_ADDR vaddr, + + if (write == 0 && !solib_keep_data_in_core (vaddr, size)) + { ++#if 0 /* https://bugzilla.redhat.com/show_bug.cgi?id=636937 */ + /* See if this region of memory lies inside a known file on disk. + If so, we can avoid copying its contents by clearing SEC_LOAD. */ + struct objfile *objfile; +@@ -433,6 +434,7 @@ gcore_create_callback (CORE_ADDR vaddr, + } + + keep: ++#endif + flags |= SEC_READONLY; + } + +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro-lib.c +@@ -0,0 +1,21 @@ ++/* Copyright 2010 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 . */ ++ ++void ++lib (void) ++{ ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro-main.c +@@ -0,0 +1,25 @@ ++/* Copyright 2010 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 . */ ++ ++extern void lib (void); ++ ++int ++main (void) ++{ ++ lib (); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro.exp +@@ -0,0 +1,80 @@ ++# 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 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 . ++ ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++set testfile "gcore-relro" ++set srcmainfile ${testfile}-main.c ++set srclibfile ${testfile}-lib.c ++set libfile ${objdir}/${subdir}/${testfile}-lib.so ++set objfile ${objdir}/${subdir}/${testfile}-main.o ++set executable ${testfile}-main ++set binfile ${objdir}/${subdir}/${executable} ++set gcorefile ${objdir}/${subdir}/${executable}.gcore ++ ++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug}] != "" ++ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++set opts [list debug shlib=${libfile} additional_flags=-Wl,-z,relro] ++if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { ++ unsupported "-Wl,-z,relro compilation failed" ++ return -1 ++} ++ ++clean_restart $executable ++gdb_load_shlibs $libfile ++ ++# Does this gdb support gcore? ++set test "help gcore" ++gdb_test_multiple $test $test { ++ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" { ++ # gcore command not supported -- nothing to test here. ++ unsupported "gdb does not support gcore on this target" ++ return -1; ++ } ++ -re "Save a core file .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++if { ![runto lib] } then { ++ return -1 ++} ++ ++set escapedfilename [string_to_regexp ${gcorefile}] ++ ++set test "save a corefile" ++gdb_test_multiple "gcore ${gcorefile}" $test { ++ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Can't create a corefile\r\n$gdb_prompt $" { ++ unsupported $test ++ return -1 ++ } ++} ++ ++# Now restart gdb and load the corefile. ++ ++clean_restart $executable ++gdb_load_shlibs $libfile ++ ++gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile" ++ ++gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" diff --git a/gdb/patches/gdb-bz634108-solib_address.patch b/gdb/patches/gdb-bz634108-solib_address.patch new file mode 100644 index 000000000..a44264881 --- /dev/null +++ b/gdb/patches/gdb-bz634108-solib_address.patch @@ -0,0 +1,29 @@ +Fix gdb.solib_address (fix by Phil Muldoon). + +--- /dev/null ++++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp +@@ -0,0 +1,24 @@ ++# Copyright (C) 2008, 2009, 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 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 . ++ ++# https://bugzilla.redhat.com/show_bug.cgi?id=634108 ++ ++gdb_exit ++gdb_start ++ ++# Skip all tests if Python scripting is not enabled. ++if { [skip_python_tests] } { continue } ++ ++gdb_test "python print gdb.solib_address(-1)" "None" "gdb.solib_address exists" diff --git a/gdb/patches/gdb-ccache-workaround.patch b/gdb/patches/gdb-ccache-workaround.patch new file mode 100644 index 000000000..86147bf3d --- /dev/null +++ b/gdb/patches/gdb-ccache-workaround.patch @@ -0,0 +1,17 @@ +--- a/gdb/testsuite/gdb.base/macscp.exp ++++ b/gdb/testsuite/gdb.base/macscp.exp +@@ -33,6 +33,14 @@ if [test_compiler_info gcc*] { + lappend options additional_flags=-g3 + } + ++# Workaround ccache making lineno non-zero for command-line definitions. ++if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} { ++ set result [catch "exec which gcc" output] ++ if {$result == 0 && [string first "/ccache/" $output] >= -1} { ++ lappend options "compiler=/usr/bin/gcc" ++ } ++} ++ + # Generate the intermediate object file. This is required by Darwin to + # have access to the .debug_macinfo section. + if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ diff --git a/gdb/patches/gdb-core-open-vdso-warning.patch b/gdb/patches/gdb-core-open-vdso-warning.patch new file mode 100644 index 000000000..87ccc0b42 --- /dev/null +++ b/gdb/patches/gdb-core-open-vdso-warning.patch @@ -0,0 +1,85 @@ +http://sourceware.org/ml/gdb-patches/2009-10/msg00142.html +Subject: [patch] Fix GNU/Linux core open: Can't read pathname for load map: Input/output error. + +Hi, + +GDB currently always prints on loading a core file: + warning: Can't read pathname for load map: Input/output error. + +The patch is not nice but it was WONTFIXed on the glibc side in: + http://sourceware.org/ml/libc-alpha/2009-10/msg00001.html + +The same message in GDB PR 8882 and glibc PR 387 was for ld-linux.so.2 l_name +but that one is now ignored thanks to IGNORE_FIRST_LINK_MAP_ENTRY. + +This fix is intended for Linux system vDSO l_name which is a second entry in +the DSO list. + +Regression tested on {x86_86,x86_64-m32,i686}-fedora11-linux-gnu. + + +Thanks, +Jan + + +gdb/ +2009-10-06 Jan Kratochvil + + Do not print false warning on reading core file with vDSO on GNU/Linux. + * solib-svr4.c (svr4_current_sos): Suppress the warning if + MASTER_SO_LIST is still NULL. + * solib.c (update_solib_list): New variable saved_so_list_head. + Conditionally restart the function. + +[ Context backport. ] + +Index: gdb-7.3.50.20110722/gdb/solib-svr4.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/solib-svr4.c 2011-07-22 19:26:46.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/solib-svr4.c 2011-07-22 19:29:36.000000000 +0200 +@@ -1197,8 +1197,18 @@ svr4_current_sos (void) + target_read_string (lm_name (new), &buffer, + SO_NAME_MAX_PATH_SIZE - 1, &errcode); + if (errcode != 0) +- warning (_("Can't read pathname for load map: %s."), +- safe_strerror (errcode)); ++ { ++ /* During the first ever DSO list reading some strings may be ++ unreadable as residing in the ld.so readonly memory not being ++ present in a dumped core file. Delay the error check after ++ the first pass of DSO list scanning when ld.so should be ++ already mapped in and all the DSO list l_name memory gets ++ readable. */ ++ ++ if (master_so_list () != NULL) ++ warning (_("Can't read pathname for load map: %s."), ++ safe_strerror (errcode)); ++ } + else + { + struct build_id *build_id; +Index: gdb-7.3.50.20110722/gdb/solib.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/solib.c 2011-06-30 21:29:54.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/solib.c 2011-07-22 19:29:10.000000000 +0200 +@@ -706,6 +706,7 @@ update_solib_list (int from_tty, struct + struct target_so_ops *ops = solib_ops (target_gdbarch); + struct so_list *inferior = ops->current_sos(); + struct so_list *gdb, **gdb_link; ++ struct so_list *saved_so_list_head = so_list_head; + + /* We can reach here due to changing solib-search-path or the + sysroot, before having any inferior. */ +@@ -846,6 +847,12 @@ update_solib_list (int from_tty, struct + observer_notify_solib_loaded (i); + } + ++ /* If this was the very first DSO list scan and we possibly read in ld.so ++ recheck all the formerly unreadable DSO names strings. */ ++ ++ if (saved_so_list_head == NULL && so_list_head != NULL) ++ return update_solib_list (from_tty, target); ++ + /* If a library was not found, issue an appropriate warning + message. We have to use a single call to warning in case the + front end does something special with warnings, e.g., pop up diff --git a/gdb/patches/gdb-dlopen-skip_inline_frames-perf.patch b/gdb/patches/gdb-dlopen-skip_inline_frames-perf.patch new file mode 100644 index 000000000..1141dd288 --- /dev/null +++ b/gdb/patches/gdb-dlopen-skip_inline_frames-perf.patch @@ -0,0 +1,90 @@ +diff --git a/gdb/infrun.c b/gdb/infrun.c +index 91e0fc2..1d7c808 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -3111,6 +3111,56 @@ fill_in_stop_func (struct gdbarch *gdbarch, + } + } + ++/* Argument for at_solib_event_breakpoint_helper. */ ++ ++struct solib_event_breakpoint_helper_arg ++{ ++ CORE_ADDR prev_pc; ++ int shlib_bp_count; ++ int other_bp_count; ++}; ++ ++/* Helper for at_solib_event_breakpoint. */ ++ ++static int ++at_solib_event_breakpoint_helper (struct breakpoint *b, void *argp) ++{ ++ struct solib_event_breakpoint_helper_arg *arg ++ = (struct solib_event_breakpoint_helper_arg *) argp; ++ struct bp_location *loc; ++ ++ for (loc = b->loc; loc; loc = loc->next) ++ { ++ if (loc->pspace == current_program_space ++ && (loc->address == stop_pc || loc->address == arg->prev_pc)) ++ { ++ if (b->type == bp_shlib_event) ++ arg->shlib_bp_count++; ++ else ++ { ++ arg->other_bp_count++; ++ return 1; /* quick exit */ ++ } ++ } ++ } ++ ++ return 0; /* carry on looking */ ++} ++ ++/* Nonzero if the location stopoed at is the shlib event breakpoint. */ ++ ++static int ++at_solib_event_breakpoint (struct execution_control_state *ecs) ++{ ++ struct solib_event_breakpoint_helper_arg arg; ++ arg.prev_pc = ecs->event_thread->prev_pc; ++ arg.shlib_bp_count = arg.other_bp_count = 0; ++ ++ iterate_over_breakpoints (at_solib_event_breakpoint_helper, &arg); ++ ++ return arg.shlib_bp_count && !arg.other_bp_count; ++} ++ + /* Given an execution control state that has been freshly filled in + by an event from the inferior, figure out what it means and take + appropriate action. */ +@@ -3964,11 +4014,23 @@ handle_inferior_event (struct execution_control_state *ecs) + ecs->random_signal = 0; + stopped_by_random_signal = 0; + +- /* Hide inlined functions starting here, unless we just performed stepi or +- nexti. After stepi and nexti, always show the innermost frame (not any +- inline function call sites). */ +- if (ecs->event_thread->control.step_range_end != 1) +- skip_inline_frames (ecs->ptid); ++ /* If we have stopped at the solib event breakpoint and ++ stop_on_solib_events is not set then we can avoid calling ++ anything that calls find_pc_section. This saves a lot ++ of time when the inferior loads a lot of shared libraries, ++ because otherwise the section map gets regenerated every ++ time we stop. */ ++ if (stop_on_solib_events ++ || ecs->event_thread->suspend.stop_signal != TARGET_SIGNAL_TRAP ++ || stop_after_trap ++ || !at_solib_event_breakpoint (ecs)) ++ { ++ /* Hide inlined functions starting here, unless we just ++ performed stepi or nexti. After stepi and nexti, always show ++ the innermost frame (not any inline function call sites). */ ++ if (ecs->event_thread->control.step_range_end != 1) ++ skip_inline_frames (ecs->ptid); ++ } + + if (ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP + && ecs->event_thread->control.trap_expected diff --git a/gdb/patches/gdb-dlopen-stap-probe-test.patch b/gdb/patches/gdb-dlopen-stap-probe-test.patch new file mode 100644 index 000000000..55a6a92eb --- /dev/null +++ b/gdb/patches/gdb-dlopen-stap-probe-test.patch @@ -0,0 +1,408 @@ +commit 5bfdc32cd3bf373c3b02e1fd864ed8ceab0292b2 +Author: Jan Kratochvil +Date: Mon Aug 8 12:08:53 2011 +0200 + + +testcase + +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2011-08-10 18:30:56.000000000 +0200 +@@ -0,0 +1,40 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++#include ++#include ++ ++static void * ++tfunc (void *arg) ++{ ++ void (*notifyp) (void) = arg; ++ ++ notifyp (); ++} ++ ++void ++f (void (*notifyp) (void)) ++{ ++ pthread_t t; ++ int i; ++ ++ i = pthread_create (&t, NULL, tfunc, notifyp); ++ assert (i == 0); ++ ++ i = pthread_join (t, NULL); ++ assert (i == 0); ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2011-08-10 18:30:56.000000000 +0200 +@@ -0,0 +1,46 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++#include ++#include ++#include ++ ++static const char *volatile filename; ++ ++static void ++notify (void) ++{ ++ filename = NULL; /* notify-here */ ++} ++ ++int ++main (void) ++{ ++ void *h; ++ void (*fp) (void (*) (void)); ++ ++ assert (filename != NULL); ++ h = dlopen (filename, RTLD_LAZY); ++ assert (h != NULL); ++ ++ fp = dlsym (h, "f"); ++ assert (fp != NULL); ++ ++ fp (notify); ++ ++ return 0; ++} +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2011-08-10 18:30:56.000000000 +0200 +@@ -0,0 +1,74 @@ ++# Copyright 2011 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 . ++ ++if {![istarget *-linux*] || [skip_shlib_tests]} { ++ return 0 ++} ++ ++load_lib prelink-support.exp ++ ++set testfile "dlopen-libpthread" ++set srcmainfile ${testfile}.c ++set srclibfile ${testfile}-lib.c ++set executable ${testfile} ++set binfile_lib ${objdir}/${subdir}/${executable}.so ++set binfile ${objdir}/${subdir}/${executable} ++set lib_dlopen [shlib_target_file ${executable}.so] ++ ++# Use build_executable_own_libs as prelinked libpthread.so can produce false ++# PASS - it is OK if GDB processes it still before relocation. ++ ++set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no] ++if {$relink_args == "" || ![prelink_no $relink_args] ++ || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug shlib_load}] } { ++ return -1 ++} ++gdb_load_shlibs $binfile_lib ++ ++if { ![runto_main] } { ++ return -1 ++} ++ ++set test "print _dl_debug_notify" ++gdb_test_multiple $test $test { ++ -re " 0x\[0-9a-f\]+ <_dl_debug_notify>\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "No symbol \"_dl_debug_notify\" in current context\\.\r\n$gdb_prompt $" { ++ xfail $test ++ untested ${testfile}.exp ++ return ++ } ++} ++ ++set test "libpthread.so not found" ++gdb_test_multiple "info sharedlibrary" $test { ++ -re "/libpthread\\.so.*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "/libc\\.so.*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++gdb_test "set variable filename=\"$lib_dlopen\"" ++ ++gdb_breakpoint "notify" ++ ++# The error was: ++# Cannot find new threads: generic error ++gdb_continue_to_breakpoint "notify" ".* notify-here .*" ++ ++gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found" +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:55.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:56.000000000 +0200 +@@ -3563,30 +3563,49 @@ proc build_executable { testname executa + set sources ${executable}.c + } + +- set binfile ${objdir}/${subdir}/${executable} +- +- set objects {} +- for {set i 0} "\$i<[llength $sources]" {incr i} { +- set s [lindex $sources $i] +- if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $options] != "" } { +- untested $testname +- return -1 +- } +- lappend objects "${binfile}${i}.o" ++ # get_compiler_info by gdb_compile_shlib and gdb_compile_shlib_pthreads. ++ set info_options "" ++ if { [lsearch -exact $options "c++"] >= 0 } { ++ set info_options "c++" + } +- +- if { [gdb_compile $objects "${binfile}" executable $options] != "" } { +- untested $testname ++ if [get_compiler_info binfile_unused ${info_options}] { + return -1 + } + +- set info_options "" +- if { [lsearch -exact $options "c++"] >= 0 } { +- set info_options "c++" ++ set binfile ${objdir}/${subdir}/${executable} ++ ++ set func gdb_compile ++ set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}] ++ if {$func_index != -1} { ++ set func "${func}_[lindex $options $func_index]" + } +- if [get_compiler_info ${binfile} ${info_options}] { ++ ++ # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd ++ # parameter. They also requires $sources while gdb_compile and ++ # gdb_compile_pthreads require $objects. ++ if [string match gdb_compile_shlib* $func] { ++ set sources_path {} ++ foreach s $sources { ++ lappend sources_path "${srcdir}/${subdir}/${s}" ++ } ++ set ret [$func $sources_path "${binfile}" $options] ++ } else { ++ set objects {} ++ for {set i 0} "\$i<[llength $sources]" {incr i} { ++ set s [lindex $sources $i] ++ if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $options] != "" } { ++ untested $testname ++ return -1 ++ } ++ lappend objects "${binfile}${i}.o" ++ } ++ set ret [$func $objects "${binfile}" executable $options] ++ } ++ if { $ret != "" } { ++ untested $testname + return -1 + } ++ + return 0 + } + +Index: gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/prelink-support.exp 2011-01-01 16:33:52.000000000 +0100 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp 2011-08-10 19:25:41.000000000 +0200 +@@ -95,8 +95,9 @@ proc file_copy {src dest} { + # Wrap function build_executable so that the resulting executable is fully + # self-sufficient (without dependencies on system libraries). Parameter + # INTERP may be used to specify a loader (ld.so) to be used that is +-# different from the default system one. Libraries on which the executable +-# depends are copied into directory DIR. Default DIR value to ++# different from the default system one. INTERP can be set to "no" if no ld.so ++# copy should be made. Libraries on which the executable depends are copied ++# into directory DIR. Default DIR value to + # `${objdir}/${subdir}/${EXECUTABLE}.d'. + # + # In case of success, return a string containing the arguments to be used +@@ -151,8 +152,15 @@ proc build_executable_own_libs {testname + + if {$interp == ""} { + set interp_system [section_get $binfile .interp] +- set interp ${dir}/[file tail $interp_system] +- file_copy $interp_system $interp ++ if {$interp_system == ""} { ++ fail "$test could not find .interp" ++ } else { ++ set interp ${dir}/[file tail $interp_system] ++ file_copy $interp_system $interp ++ } ++ } ++ if {$interp == "no"} { ++ set interp "" + } + + set dests {} +@@ -164,13 +172,19 @@ proc build_executable_own_libs {testname + + # Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s + # specified by the caller to be able to link it for ldd" above. +- set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"] ++ set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"] ++ if {$interp != ""} { ++ set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"] ++ } + + if {[build_executable $testname $executable $sources $options] == -1} { + return "" + } + +- set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]" ++ set prelink_args "--ld-library-path=$dir $binfile [concat $dests]" ++ if {$interp != ""} { ++ set prelink_args "--dynamic-linker=$interp $prelink_args $interp" ++ } + return $prelink_args + } + +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/break-interp.exp 2011-07-01 21:12:12.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp 2011-08-10 18:32:21.000000000 +0200 +@@ -108,14 +108,20 @@ proc strip_debug {dest} { + } + } + ++# Former symbol for solib changes notifications was _dl_debug_state, newer one ++# is _dl_debug_notify, the right one one traps by `set stop-on-solib-events 1'. ++ ++set solib_bp {(_dl_debug_state|_dl_debug_notify)} ++ + # Implementation of reach. + + proc reach_1 {func command displacement} { +- global gdb_prompt expect_out ++ global gdb_prompt expect_out solib_bp + +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + # Breakpoint on _dl_debug_state can have problems due to its overlap + # with the existing internal breakpoint from GDB. ++ # With also _dl_debug_notify we would need even two breakpoints. + gdb_test_no_output "set stop-on-solib-events 1" + } elseif {! [gdb_breakpoint $func allow-pending]} { + return +@@ -141,21 +147,21 @@ proc reach_1 {func command displacement} + exp_continue + } + -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + fail $test + } else { + pass $test + } + } + -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + fail $test + } else { + pass $test + } + } + -re "Stopped due to shared library event\r\n$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + if {$debug_state_count == 0} { + # First stop does not yet relocate the _start function + # descriptor on ppc64. +@@ -174,7 +180,7 @@ proc reach_1 {func command displacement} + fail $test_displacement + } + +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + gdb_test_no_output "set stop-on-solib-events 0" + } + } +@@ -373,7 +379,7 @@ proc test_attach {file displacement {rel + } + + proc test_ld {file ifmain trynosym displacement} { +- global srcdir subdir gdb_prompt expect_out inferior_exited_re ++ global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp + + # First test normal `file'-command loaded $FILE with symbols. + +@@ -401,9 +407,9 @@ proc test_ld {file ifmain trynosym displ + gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test" + } + +- reach "_dl_debug_state" "run" $displacement ++ reach $solib_bp "run" $displacement + +- gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt" ++ gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt" + + if $ifmain { + reach "main" continue "NONE" +@@ -415,7 +421,7 @@ proc test_ld {file ifmain trynosym displ + + # Try re-run if the new PIE displacement takes effect. + gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" +- reach "_dl_debug_state" "run" $displacement ++ reach $solib_bp "run" $displacement + + if $ifmain { + test_core $file $displacement +@@ -448,7 +454,7 @@ proc test_ld {file ifmain trynosym displ + gdb_test "exec-file $file" "exec-file $escapedfile" "load" + + if $ifmain { +- reach "_dl_debug_state" run $displacement ++ reach $solib_bp run $displacement + + # Use two separate gdb_test_multiple statements to avoid timeouts due + # to slow processing of wildcard capturing long output diff --git a/gdb/patches/gdb-dlopen-stap-probe.patch b/gdb/patches/gdb-dlopen-stap-probe.patch new file mode 100644 index 000000000..535229914 --- /dev/null +++ b/gdb/patches/gdb-dlopen-stap-probe.patch @@ -0,0 +1,358 @@ +From: Gary Benson +To: Jan Kratochvil +Message-ID: <20110810133605.GB7294@redhat.com> + +diff --git a/gdb/infrun.c b/gdb/infrun.c +index 4296d3a..fd5e9c3 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -321,6 +323,13 @@ static struct symbol *step_start_function; + /* Nonzero if we want to give control to the user when we're notified + of shared library events by the dynamic linker. */ + int stop_on_solib_events; ++ ++static void ++set_stop_on_solib_events (char *args, int from_tty, struct cmd_list_element *c) ++{ ++ update_solib_breakpoints (); ++} ++ + static void + show_stop_on_solib_events (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +@@ -7153,7 +7162,7 @@ Show stopping for shared library events."), _("\ + If nonzero, gdb will give control to the user when the dynamic linker\n\ + notifies gdb of shared library events. The most common event of interest\n\ + to the user would be loading/unloading of a new library."), +- NULL, ++ set_stop_on_solib_events, + show_stop_on_solib_events, + &setlist, &showlist); + +diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c +index dffc621..73cbe1c 100644 +--- a/gdb/solib-svr4.c ++++ b/gdb/solib-svr4.c +@@ -48,6 +48,8 @@ + #include "auxv.h" + #include "exceptions.h" + ++#include "stap-probe.h" ++ + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); + static int svr4_have_link_map_offsets (void); + static void svr4_relocate_main_executable (void); +@@ -92,6 +94,32 @@ static const char * const solib_break_names[] = + NULL + }; + ++/* A list of SystemTap probes which, if present in the dynamic linker, ++ allow more fine-grained breakpoints to be placed on shared library ++ events. */ ++ ++struct probe_info ++ { ++ /* The name of the probe. */ ++ const char *name; ++ ++ /* Nonzero if this probe must be stopped at even when ++ stop-on-solib-events is off. */ ++ int mandatory; ++ }; ++ ++static const struct probe_info probe_info[] = ++{ ++ {"rtld_init_start", 0}, ++ {"rtld_init_complete", 1}, ++ {"rtld_map_start", 0}, ++ {"rtld_reloc_complete", 1}, ++ {"rtld_unmap_start", 0}, ++ {"rtld_unmap_complete", 1}, ++}; ++ ++#define NUM_PROBES (sizeof(probe_info) / sizeof(probe_info[0])) ++ + static const char * const bkpt_names[] = + { + "_start", +@@ -335,6 +363,12 @@ struct svr4_info + CORE_ADDR interp_text_sect_high; + CORE_ADDR interp_plt_sect_low; + CORE_ADDR interp_plt_sect_high; ++ ++ /* SystemTap probes. */ ++ VEC (stap_probe_p) *probes[NUM_PROBES]; ++ ++ /* Nonzero if we are using the SystemTap interface. */ ++ int using_probes; + }; + + /* Per-program-space data key. */ +@@ -344,8 +378,15 @@ static void + svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) + { + struct svr4_info *info; ++ int i; + + info = program_space_data (pspace, solib_svr4_pspace_data); ++ if (info == NULL) ++ return; ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ VEC_free (stap_probe_p, info->probes[i]); ++ + xfree (info); + } + +@@ -1321,6 +1362,126 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ) + targ); + } + ++/* Helper function for svr4_update_solib_event_breakpoints. */ ++ ++static int ++svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ struct bp_location *loc; ++ ++ if (b->type != bp_shlib_event) ++ return 0; ++ ++ for (loc = b->loc; loc; loc = loc->next) ++ { ++ int i; ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ if (!probe_info[i].mandatory) ++ { ++ const struct stap_probe *probe; ++ int ix; ++ ++ for (ix = 0; ++ VEC_iterate (stap_probe_p, info->probes[i], ix, probe); ++ ++ix) ++ { ++ if (loc->pspace == current_program_space ++ && loc->address == probe->address) ++ { ++ b->enable_state = ++ stop_on_solib_events ? bp_enabled : bp_disabled; ++ return 0; ++ } ++ } ++ } ++ } ++ } ++ ++ return 0; ++} ++ ++/* Enable or disable optional solib event breakpoints as appropriate. ++ Called whenever stop_on_solib_events is changed. */ ++ ++static void ++svr4_update_solib_event_breakpoints (void) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ ++ if (info->using_probes) ++ iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL); ++} ++ ++/* Both the SunOS and the SVR4 dynamic linkers call a marker function ++ before and after mapping and unmapping shared libraries. The sole ++ purpose of this method is to allow debuggers to set a breakpoint so ++ they can track these changes. ++ ++ Some versions of the glibc dynamic linker contain SystemTap probes ++ to allow more fine grained stopping. Given the address of the ++ original marker function, this function attempts to find these ++ probes, and if found, sets breakpoints on those instead. If the ++ probes aren't found, a single breakpoint is set on the original ++ SVR4 marker function. */ ++ ++static void ++svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, CORE_ADDR address) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ struct obj_section *os; ++ ++ os = find_pc_section (address); ++ if (os != NULL) ++ { ++ int all_probes_found = 1; ++ int i; ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ info->probes[i] = find_probes_in_objfile (os->objfile, "rtld", ++ probe_info[i].name); ++ ++ if (!VEC_length(stap_probe_p, info->probes[i])) ++ { ++ int j; ++ ++ for (j = i - 1; j >= 0; j--) ++ { ++ VEC_free (stap_probe_p, info->probes[j]); ++ info->probes[j] = NULL; ++ } ++ ++ all_probes_found = 0; ++ break; ++ } ++ } ++ ++ if (all_probes_found) ++ { ++ info->using_probes = 1; ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ const struct stap_probe *probe; ++ int ix; ++ ++ for (ix = 0; ++ VEC_iterate (stap_probe_p, info->probes[i], ix, probe); ++ ++ix) ++ create_solib_event_breakpoint (gdbarch, probe->address); ++ } ++ ++ svr4_update_solib_event_breakpoints (); ++ return; ++ } ++ } ++ ++ create_solib_event_breakpoint (gdbarch, address); ++} ++ + /* + + LOCAL FUNCTION +@@ -1372,10 +1533,18 @@ enable_break (struct svr4_info *info, int from_tty) + asection *interp_sect; + gdb_byte *interp_name; + CORE_ADDR sym_addr; ++ int i; + + info->interp_text_sect_low = info->interp_text_sect_high = 0; + info->interp_plt_sect_low = info->interp_plt_sect_high = 0; + ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ VEC_free (stap_probe_p, info->probes[i]); ++ info->probes[i] = NULL; ++ } ++ info->using_probes = 0; ++ + /* If we already have a shared library list in the target, and + r_debug contains r_brk, set the breakpoint there - this should + mean r_brk has already been relocated. Assume the dynamic linker +@@ -1407,7 +1576,7 @@ enable_break (struct svr4_info *info, int from_tty) + That knowledge is encoded in the address, if it's Thumb the low bit + is 1. However, we've stripped that info above and it's not clear + what all the consequences are of passing a non-addr_bits_remove'd +- address to create_solib_event_breakpoint. The call to ++ address to svr4_create_solib_event_breakpoints. The call to + find_pc_section verifies we know about the address and have some + hope of computing the right kind of breakpoint to use (via + symbol info). It does mean that GDB needs to be pointed at a +@@ -1445,7 +1614,7 @@ enable_break (struct svr4_info *info, int from_tty) + + bfd_section_size (tmp_bfd, interp_sect); + } + +- create_solib_event_breakpoint (target_gdbarch, sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch, sym_addr); + return 1; + } + } +@@ -1599,7 +1768,8 @@ enable_break (struct svr4_info *info, int from_tty) + + if (sym_addr != 0) + { +- create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch, ++ load_addr + sym_addr); + xfree (interp_name); + return 1; + } +@@ -1625,7 +1795,7 @@ enable_break (struct svr4_info *info, int from_tty) + sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, + sym_addr, + ¤t_target); +- create_solib_event_breakpoint (target_gdbarch, sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch, sym_addr); + return 1; + } + } +@@ -1641,7 +1811,7 @@ enable_break (struct svr4_info *info, int from_tty) + sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, + sym_addr, + ¤t_target); +- create_solib_event_breakpoint (target_gdbarch, sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch, sym_addr); + return 1; + } + } +@@ -2470,4 +2640,5 @@ _initialize_svr4_solib (void) + svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; + svr4_so_ops.same = svr4_same; + svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core; ++ svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints; + } +diff --git a/gdb/solib.c b/gdb/solib.c +index 3296ed4..7ba70ce 100644 +--- a/gdb/solib.c ++++ b/gdb/solib.c +@@ -1313,6 +1313,18 @@ no_shared_libraries (char *ignored, int from_tty) + objfile_purge_solibs (); + } + ++/* Enable or disable optional solib event breakpoints as appropriate. */ ++ ++void ++update_solib_breakpoints (void) ++{ ++ struct target_so_ops *ops = solib_ops (target_gdbarch); ++ ++ if (ops->update_breakpoints != NULL) ++ ops->update_breakpoints (); ++} ++ ++ + /* Reload shared libraries, but avoid reloading the same symbol file + we already have loaded. */ + +diff --git a/gdb/solib.h b/gdb/solib.h +index c473d85..7b3881c 100644 +--- a/gdb/solib.h ++++ b/gdb/solib.h +@@ -78,4 +78,8 @@ extern void set_solib_ops (struct gdbarch *gdbarch, + + extern int libpthread_name_p (const char *name); + ++/* Enable or disable optional solib event breakpoints as appropriate. */ ++ ++extern void update_solib_breakpoints (void); ++ + #endif /* SOLIB_H */ +diff --git a/gdb/solist.h b/gdb/solist.h +index dad11be..14ede10 100644 +--- a/gdb/solist.h ++++ b/gdb/solist.h +@@ -137,6 +137,13 @@ struct target_so_ops + core file (in particular, for readonly sections). */ + int (*keep_data_in_core) (CORE_ADDR vaddr, + unsigned long size); ++ ++ /* Enable or disable optional solib event breakpoints as ++ appropriate. This should be called whenever ++ stop_on_solib_events is changed. This pointer can be ++ NULL, in which case no enabling or disabling is necessary ++ for this target. */ ++ void (*update_breakpoints) (void); + }; + + /* Free the memory associated with a (so_list *). */ diff --git a/gdb/patches/gdb-follow-child-stale-parent.patch b/gdb/patches/gdb-follow-child-stale-parent.patch new file mode 100644 index 000000000..336790cba --- /dev/null +++ b/gdb/patches/gdb-follow-child-stale-parent.patch @@ -0,0 +1,27 @@ +Problem occurs with python and its get_current_arch () as it selects +selected_frame and current_frame while still inferior_ptid is valid for the +original parent. But since this place it is already attached and later +unwinders try to access it, breaking: + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +--- ./gdb/infrun.c 2009-12-21 20:26:30.000000000 +0100 ++++ ./gdb/infrun.c 2009-12-21 20:26:11.000000000 +0100 +@@ -375,6 +375,9 @@ follow_fork (void) + } + else + { ++ /* Possibly referenced PARENT is no longer valid. */ ++ reinit_frame_cache (); ++ + /* This pending follow fork event is now handled, one way + or another. The previous selected thread may be gone + from the lists by now, but if it is still around, need diff --git a/gdb/patches/gdb-fortran-common-reduce.patch b/gdb/patches/gdb-fortran-common-reduce.patch new file mode 100644 index 000000000..fe1199f20 --- /dev/null +++ b/gdb/patches/gdb-fortran-common-reduce.patch @@ -0,0 +1,507 @@ +Index: gdb-7.2.50.20110117/gdb/f-lang.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/f-lang.c 2011-01-07 20:36:16.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/f-lang.c 2011-01-17 15:56:07.000000000 +0100 +@@ -57,20 +57,6 @@ typedef struct saved_bf_symnum SAVED_BF, + /* Local functions */ + + extern void _initialize_f_language (void); +-#if 0 +-static void clear_function_list (void); +-static long get_bf_for_fcn (long); +-static void clear_bf_list (void); +-static void patch_all_commons_by_name (char *, CORE_ADDR, int); +-static SAVED_F77_COMMON_PTR find_first_common_named (char *); +-static void add_common_entry (struct symbol *); +-static void add_common_block (char *, CORE_ADDR, int, char *); +-static SAVED_FUNCTION *allocate_saved_function_node (void); +-static SAVED_BF_PTR allocate_saved_bf_node (void); +-static COMMON_ENTRY_PTR allocate_common_entry_node (void); +-static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void); +-static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int); +-#endif + + static void f_printchar (int c, struct type *type, struct ui_file * stream); + static void f_emit_char (int c, struct type *type, +@@ -461,185 +447,7 @@ _initialize_f_language (void) + add_language (&f_language_defn); + } + +-#if 0 +-static SAVED_BF_PTR +-allocate_saved_bf_node (void) +-{ +- SAVED_BF_PTR new; +- +- new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); +- return (new); +-} +- +-static SAVED_FUNCTION * +-allocate_saved_function_node (void) +-{ +- SAVED_FUNCTION *new; +- +- new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); +- return (new); +-} +- +-static SAVED_F77_COMMON_PTR +-allocate_saved_f77_common_node (void) +-{ +- SAVED_F77_COMMON_PTR new; +- +- new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); +- return (new); +-} +- +-static COMMON_ENTRY_PTR +-allocate_common_entry_node (void) +-{ +- COMMON_ENTRY_PTR new; +- +- new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); +- return (new); +-} +-#endif +- + SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ +-SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */ +-SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */ +- +-#if 0 +-static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) +- list */ +-static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ +-static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of +- above list. */ +- +-static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use +- in macros. */ +- +-/* The following function simply enters a given common block onto +- the global common block chain. */ +- +-static void +-add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab) +-{ +- SAVED_F77_COMMON_PTR tmp; +- char *c, *local_copy_func_stab; +- +- /* If the COMMON block we are trying to add has a blank +- name (i.e. "#BLNK_COM") then we set it to __BLANK +- because the darn "#" character makes GDB's input +- parser have fits. */ +- +- +- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 +- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) +- { +- +- xfree (name); +- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); +- strcpy (name, BLANK_COMMON_NAME_LOCAL); +- } +- +- tmp = allocate_saved_f77_common_node (); +- +- local_copy_func_stab = xmalloc (strlen (func_stab) + 1); +- strcpy (local_copy_func_stab, func_stab); +- +- tmp->name = xmalloc (strlen (name) + 1); +- +- /* local_copy_func_stab is a stabstring, let us first extract the +- function name from the stab by NULLing out the ':' character. */ +- +- +- c = NULL; +- c = strchr (local_copy_func_stab, ':'); +- +- if (c) +- *c = '\0'; +- else +- error (_("Malformed function STAB found in add_common_block()")); +- +- +- tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1); +- +- strcpy (tmp->owning_function, local_copy_func_stab); +- +- strcpy (tmp->name, name); +- tmp->offset = offset; +- tmp->next = NULL; +- tmp->entries = NULL; +- tmp->secnum = secnum; +- +- current_common = tmp; +- +- if (head_common_list == NULL) +- { +- head_common_list = tail_common_list = tmp; +- } +- else +- { +- tail_common_list->next = tmp; +- tail_common_list = tmp; +- } +-} +-#endif +- +-/* The following function simply enters a given common entry onto +- the "current_common" block that has been saved away. */ +- +-#if 0 +-static void +-add_common_entry (struct symbol *entry_sym_ptr) +-{ +- COMMON_ENTRY_PTR tmp; +- +- +- +- /* The order of this list is important, since +- we expect the entries to appear in decl. +- order when we later issue "info common" calls. */ +- +- tmp = allocate_common_entry_node (); +- +- tmp->next = NULL; +- tmp->symbol = entry_sym_ptr; +- +- if (current_common == NULL) +- error (_("Attempt to add COMMON entry with no block open!")); +- else +- { +- if (current_common->entries == NULL) +- { +- current_common->entries = tmp; +- current_common->end_of_entries = tmp; +- } +- else +- { +- current_common->end_of_entries->next = tmp; +- current_common->end_of_entries = tmp; +- } +- } +-} +-#endif +- +-/* This routine finds the first encountred COMMON block named "name". */ +- +-#if 0 +-static SAVED_F77_COMMON_PTR +-find_first_common_named (char *name) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (strcmp (tmp->name, name) == 0) +- return (tmp); +- else +- tmp = tmp->next; +- } +- return (NULL); +-} +-#endif + + /* This routine finds the first encountred COMMON block named "name" + that belongs to function funcname. */ +@@ -662,193 +470,3 @@ find_common_for_function (char *name, ch + } + return (NULL); + } +- +- +-#if 0 +- +-/* The following function is called to patch up the offsets +- for the statics contained in the COMMON block named +- "name." */ +- +-static void +-patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum) +-{ +- COMMON_ENTRY_PTR entry; +- +- blk->offset = offset; /* Keep this around for future use. */ +- +- entry = blk->entries; +- +- while (entry != NULL) +- { +- SYMBOL_VALUE (entry->symbol) += offset; +- SYMBOL_SECTION (entry->symbol) = secnum; +- +- entry = entry->next; +- } +- blk->secnum = secnum; +-} +- +-/* Patch all commons named "name" that need patching.Since COMMON +- blocks occur with relative infrequency, we simply do a linear scan on +- the name. Eventually, the best way to do this will be a +- hashed-lookup. Secnum is the section number for the .bss section +- (which is where common data lives). */ +- +-static void +-patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- /* For blank common blocks, change the canonical reprsentation +- of a blank name */ +- +- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 +- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) +- { +- xfree (name); +- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); +- strcpy (name, BLANK_COMMON_NAME_LOCAL); +- } +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (COMMON_NEEDS_PATCHING (tmp)) +- if (strcmp (tmp->name, name) == 0) +- patch_common_entries (tmp, offset, secnum); +- +- tmp = tmp->next; +- } +-} +-#endif +- +-/* This macro adds the symbol-number for the start of the function +- (the symbol number of the .bf) referenced by symnum_fcn to a +- list. This list, in reality should be a FIFO queue but since +- #line pragmas sometimes cause line ranges to get messed up +- we simply create a linear list. This list can then be searched +- first by a queueing algorithm and upon failure fall back to +- a linear scan. */ +- +-#if 0 +-#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \ +- \ +- if (saved_bf_list == NULL) \ +-{ \ +- tmp_bf_ptr = allocate_saved_bf_node(); \ +- \ +- tmp_bf_ptr->symnum_bf = (bf_sym); \ +- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ +- tmp_bf_ptr->next = NULL; \ +- \ +- current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ +- saved_bf_list_end = tmp_bf_ptr; \ +- } \ +-else \ +-{ \ +- tmp_bf_ptr = allocate_saved_bf_node(); \ +- \ +- tmp_bf_ptr->symnum_bf = (bf_sym); \ +- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ +- tmp_bf_ptr->next = NULL; \ +- \ +- saved_bf_list_end->next = tmp_bf_ptr; \ +- saved_bf_list_end = tmp_bf_ptr; \ +- } +-#endif +- +-/* This function frees the entire (.bf,function) list. */ +- +-#if 0 +-static void +-clear_bf_list (void) +-{ +- +- SAVED_BF_PTR tmp = saved_bf_list; +- SAVED_BF_PTR next = NULL; +- +- while (tmp != NULL) +- { +- next = tmp->next; +- xfree (tmp); +- tmp = next; +- } +- saved_bf_list = NULL; +-} +-#endif +- +-int global_remote_debug; +- +-#if 0 +- +-static long +-get_bf_for_fcn (long the_function) +-{ +- SAVED_BF_PTR tmp; +- int nprobes = 0; +- +- /* First use a simple queuing algorithm (i.e. look and see if the +- item at the head of the queue is the one you want). */ +- +- if (saved_bf_list == NULL) +- internal_error (__FILE__, __LINE__, +- _("cannot get .bf node off empty list")); +- +- if (current_head_bf_list != NULL) +- if (current_head_bf_list->symnum_fcn == the_function) +- { +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "*"); +- +- tmp = current_head_bf_list; +- current_head_bf_list = current_head_bf_list->next; +- return (tmp->symnum_bf); +- } +- +- /* If the above did not work (probably because #line directives were +- used in the sourcefile and they messed up our internal tables) we now do +- the ugly linear scan. */ +- +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n"); +- +- nprobes = 0; +- tmp = saved_bf_list; +- while (tmp != NULL) +- { +- nprobes++; +- if (tmp->symnum_fcn == the_function) +- { +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes); +- current_head_bf_list = tmp->next; +- return (tmp->symnum_bf); +- } +- tmp = tmp->next; +- } +- +- return (-1); +-} +- +-static SAVED_FUNCTION_PTR saved_function_list = NULL; +-static SAVED_FUNCTION_PTR saved_function_list_end = NULL; +- +-static void +-clear_function_list (void) +-{ +- SAVED_FUNCTION_PTR tmp = saved_function_list; +- SAVED_FUNCTION_PTR next = NULL; +- +- while (tmp != NULL) +- { +- next = tmp->next; +- xfree (tmp); +- tmp = next; +- } +- +- saved_function_list = NULL; +-} +-#endif +Index: gdb-7.2.50.20110117/gdb/f-lang.h +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/f-lang.h 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/f-lang.h 2011-01-17 15:54:14.000000000 +0100 +@@ -76,14 +76,9 @@ typedef struct saved_f77_common SAVED_F7 + typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; + + extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ +-extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */ +-extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */ + + extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); + +-#define UNINITIALIZED_SECNUM -1 +-#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM) +- + #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ + #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ + #define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ +Index: gdb-7.2.50.20110117/gdb/f-valprint.c +=================================================================== +--- gdb-7.2.50.20110117.orig/gdb/f-valprint.c 2011-01-17 15:47:37.000000000 +0100 ++++ gdb-7.2.50.20110117/gdb/f-valprint.c 2011-01-17 15:54:36.000000000 +0100 +@@ -35,10 +35,6 @@ + #include "command.h" + #include "block.h" + +-#if 0 +-static int there_is_a_visible_common_named (char *); +-#endif +- + extern void _initialize_f_valprint (void); + static void info_common_command (char *, int); + static void list_all_visible_commons (char *); +@@ -604,67 +600,6 @@ info_common_command (char *comname, int + comname, funname); + } + +-/* This function is used to determine whether there is a +- F77 common block visible at the current scope called 'comname'. */ +- +-#if 0 +-static int +-there_is_a_visible_common_named (char *comname) +-{ +- SAVED_F77_COMMON_PTR the_common; +- struct frame_info *fi; +- char *funname = 0; +- struct symbol *func; +- +- if (comname == NULL) +- error (_("Cannot deal with NULL common name!")); +- +- fi = get_selected_frame (_("No frame selected")); +- +- /* The following is generally ripped off from stack.c's routine +- print_frame_info(). */ +- +- func = find_pc_function (fi->pc); +- if (func) +- { +- /* In certain pathological cases, the symtabs give the wrong +- function (when we are in the first function in a file which +- is compiled without debugging symbols, the previous function +- is compiled with debugging symbols, and the "foo.o" symbol +- that is supposed to tell us where the file with debugging symbols +- ends has been truncated by ar because it is longer than 15 +- characters). +- +- So look in the minimal symbol tables as well, and if it comes +- up with a larger address for the function use that instead. +- I don't think this can ever cause any problems; there shouldn't +- be any minimal symbols in the middle of a function. +- FIXME: (Not necessarily true. What about text labels?) */ +- +- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); +- +- if (msymbol != NULL +- && (SYMBOL_VALUE_ADDRESS (msymbol) +- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else +- funname = SYMBOL_LINKAGE_NAME (func); +- } +- else +- { +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (fi->pc); +- +- if (msymbol != NULL) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- } +- +- the_common = find_common_for_function (comname, funname); +- +- return (the_common ? 1 : 0); +-} +-#endif +- + void + _initialize_f_valprint (void) + { diff --git a/gdb/patches/gdb-fortran-common.patch b/gdb/patches/gdb-fortran-common.patch new file mode 100644 index 000000000..66d46b976 --- /dev/null +++ b/gdb/patches/gdb-fortran-common.patch @@ -0,0 +1,585 @@ +Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-22 20:12:05.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-22 20:17:22.000000000 +0200 +@@ -7969,12 +7969,14 @@ read_set_type (struct die_info *die, str + return set_die_type (die, set_type, cu); + } + +-/* First cut: install each common block member as a global variable. */ ++/* Create appropriate locally-scoped variables for all the DW_TAG_common_block ++ entries. Create also TYPE_CODE_STRUCT listing all such variables to be ++ available for `info common'. COMMON_BLOCK_DOMAIN is used to sepate the ++ common blocks name namespace from regular variable names. */ + + static void + read_common_block (struct die_info *die, struct dwarf2_cu *cu) + { +- struct die_info *child_die; + struct attribute *attr; + struct symbol *sym; + CORE_ADDR base = (CORE_ADDR) 0; +@@ -7999,20 +8001,67 @@ read_common_block (struct die_info *die, + } + if (die->child != NULL) + { ++ struct objfile *objfile = cu->objfile; ++ struct die_info *child_die; ++ struct type *type; ++ struct field *field; ++ char *name; ++ struct symbol *sym; ++ ++ type = alloc_type (objfile); ++ TYPE_CODE (type) = TYPE_CODE_STRUCT; ++ /* Artificial type to be used only by `info common'. */ ++ TYPE_NAME (type) = ""; ++ ++ child_die = die->child; ++ while (child_die && child_die->tag) ++ { ++ TYPE_NFIELDS (type)++; ++ child_die = sibling_die (child_die); ++ } ++ ++ TYPE_FIELDS (type) = obstack_alloc (&objfile->objfile_obstack, ++ sizeof (*TYPE_FIELDS (type)) ++ * TYPE_NFIELDS (type)); ++ memset (TYPE_FIELDS (type), 0, sizeof (*TYPE_FIELDS (type)) ++ * TYPE_NFIELDS (type)); ++ ++ field = TYPE_FIELDS (type); + child_die = die->child; + while (child_die && child_die->tag) + { + LONGEST offset; + ++ /* Create the symbol in the DW_TAG_common_block block in the current ++ symbol scope. */ + sym = new_symbol (child_die, NULL, cu); ++ ++ /* Undocumented in DWARF3, when it can be present? */ + if (sym != NULL + && handle_data_member_location (child_die, cu, &offset)) + { + SYMBOL_VALUE_ADDRESS (sym) = base + offset; + add_symbol_to_list (sym, &global_symbols); + } ++ ++ if (SYMBOL_CLASS (sym) == LOC_STATIC) ++ SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym)); ++ else ++ SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym)); ++ FIELD_TYPE (*field) = SYMBOL_TYPE (sym); ++ FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym); ++ field++; + child_die = sibling_die (child_die); + } ++ ++ /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even ++ with no consecutive address space. */ ++ ++ sym = new_symbol (die, type, cu); ++ /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */ ++ SYMBOL_VALUE_ADDRESS (sym) = base; ++ ++ set_die_type (die, type, cu); + } + } + +@@ -11695,6 +11744,13 @@ new_symbol_full (struct die_info *die, s + { + var_decode_location (attr, sym, cu); + attr2 = dwarf2_attr (die, DW_AT_external, cu); ++ ++ /* Fortran explicitly imports any global symbols to the local ++ scope by DW_TAG_common_block. */ ++ if (cu->language == language_fortran && die->parent ++ && die->parent->tag == DW_TAG_common_block) ++ attr2 = NULL; ++ + if (SYMBOL_CLASS (sym) == LOC_STATIC + && SYMBOL_VALUE_ADDRESS (sym) == 0 + && !dwarf2_per_objfile->has_section_at_zero) +@@ -11867,6 +11923,11 @@ new_symbol_full (struct die_info *die, s + SYMBOL_CLASS (sym) = LOC_TYPEDEF; + list_to_add = &global_symbols; + break; ++ case DW_TAG_common_block: ++ SYMBOL_CLASS (sym) = LOC_STATIC; ++ SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN; ++ add_symbol_to_list (sym, cu->list_in_scope); ++ break; + default: + /* Not a tag we recognize. Hopefully we aren't processing + trash data, but since we must specifically ignore things +Index: gdb-7.3.50.20110722/gdb/f-lang.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-lang.c 2011-07-22 20:17:16.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-lang.c 2011-07-22 20:17:22.000000000 +0200 +@@ -371,27 +371,3 @@ _initialize_f_language (void) + + add_language (&f_language_defn); + } +- +-SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ +- +-/* This routine finds the first encountred COMMON block named "name" +- that belongs to function funcname. */ +- +-SAVED_F77_COMMON_PTR +-find_common_for_function (char *name, char *funcname) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (strcmp (tmp->name, name) == 0 +- && strcmp (tmp->owning_function, funcname) == 0) +- return (tmp); +- else +- tmp = tmp->next; +- } +- return (NULL); +-} +Index: gdb-7.3.50.20110722/gdb/f-lang.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-lang.h 2011-07-22 20:17:16.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-lang.h 2011-07-22 20:17:22.000000000 +0200 +@@ -52,36 +52,8 @@ enum f90_range_type + NONE_BOUND_DEFAULT /* "(low:high)" */ + }; + +-struct common_entry +- { +- struct symbol *symbol; /* The symbol node corresponding +- to this component */ +- struct common_entry *next; /* The next component */ +- }; +- +-struct saved_f77_common +- { +- char *name; /* Name of COMMON */ +- char *owning_function; /* Name of parent function */ +- int secnum; /* Section # of .bss */ +- CORE_ADDR offset; /* Offset from .bss for +- this block */ +- struct common_entry *entries; /* List of block's components */ +- struct common_entry *end_of_entries; /* ptr. to end of components */ +- struct saved_f77_common *next; /* Next saved COMMON block */ +- }; +- +-typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR; +- +-typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; +- +-extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ +- +-extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); +- + #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ + #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ +-#define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ + + /* When reasonable array bounds cannot be fetched, such as when + you ask to 'mt print symbols' and there is no stack frame and +Index: gdb-7.3.50.20110722/gdb/f-valprint.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/f-valprint.c 2011-07-22 20:17:16.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/f-valprint.c 2011-07-22 20:18:26.000000000 +0200 +@@ -34,10 +34,11 @@ + #include "gdbcore.h" + #include "command.h" + #include "block.h" ++#include "dictionary.h" ++#include "gdb_assert.h" + + extern void _initialize_f_valprint (void); + static void info_common_command (char *, int); +-static void list_all_visible_commons (char *); + static void f77_create_arrayprint_offset_tbl (struct type *, + struct ui_file *); + static void f77_get_dynamic_length_of_aggregate (struct type *); +@@ -515,22 +516,54 @@ f_val_print (struct type *type, const gd + return 0; + } + +-static void +-list_all_visible_commons (char *funname) ++static int ++info_common_command_for_block (struct block *block, struct frame_info *frame, ++ const char *comname) + { +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; ++ struct dict_iterator iter; ++ struct symbol *sym; ++ int values_printed = 0; ++ const char *name; ++ struct value_print_options opts; ++ ++ get_user_print_options (&opts); ++ ++ ALL_BLOCK_SYMBOLS (block, iter, sym) ++ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) ++ { ++ struct type *type = SYMBOL_TYPE (sym); ++ int index; ++ ++ gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC); ++ gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT); ++ ++ if (comname && (!SYMBOL_LINKAGE_NAME (sym) ++ || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0)) ++ continue; ++ ++ values_printed = 1; ++ if (SYMBOL_PRINT_NAME (sym)) ++ printf_filtered (_("Contents of F77 COMMON block '%s':\n"), ++ SYMBOL_PRINT_NAME (sym)); ++ else ++ printf_filtered (_("Contents of blank COMMON block:\n")); ++ ++ for (index = 0; index < TYPE_NFIELDS (type); index++) ++ { ++ struct value *val; ++ ++ gdb_assert (field_is_static (&TYPE_FIELD (type, index))); ++ val = value_static_field (type, index); ++ ++ printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index)); ++ value_print (val, gdb_stdout, &opts); ++ putchar_filtered ('\n'); ++ } + +- printf_filtered (_("All COMMON blocks visible at this level:\n\n")); ++ putchar_filtered ('\n'); ++ } + +- while (tmp != NULL) +- { +- if (strcmp (tmp->owning_function, funname) == 0) +- printf_filtered ("%s\n", tmp->name); +- +- tmp = tmp->next; +- } ++ return values_printed; + } + + /* This function is used to print out the values in a given COMMON +@@ -540,11 +573,9 @@ list_all_visible_commons (char *funname) + static void + info_common_command (char *comname, int from_tty) + { +- SAVED_F77_COMMON_PTR the_common; +- COMMON_ENTRY_PTR entry; + struct frame_info *fi; +- char *funname = 0; +- struct symbol *func; ++ struct block *block; ++ int values_printed = 0; + + /* We have been told to display the contents of F77 COMMON + block supposedly visible in this function. Let us +@@ -556,74 +587,31 @@ info_common_command (char *comname, int + /* The following is generally ripped off from stack.c's routine + print_frame_info(). */ + +- func = find_pc_function (get_frame_pc (fi)); +- if (func) ++ block = get_frame_block (fi, 0); ++ if (block == NULL) + { +- /* In certain pathological cases, the symtabs give the wrong +- function (when we are in the first function in a file which +- is compiled without debugging symbols, the previous function +- is compiled with debugging symbols, and the "foo.o" symbol +- that is supposed to tell us where the file with debugging symbols +- ends has been truncated by ar because it is longer than 15 +- characters). +- +- So look in the minimal symbol tables as well, and if it comes +- up with a larger address for the function use that instead. +- I don't think this can ever cause any problems; there shouldn't +- be any minimal symbols in the middle of a function. +- FIXME: (Not necessarily true. What about text labels?) */ +- +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); +- +- if (msymbol != NULL +- && (SYMBOL_VALUE_ADDRESS (msymbol) +- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else +- funname = SYMBOL_LINKAGE_NAME (func); +- } +- else +- { +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); +- +- if (msymbol != NULL) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else /* Got no 'funname', code below will fail. */ +- error (_("No function found for frame.")); ++ printf_filtered (_("No symbol table info available.\n")); ++ return; + } + +- /* If comname is NULL, we assume the user wishes to see the +- which COMMON blocks are visible here and then return. */ +- +- if (comname == 0) ++ while (block) + { +- list_all_visible_commons (funname); +- return; ++ if (info_common_command_for_block (block, fi, comname)) ++ values_printed = 1; ++ /* After handling the function's top-level block, stop. Don't ++ continue to its superblock, the block of per-file symbols. */ ++ if (BLOCK_FUNCTION (block)) ++ break; ++ block = BLOCK_SUPERBLOCK (block); + } + +- the_common = find_common_for_function (comname, funname); +- +- if (the_common) ++ if (!values_printed) + { +- if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0) +- printf_filtered (_("Contents of blank COMMON block:\n")); ++ if (comname) ++ printf_filtered (_("No common block '%s'.\n"), comname); + else +- printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname); +- +- printf_filtered ("\n"); +- entry = the_common->entries; +- +- while (entry != NULL) +- { +- print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0); +- entry = entry->next; +- } ++ printf_filtered (_("No common blocks.\n")); + } +- else +- printf_filtered (_("Cannot locate the common block %s in function '%s'\n"), +- comname, funname); + } + + void +Index: gdb-7.3.50.20110722/gdb/stack.c +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/stack.c 2011-07-22 20:12:05.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/stack.c 2011-07-22 20:17:22.000000000 +0200 +@@ -1524,6 +1524,8 @@ iterate_over_block_locals (struct block + case LOC_COMPUTED: + if (SYMBOL_IS_ARGUMENT (sym)) + break; ++ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) ++ break; + (*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data); + break; + +Index: gdb-7.3.50.20110722/gdb/symtab.h +=================================================================== +--- gdb-7.3.50.20110722.orig/gdb/symtab.h 2011-07-22 20:12:05.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/symtab.h 2011-07-22 20:18:58.000000000 +0200 +@@ -396,7 +396,10 @@ typedef enum domain_enum_tag + + /* LABEL_DOMAIN may be used for names of labels (for gotos). */ + +- LABEL_DOMAIN ++ LABEL_DOMAIN, ++ ++ /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. */ ++ COMMON_BLOCK_DOMAIN + } domain_enum; + + /* Searching domains, used for `search_symbols'. Element numbers are +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.exp 2011-07-22 20:17:22.000000000 +0200 +@@ -0,0 +1,101 @@ ++# 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. ++ ++# This file was written by Jan Kratochvil . ++ ++set testfile "common-block" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "stop-here-out"] ++gdb_continue_to_breakpoint "stop-here-out" ++ ++# Common block naming with source name /foo/: ++# .symtab DW_TAG_common_block's DW_AT_name ++# Intel Fortran foo_ foo_ ++# GNU Fortran foo_ foo ++#set suffix "_" ++set suffix "" ++ ++set int4 {(integer\(kind=4\)|INTEGER\(4\))} ++set real4 {(real\(kind=4\)|REAL\(4\))} ++set real8 {(real\(kind=8\)|REAL\(8\))} ++ ++gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++ ++gdb_test "info locals" "ix_x = 11\r\niy_y = 22\r\niz_z = 33\r\nix = 1\r\niy = 2\r\niz = 3" "info locals out" ++gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix_x = 11\r\niy_y = 22\r\niz_z = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix = 1\r\niy = 2\r\niz = 3" "info common out" ++ ++gdb_test "ptype ix" "type = $int4" "ptype ix out" ++gdb_test "ptype iy" "type = $real4" "ptype iy out" ++gdb_test "ptype iz" "type = $real8" "ptype iz out" ++gdb_test "ptype ix_x" "type = $int4" "ptype ix_x out" ++gdb_test "ptype iy_y" "type = $real4" "ptype iy_y out" ++gdb_test "ptype iz_z" "type = $real8" "ptype iz_z out" ++ ++gdb_test "p ix" " = 1 *" "p ix out" ++gdb_test "p iy" " = 2 *" "p iy out" ++gdb_test "p iz" " = 3 *" "p iz out" ++gdb_test "p ix_x" " = 11 *" "p ix_x out" ++gdb_test "p iy_y" " = 22 *" "p iy_y out" ++gdb_test "p iz_z" " = 33 *" "p iz_z out" ++ ++gdb_breakpoint [gdb_get_line_number "stop-here-in"] ++gdb_continue_to_breakpoint "stop-here-in" ++ ++gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." "whatis foo$suffix in" ++gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." "ptype foo$suffix in" ++gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." "p foo$suffix in" ++gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "whatis fo_o$suffix in" ++gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "ptype fo_o$suffix in" ++gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "p fo_o$suffix in" ++ ++gdb_test "info locals" "ix = 11\r\niy2 = 22\r\niz = 33\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3\r\niy = 5\r\niz_z = 55" "info locals in" ++gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix = 11\r\niy2 = 22\r\niz = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3" "info common in" ++ ++gdb_test "ptype ix" "type = $int4" "ptype ix in" ++gdb_test "ptype iy2" "type = $real4" "ptype iy2 in" ++gdb_test "ptype iz" "type = $real8" "ptype iz in" ++gdb_test "ptype ix_x" "type = $int4" "ptype ix_x in" ++gdb_test "ptype iy_y" "type = $real4" "ptype iy_y in" ++gdb_test "ptype iz_z2" "type = $real8" "ptype iz_z2 in" ++ ++gdb_test "p ix" " = 11 *" "p ix in" ++gdb_test "p iy2" " = 22 *" "p iy2 in" ++gdb_test "p iz" " = 33 *" "p iz in" ++gdb_test "p ix_x" " = 1 *" "p ix_x in" ++gdb_test "p iy_y" " = 2 *" "p iy_y in" ++gdb_test "p iz_z2" " = 3 *" "p iz_z2 in" +Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.f90 2011-07-22 20:17:22.000000000 +0200 +@@ -0,0 +1,67 @@ ++! 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine in ++ ++ INTEGER*4 ix ++ REAL*4 iy2 ++ REAL*8 iz ++ ++ INTEGER*4 ix_x ++ REAL*4 iy_y ++ REAL*8 iz_z2 ++ ++ common /fo_o/ix,iy2,iz ++ common /foo/ix_x,iy_y,iz_z2 ++ ++ iy = 5 ++ iz_z = 55 ++ ++ if (ix .ne. 11 .or. iy2 .ne. 22.0 .or. iz .ne. 33.0) call abort ++ if (ix_x .ne. 1 .or. iy_y .ne. 2.0 .or. iz_z2 .ne. 3.0) call abort ++ ++ ix = 0 ! stop-here-in ++ ++end subroutine in ++ ++program common_test ++ ++ INTEGER*4 ix ++ REAL*4 iy ++ REAL*8 iz ++ ++ INTEGER*4 ix_x ++ REAL*4 iy_y ++ REAL*8 iz_z ++ ++ common /foo/ix,iy,iz ++ common /fo_o/ix_x,iy_y,iz_z ++ ++ ix = 1 ++ iy = 2.0 ++ iz = 3.0 ++ ++ ix_x = 11 ++ iy_y = 22.0 ++ iz_z = 33.0 ++ ++ call in ! stop-here-out ++ ++end program common_test diff --git a/gdb/patches/gdb-gcc46-stdarg-prologue.patch b/gdb/patches/gdb-gcc46-stdarg-prologue.patch new file mode 100644 index 000000000..d0f318e8b --- /dev/null +++ b/gdb/patches/gdb-gcc46-stdarg-prologue.patch @@ -0,0 +1,655 @@ +http://sourceware.org/ml/gdb-patches/2011-07/msg00645.html +Subject: [patch] workaround gcc46: prologue skip skips too far (PR 12435) #2 + +Hi, + +this is an improved patch of a former: + [patch] workaround gcc46: prologue skip skips too far (PR 12435) + http://sourceware.org/ml/gdb-patches/2011-03/msg01108.html + cancel/FYI: Re: [patch] workaround gcc46: prologue skip skips too far (PR 12435) + http://sourceware.org/ml/gdb-patches/2011-03/msg01123.html + +For example `break error' does not work for debugging GDB with gcc-4.6.x. + +As gcc-4.6.0 and now even 4.6.1 still has this bug and I have seen a user(s?) +on non-Fedora platform asking about this bug and as there may be enough +binaries out there (although it affects only -O0 -g compilation) coded it +properly I have coded the workaround properly this time. + +It does not solve overlays well, but the code just does not work for overlays, +it has no other negative effect. + +I will update the code after FSF gcc gets fixed to minimize the workaround. + +No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. + +I would welcome a comment whether it is suitable for FSF GDB. + + +Thanks, +Jan + + +gdb/ +2011-07-22 Jan Kratochvil + + PR breakpoints/12435 + * amd64-tdep.c (amd64_skip_prologue): New variables start_pc_sal, + next_sal, buf, offset and xmmreg. Advance PC if it sees the PR. + * dwarf2read.c (process_full_comp_unit): Initialize + amd64_prologue_line_bug. + * symtab.h (struct symtab): New field amd64_prologue_line_bug. + +gdb/testsuite/ +2011-07-22 Jan Kratochvil + + PR breakpoints/12435 + * gdb.arch/amd64-prologue-xmm.c: New file. + * gdb.arch/amd64-prologue-xmm.exp: New file. + * gdb.arch/amd64-prologue-xmm.s: New file. + +--- a/gdb/amd64-tdep.c ++++ b/gdb/amd64-tdep.c +@@ -1902,6 +1902,9 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) + { + struct amd64_frame_cache cache; + CORE_ADDR pc; ++ struct symtab_and_line start_pc_sal, next_sal; ++ gdb_byte buf[4 + 8 * 7]; ++ int offset, xmmreg; + + amd64_init_frame_cache (&cache); + pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL, +@@ -1909,7 +1912,71 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) + if (cache.frameless_p) + return start_pc; + +- return pc; ++ /* GCC PR debug/48827 produced false prologue end: ++ 84 c0 test %al,%al ++ 74 23 je after ++ <-- here is 0 lines advance - the false prologue end marker. ++ 0f 29 85 70 ff ff ff movaps %xmm0,-0x90(%rbp) ++ 0f 29 4d 80 movaps %xmm1,-0x80(%rbp) ++ 0f 29 55 90 movaps %xmm2,-0x70(%rbp) ++ 0f 29 5d a0 movaps %xmm3,-0x60(%rbp) ++ 0f 29 65 b0 movaps %xmm4,-0x50(%rbp) ++ 0f 29 6d c0 movaps %xmm5,-0x40(%rbp) ++ 0f 29 75 d0 movaps %xmm6,-0x30(%rbp) ++ 0f 29 7d e0 movaps %xmm7,-0x20(%rbp) ++ after: */ ++ ++ if (pc == start_pc) ++ return pc; ++ ++ start_pc_sal = find_pc_sect_line (start_pc, NULL, 0); ++ if (start_pc_sal.symtab == NULL ++ || !start_pc_sal.symtab->amd64_prologue_line_bug ++ || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end) ++ return pc; ++ ++ next_sal = find_pc_sect_line (start_pc_sal.end, NULL, 0); ++ if (next_sal.line != start_pc_sal.line) ++ return pc; ++ ++ /* START_PC can be from overlayed memory, ignored here. */ ++ if (target_read_memory (next_sal.pc - 4, buf, sizeof (buf)) != 0) ++ return pc; ++ ++ /* test %al,%al */ ++ if (buf[0] != 0x84 || buf[1] != 0xc0) ++ return pc; ++ /* je AFTER */ ++ if (buf[2] != 0x74) ++ return pc; ++ ++ offset = 4; ++ for (xmmreg = 0; xmmreg < 8; xmmreg++) ++ { ++ /* movaps %xmmreg?,-0x??(%rbp) */ ++ if (buf[offset] != 0x0f || buf[offset + 1] != 0x29 ++ || (buf[offset + 2] & 0b00111111) != (xmmreg << 3 | 0b101)) ++ return pc; ++ ++ if ((buf[offset + 2] & 0b11000000) == 0b01000000) ++ { ++ /* 8-bit displacement. */ ++ offset += 4; ++ } ++ else if ((buf[offset + 2] & 0b11000000) == 0b10000000) ++ { ++ /* 32-bit displacement. */ ++ offset += 7; ++ } ++ else ++ return pc; ++ } ++ ++ /* je AFTER */ ++ if (offset - 4 != buf[3]) ++ return pc; ++ ++ return next_sal.end; + } + + +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -4818,6 +4818,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) + + if (gcc_4_minor >= 5) + symtab->epilogue_unwind_valid = 1; ++ ++ if (gcc_4_minor >= 6) ++ symtab->amd64_prologue_line_bug = 1; + } + + if (dwarf2_per_objfile->using_index) +--- a/gdb/symtab.h ++++ b/gdb/symtab.h +@@ -784,6 +784,11 @@ struct symtab + + unsigned int epilogue_unwind_valid : 1; + ++ /* At least GCC 4.6.0 and 4.6.1 can produce invalid false prologue and marker ++ on amd64. This flag is set independently of the symtab arch. */ ++ ++ unsigned amd64_prologue_line_bug : 1; ++ + /* The macro table for this symtab. Like the blockvector, this + may be shared between different symtabs --- and normally is for + all the symtabs in a given compilation unit. */ +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.c +@@ -0,0 +1,38 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++static volatile int v, fail; ++ ++static void ++func (int i, ...) ++{ ++ v = i; ++} ++ ++static void ++marker (void) ++{ ++} ++ ++int ++main (void) ++{ ++ func (1); ++ fail = 1; ++ marker (); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp +@@ -0,0 +1,46 @@ ++# Copyright 2011 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 . ++ ++# Test GCC PR debug/48827 workaround in GDB. ++ ++set testfile "amd64-prologue-xmm" ++set srcfile ${testfile}.s ++set csrcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile}.x ++set opts {} ++ ++if [info exists COMPILE] { ++ # make check RUNTESTFLAGS='gdb.arch/amd64-prologue-xmm.exp COMPILE=1' ++ set srcfile ${csrcfile} ++ lappend opts debug optimize=-O0 ++} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } { ++ verbose "Skipping amd64-prologue-xmm test." ++ return 0 ++} ++ ++if {[prepare_for_testing ${testfile}.exp ${testfile} $srcfile $opts]} { ++ return -1 ++} ++ ++if ![runto_main] { ++ return -1 ++} ++ ++gdb_breakpoint "func" ++gdb_breakpoint "marker" ++ ++gdb_continue_to_breakpoint "func" ++ ++gdb_test "p fail" " = 0" "stopped at func" +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.s +@@ -0,0 +1,400 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++/* This file is compiled from gdb.arch/amd64-prologue-xmm.c ++ using -g -dA -S. */ ++ ++ .file "amd64-prologue-xmm.c" ++ .text ++.Ltext0: ++ .local v ++ .comm v,4,4 ++ .local fail ++ .comm fail,4,4 ++ .type func, @function ++func: ++.LFB0: ++ .file 1 "gdb.arch/amd64-prologue-xmm.c" ++ # gdb.arch/amd64-prologue-xmm.c:22 ++ .loc 1 22 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ .cfi_offset 6, -16 ++ movq %rsp, %rbp ++ .cfi_def_cfa_register 6 ++ subq $72, %rsp ++ movq %rsi, -168(%rbp) ++ movq %rdx, -160(%rbp) ++ movq %rcx, -152(%rbp) ++ movq %r8, -144(%rbp) ++ movq %r9, -136(%rbp) ++ testb %al, %al ++ je .L2 ++ # basic block 3 ++ # gdb.arch/amd64-prologue-xmm.c:22 ++ .loc 1 22 0 ++ movaps %xmm0, -128(%rbp) ++ movaps %xmm1, -112(%rbp) ++ movaps %xmm2, -96(%rbp) ++ movaps %xmm3, -80(%rbp) ++ movaps %xmm4, -64(%rbp) ++ movaps %xmm5, -48(%rbp) ++ movaps %xmm6, -32(%rbp) ++ movaps %xmm7, -16(%rbp) ++.L2: ++ # basic block 4 ++ movl %edi, -180(%rbp) ++ # gdb.arch/amd64-prologue-xmm.c:23 ++ .loc 1 23 0 ++ movl -180(%rbp), %eax ++ movl %eax, v(%rip) ++ # gdb.arch/amd64-prologue-xmm.c:24 ++ .loc 1 24 0 ++ leave ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE0: ++ .size func, .-func ++ .type marker, @function ++marker: ++.LFB1: ++ # gdb.arch/amd64-prologue-xmm.c:28 ++ .loc 1 28 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ .cfi_offset 6, -16 ++ movq %rsp, %rbp ++ .cfi_def_cfa_register 6 ++ # gdb.arch/amd64-prologue-xmm.c:29 ++ .loc 1 29 0 ++ popq %rbp ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE1: ++ .size marker, .-marker ++ .globl main ++ .type main, @function ++main: ++.LFB2: ++ # gdb.arch/amd64-prologue-xmm.c:33 ++ .loc 1 33 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ .cfi_offset 6, -16 ++ movq %rsp, %rbp ++ .cfi_def_cfa_register 6 ++ # gdb.arch/amd64-prologue-xmm.c:34 ++ .loc 1 34 0 ++ movl $1, %edi ++ movl $0, %eax ++ call func ++ # gdb.arch/amd64-prologue-xmm.c:35 ++ .loc 1 35 0 ++ movl $1, fail(%rip) ++ # gdb.arch/amd64-prologue-xmm.c:36 ++ .loc 1 36 0 ++ call marker ++ # gdb.arch/amd64-prologue-xmm.c:37 ++ .loc 1 37 0 ++ movl $0, %eax ++ # gdb.arch/amd64-prologue-xmm.c:38 ++ .loc 1 38 0 ++ popq %rbp ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE2: ++ .size main, .-main ++.Letext0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .long 0xc0 # Length of Compilation Unit Info ++ .value 0x4 # DWARF version number ++ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section ++ .byte 0x8 # Pointer Size (in bytes) ++ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) ++ .long .LASF1 # DW_AT_producer: "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)" ++ .byte 0x1 # DW_AT_language ++ .long .LASF2 # DW_AT_name: "gdb.arch/amd64-prologue-xmm.c" ++ .long .LASF3 # DW_AT_comp_dir: "" ++ .quad .Ltext0 # DW_AT_low_pc ++ .quad .Letext0 # DW_AT_high_pc ++ .long .Ldebug_line0 # DW_AT_stmt_list ++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) ++ .long .LASF4 # DW_AT_name: "func" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x15 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .quad .LFB0 # DW_AT_low_pc ++ .quad .LFE0 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ # DW_AT_GNU_all_call_sites ++ .long 0x59 # DW_AT_sibling ++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter) ++ .ascii "i\0" # DW_AT_name ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x15 # DW_AT_decl_line ++ .long 0x59 # DW_AT_type ++ .uleb128 0x3 # DW_AT_location ++ .byte 0x91 # DW_OP_fbreg ++ .sleb128 -196 ++ .uleb128 0x4 # (DIE (0x57) DW_TAG_unspecified_parameters) ++ .byte 0 # end of children of DIE 0x2d ++ .uleb128 0x5 # (DIE (0x59) DW_TAG_base_type) ++ .byte 0x4 # DW_AT_byte_size ++ .byte 0x5 # DW_AT_encoding ++ .ascii "int\0" # DW_AT_name ++ .uleb128 0x6 # (DIE (0x60) DW_TAG_subprogram) ++ .long .LASF5 # DW_AT_name: "marker" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x1b # DW_AT_decl_line ++ # DW_AT_prototyped ++ .quad .LFB1 # DW_AT_low_pc ++ .quad .LFE1 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ # DW_AT_GNU_all_call_sites ++ .uleb128 0x7 # (DIE (0x79) DW_TAG_subprogram) ++ # DW_AT_external ++ .long .LASF6 # DW_AT_name: "main" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x20 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .long 0x59 # DW_AT_type ++ .quad .LFB2 # DW_AT_low_pc ++ .quad .LFE2 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ # DW_AT_GNU_all_tail_call_sites ++ .uleb128 0x8 # (DIE (0x96) DW_TAG_variable) ++ .ascii "v\0" # DW_AT_name ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x12 # DW_AT_decl_line ++ .long 0xa9 # DW_AT_type ++ .uleb128 0x9 # DW_AT_location ++ .byte 0x3 # DW_OP_addr ++ .quad v ++ .uleb128 0x9 # (DIE (0xa9) DW_TAG_volatile_type) ++ .long 0x59 # DW_AT_type ++ .uleb128 0xa # (DIE (0xae) DW_TAG_variable) ++ .long .LASF0 # DW_AT_name: "fail" ++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c) ++ .byte 0x12 # DW_AT_decl_line ++ .long 0xa9 # DW_AT_type ++ .uleb128 0x9 # DW_AT_location ++ .byte 0x3 # DW_OP_addr ++ .quad fail ++ .byte 0 # end of children of DIE 0xb ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .uleb128 0x1 # (abbrev code) ++ .uleb128 0x11 # (TAG: DW_TAG_compile_unit) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x25 # (DW_AT_producer) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x13 # (DW_AT_language) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x1b # (DW_AT_comp_dir) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x10 # (DW_AT_stmt_list) ++ .uleb128 0x17 # (DW_FORM_sec_offset) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x2 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x1 # (DW_AT_sibling) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x3 # (abbrev code) ++ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x4 # (abbrev code) ++ .uleb128 0x18 # (TAG: DW_TAG_unspecified_parameters) ++ .byte 0 # DW_children_no ++ .byte 0 ++ .byte 0 ++ .uleb128 0x5 # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0 # DW_children_no ++ .uleb128 0xb # (DW_AT_byte_size) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3e # (DW_AT_encoding) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x6 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x7 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0 # DW_children_no ++ .uleb128 0x3f # (DW_AT_external) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x8 # (abbrev code) ++ .uleb128 0x34 # (TAG: DW_TAG_variable) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .uleb128 0x9 # (abbrev code) ++ .uleb128 0x35 # (TAG: DW_TAG_volatile_type) ++ .byte 0 # DW_children_no ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .byte 0 ++ .byte 0 ++ .uleb128 0xa # (abbrev code) ++ .uleb128 0x34 # (TAG: DW_TAG_variable) ++ .byte 0 # DW_children_no ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x2 # (DW_AT_location) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0 ++ .byte 0 ++ .byte 0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c # Length of Address Ranges Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .byte 0x8 # Size of Address ++ .byte 0 # Size of Segment Descriptor ++ .value 0 # Pad to 16 byte boundary ++ .value 0 ++ .quad .Ltext0 # Address ++ .quad .Letext0-.Ltext0 # Length ++ .quad 0 ++ .quad 0 ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .section .debug_str,"MS",@progbits,1 ++.LASF3: ++ .string "" ++.LASF0: ++ .string "fail" ++.LASF4: ++ .string "func" ++.LASF1: ++ .string "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)" ++.LASF2: ++ .string "gdb.arch/amd64-prologue-xmm.c" ++.LASF5: ++ .string "marker" ++.LASF6: ++ .string "main" ++ .ident "GCC: (GNU) 4.6.1 20110715 (Red Hat 4.6.1-3)" ++ .section .note.GNU-stack,"",@progbits + diff --git a/gdb/patches/gdb-gdb-add-index-script.patch b/gdb/patches/gdb-gdb-add-index-script.patch new file mode 100644 index 000000000..1c145ace3 --- /dev/null +++ b/gdb/patches/gdb-gdb-add-index-script.patch @@ -0,0 +1,118 @@ +http://sourceware.org/ml/gdb-patches/2010-07/msg00184.html +Subject: Re: [0/4] RFC: add DWARF index support + +Jan Kratochvil: Fixed $d -> $dir. +Jan Kratochvil: Remove /dev/null redirection. + +>>>>> "Tom" == Tom Tromey writes: + +Tom> This patch series adds support for a DWARF index to gdb. + +Roland suggested we wrap up the index-creation code into a helper +script. + +I'm not sure if this is something people would want in gdb proper, but I +figured I would send it here just in case. + +Tom + +2010-07-09 Tom Tromey + + * Makefile.in (install-only): Install gdb-add-index. + * gdb-add-index: New file. + +2010-07-09 Tom Tromey + + * gdb.texinfo (Index Files): Mention gdb-add-index. + +>From 30714fe719e61baea03d0dc5793eb0d564faebb7 Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Fri, 9 Jul 2010 11:17:54 -0600 +Subject: [PATCH 4/4] add gdb-add-index +Subject: [PATCH 4/4] add gdb-add-index + +--- + gdb/ChangeLog | 5 +++++ + gdb/Makefile.in | 11 ++++++++++- + gdb/doc/ChangeLog | 4 ++++ + gdb/doc/gdb.texinfo | 8 ++++++++ + gdb/gdb-add-index | 30 ++++++++++++++++++++++++++++++ + 5 files changed, 57 insertions(+), 1 deletions(-) + create mode 100755 gdb/gdb-add-index + +Index: gdb-7.2.50.20101116/gdb/Makefile.in +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/Makefile.in 2010-11-16 08:03:17.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/Makefile.in 2010-11-16 08:47:45.000000000 +0100 +@@ -986,7 +986,16 @@ install-only: install-gstack $(CONFIG_IN + $(SHELL) $(srcdir)/../mkinstalldirs \ + $(DESTDIR)$(man1dir) ; \ + $(INSTALL_DATA) $(srcdir)/gdb.1 \ +- $(DESTDIR)$(man1dir)/$$transformed_name.1 ++ $(DESTDIR)$(man1dir)/$$transformed_name.1; \ ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb-add-index | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb-add-index ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(INSTALL_PROGRAM) $(srcdir)/gdb-add-index \ ++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) + @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do + .PHONY: install-tui + install-tui: +Index: gdb-7.2.50.20101116/gdb/doc/gdb.texinfo +=================================================================== +--- gdb-7.2.50.20101116.orig/gdb/doc/gdb.texinfo 2010-11-16 08:04:18.000000000 +0100 ++++ gdb-7.2.50.20101116/gdb/doc/gdb.texinfo 2010-11-16 08:56:30.000000000 +0100 +@@ -15500,6 +15500,14 @@ There are currently some limitation on i + for DWARF debugging information, not stabs. And, they do not + currently work for programs using Ada. + ++@value{GDBN} comes with a program, @command{gdb-add-index}, which can ++be used to add the index to a symbol file. It takes the symbol file ++as its only argument: ++ ++@smallexample ++$ gdb-add-index symfile ++@end smallexample ++ + @node Symbol Errors + @section Errors Reading Symbol Files + +Index: gdb-7.2.50.20101116/gdb/gdb-add-index +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2.50.20101116/gdb/gdb-add-index 2010-11-16 08:47:45.000000000 +0100 +@@ -0,0 +1,30 @@ ++#! /bin/sh ++ ++# Add a .gdb_index section to a file. ++ ++# Copyright (C) 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 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 . ++ ++file="$1" ++dir="${file%/*}" ++ ++# We don't care if gdb gives an error. ++gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir" ++ ++if test -f "${file}.gdb-index"; then ++ objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file" ++ rm -f "${file}.gdb-index" ++fi ++ ++exit 0 diff --git a/gdb/patches/gdb-glibc-vdso-workaround.patch b/gdb/patches/gdb-glibc-vdso-workaround.patch new file mode 100644 index 000000000..48646d7fa --- /dev/null +++ b/gdb/patches/gdb-glibc-vdso-workaround.patch @@ -0,0 +1,30 @@ +http://sourceware.org/ml/gdb-patches/2011-08/msg00331.html +Subject: [RFC] Work around PR libc/13097 "linux-vdso.so.1" #2 + +Hi, + +missed the x86_64-m32 case: + +gdb/ +2011-08-16 Jan Kratochvil + + Work around PR libc/13097. + * solib.c (update_solib_list): Ignore "linux-vdso.so.1". + +--- a/gdb/solib.c ++++ b/gdb/solib.c +@@ -783,8 +783,11 @@ update_solib_list (int from_tty, struct target_ops *target) + + TRY_CATCH (e, RETURN_MASK_ERROR) + { +- /* Fill in the rest of the `struct so_list' node. */ +- if (!solib_map_sections (i)) ++ /* Fill in the rest of the `struct so_list' node. ++ Work around PR libc/13097. */ ++ if (!solib_map_sections (i) ++ && strcmp (i->so_original_name, "linux-vdso.so.1") != 0 ++ && strcmp (i->so_original_name, "linux-gate.so.1") != 0) + { + not_found++; + if (not_found_filename == NULL) + diff --git a/gdb/patches/gdb-implptr-64bit-1of2.patch b/gdb/patches/gdb-implptr-64bit-1of2.patch new file mode 100644 index 000000000..e24595d86 --- /dev/null +++ b/gdb/patches/gdb-implptr-64bit-1of2.patch @@ -0,0 +1,110 @@ +http://sourceware.org/ml/gdb-patches/2011-09/msg00450.html +Subject: [patch 1/2] Code cleanup: Unify dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size + +Hi, + +this is more rather for patch 2/2, it has positive LoC change but still +I would find it applicable even on its own. + +No functionality change intended. + + +Thanks, +Jan + + +gdb/ +2011-09-26 Jan Kratochvil + + Code cleanup. + * dwarf2read.c (per_cu_header_read_in): New function. + (dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size): Use it, with new + variables cu_header_local and cu_headerp. + +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -15187,26 +15187,42 @@ dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu) + return objfile; + } + ++/* Return comp_unit_head for PER_CU, either already available in PER_CU->CU ++ (CU_HEADERP is unused in such case) or prepare a temporary copy at ++ CU_HEADERP first. */ ++ ++static const struct comp_unit_head * ++per_cu_header_read_in (struct comp_unit_head *cu_headerp, ++ struct dwarf2_per_cu_data *per_cu) ++{ ++ struct objfile *objfile; ++ struct dwarf2_per_objfile *per_objfile; ++ gdb_byte *info_ptr; ++ ++ if (per_cu->cu) ++ return &per_cu->cu->header; ++ ++ objfile = per_cu->objfile; ++ per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); ++ info_ptr = per_objfile->info.buffer + per_cu->offset; ++ ++ memset (cu_headerp, 0, sizeof (*cu_headerp)); ++ read_comp_unit_head (cu_headerp, info_ptr, objfile->obfd); ++ ++ return cu_headerp; ++} ++ + /* Return the address size given in the compilation unit header for CU. */ + + CORE_ADDR + dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu) + { +- if (per_cu->cu) +- return per_cu->cu->header.addr_size; +- else +- { +- /* If the CU is not currently read in, we re-read its header. */ +- struct objfile *objfile = per_cu->objfile; +- struct dwarf2_per_objfile *per_objfile +- = objfile_data (objfile, dwarf2_objfile_data_key); +- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset; +- struct comp_unit_head cu_header; ++ struct comp_unit_head cu_header_local; ++ const struct comp_unit_head *cu_headerp; + +- memset (&cu_header, 0, sizeof cu_header); +- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd); +- return cu_header.addr_size; +- } ++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu); ++ ++ return cu_headerp->addr_size; + } + + /* Return the offset size given in the compilation unit header for CU. */ +@@ -15214,21 +15230,12 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu) + int + dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu) + { +- if (per_cu->cu) +- return per_cu->cu->header.offset_size; +- else +- { +- /* If the CU is not currently read in, we re-read its header. */ +- struct objfile *objfile = per_cu->objfile; +- struct dwarf2_per_objfile *per_objfile +- = objfile_data (objfile, dwarf2_objfile_data_key); +- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset; +- struct comp_unit_head cu_header; ++ struct comp_unit_head cu_header_local; ++ const struct comp_unit_head *cu_headerp; + +- memset (&cu_header, 0, sizeof cu_header); +- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd); +- return cu_header.offset_size; +- } ++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu); ++ ++ return cu_headerp->offset_size; + } + + /* Return the text offset of the CU. The returned offset comes from + diff --git a/gdb/patches/gdb-implptr-64bit-2of2.patch b/gdb/patches/gdb-implptr-64bit-2of2.patch new file mode 100644 index 000000000..d18067487 --- /dev/null +++ b/gdb/patches/gdb-implptr-64bit-2of2.patch @@ -0,0 +1,411 @@ +http://sourceware.org/ml/gdb-patches/2011-09/msg00451.html +Subject: [patch 2/2] Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches + +Hi, + +on 64-bit targets DWARF-3+ is used DW_OP_GNU_implicit_pointer does not work. + +DWARF-2 says: + This type of reference (DW_FORM_ref_addr) is the size of an address on + the target architecture; +DWARF-3 says: + 1.5.1 Upward Compatibility + References that use the attribute form DW_FORM_ref_addr are specified + to be four bytes in the DWARF 32-bit format and eight bytes in the + DWARF 64-bit format, while DWARF Version 2 specifies that such + references have the same size as an address on the target system (see + Sections 7.4 and 7.5.4). + + (DW_FORM_ref_addr) + In the 32-bit DWARF format, this offset is a 4-byte unsigned value; in + the 64-bit DWARF format, it is an 8-byte unsigned value (see Section + 7.4). + +GDB currently parsed DW_OP_GNU_implicit_pointer the DWARF-2 way, being +incompatible with DWARF-3+. + +I think DW_OP_GNU_implicit_pointer does not make sense to be used from +.debug_frame (DWARF-5 is not yet released to say more) so for .debug_frame its +use is just not permitted (the code would be more complicated otherwise). + +No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. + + +Thanks, +Jan + + +gdb/ +2011-09-26 Jan Kratochvil + + Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches. + * dwarf2-frame.c (execute_stack_op): Initialize ctx->ref_addr_size. + * dwarf2expr.c (execute_stack_op) : Use + ctx->ref_addr_size. Handle its invalid value. + * dwarf2expr.h (struct dwarf_expr_context): New field ref_addr_size. + * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) + (dwarf2_loc_desc_needs_frame): Initialize ctx->ref_addr_size. + * dwarf2loc.h (dwarf2_per_cu_ref_addr_size): New declaration. + * dwarf2read.c (decode_locdesc): Initialize ctx->ref_addr_size. + (dwarf2_per_cu_ref_addr_size): New function. + +gdb/testsuite/ +2011-09-26 Jan Kratochvil + + Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches. + * gdb.dwarf2/implptr-64bit.S: New file. + * gdb.dwarf2/implptr-64bit.exp: New file. + +--- a/gdb/dwarf2-frame.c ++++ b/gdb/dwarf2-frame.c +@@ -371,6 +371,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size, + + ctx->gdbarch = get_frame_arch (this_frame); + ctx->addr_size = addr_size; ++ ctx->ref_addr_size = -1; + ctx->offset = offset; + ctx->baton = this_frame; + ctx->funcs = &dwarf2_frame_ctx_funcs; +--- a/gdb/dwarf2expr.c ++++ b/gdb/dwarf2expr.c +@@ -709,10 +709,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, + ULONGEST die; + LONGEST len; + ++ if (ctx->ref_addr_size == -1) ++ error (_("DWARF-2 expression error: DW_OP_GNU_implicit_pointer " ++ "is not allowed in frame context")); ++ + /* The referred-to DIE. */ +- ctx->len = extract_unsigned_integer (op_ptr, ctx->addr_size, ++ ctx->len = extract_unsigned_integer (op_ptr, ctx->ref_addr_size, + byte_order); +- op_ptr += ctx->addr_size; ++ op_ptr += ctx->ref_addr_size; + + /* The byte offset into the data. */ + op_ptr = read_sleb128 (op_ptr, op_end, &len); +--- a/gdb/dwarf2expr.h ++++ b/gdb/dwarf2expr.h +@@ -125,6 +125,10 @@ struct dwarf_expr_context + /* Target address size in bytes. */ + int addr_size; + ++ /* DW_FORM_ref_addr size in bytes. If -1 DWARF is executed from a frame ++ context and operations depending on DW_FORM_ref_addr are not allowed. */ ++ int ref_addr_size; ++ + /* Offset used to relocate DW_OP_addr argument. */ + CORE_ADDR offset; + +--- a/gdb/dwarf2loc.c ++++ b/gdb/dwarf2loc.c +@@ -1118,6 +1118,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, + + ctx->gdbarch = get_objfile_arch (objfile); + ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); ++ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu); + ctx->offset = dwarf2_per_cu_text_offset (per_cu); + ctx->baton = &baton; + ctx->funcs = &dwarf_expr_ctx_funcs; +@@ -1398,6 +1399,7 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size, + + ctx->gdbarch = get_objfile_arch (objfile); + ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); ++ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu); + ctx->offset = dwarf2_per_cu_text_offset (per_cu); + ctx->baton = &baton; + ctx->funcs = &needs_frame_ctx_funcs; +--- a/gdb/dwarf2loc.h ++++ b/gdb/dwarf2loc.h +@@ -39,6 +39,10 @@ struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu); + /* Return the address size given in the compilation unit header for CU. */ + CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu); + ++/* Return the DW_FORM_ref_addr size given in the compilation unit header for ++ CU. */ ++int dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *cu); ++ + /* Return the offset size given in the compilation unit header for CU. */ + int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu); + +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -15238,6 +15239,22 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu) + return cu_headerp->offset_size; + } + ++/* See its dwarf2loc.h declaration. */ ++ ++int ++dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu) ++{ ++ struct comp_unit_head cu_header_local; ++ const struct comp_unit_head *cu_headerp; ++ ++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu); ++ ++ if (cu_headerp->version == 2) ++ return cu_headerp->addr_size; ++ else ++ return cu_headerp->offset_size; ++} ++ + /* Return the text offset of the CU. The returned offset comes from + this CU's objfile. If this objfile came from a separate debuginfo + file, then the offset may be different from the corresponding +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/implptr-64bit.S +@@ -0,0 +1,197 @@ ++/* Copyright 2010, 2011 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 . */ ++ ++ .section .debug_info ++d: ++ /* Length of Compilation Unit Info */ ++#if OFFSET_SIZE == 4 ++# define OFFSET .4byte ++ .4byte debug_end - 1f ++#elif OFFSET_SIZE == 8 ++# define OFFSET .8byte ++ .4byte 0xffffffff ++ .8byte debug_end - 1f ++#else ++# error ++#endif ++#if ADDR_SIZE == 4 ++# define ADDR .4byte ++#elif ADDR_SIZE == 8 ++# define ADDR .8byte ++#else ++# error ++#endif ++#if REF_ADDR_SIZE == 4 ++# define REF_ADDR .4byte ++#elif REF_ADDR_SIZE == 8 ++# define REF_ADDR .8byte ++#else ++# error ++#endif ++1: ++ .2byte DWARF_VERSION /* DWARF version number */ ++ OFFSET .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte ADDR_SIZE /* Pointer Size (in bytes) */ ++ ++ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ ++ .ascii "GNU C 4.4.3\0" /* DW_AT_producer */ ++ .byte 0x1 /* DW_AT_language */ ++ .ascii "1.c\0" /* DW_AT_name */ ++ ++.Ltype_int: ++ .uleb128 0x7 /* DW_TAG_base_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .byte 0x5 /* DW_AT_encoding */ ++ .ascii "int\0" /* DW_AT_name */ ++ ++.Ltype_struct: ++ .uleb128 0x2 /* DW_TAG_structure_type */ ++ .ascii "s\0" /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ ++ .uleb128 0x3 /* DW_TAG_member */ ++ .ascii "f\0" /* DW_AT_name */ ++ .4byte .Ltype_int - d /* DW_AT_type */ ++ .byte 0 /* DW_AT_data_member_location */ ++ ++ .byte 0x0 /* end of children of DW_TAG_structure_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_subprogram */ ++ .ascii "main\0" /* DW_AT_name */ ++ ADDR main /* DW_AT_low_pc */ ++ ADDR main + 0x100 /* DW_AT_high_pc */ ++ .4byte .Ltype_int - d /* DW_AT_type */ ++ .byte 1 /* DW_AT_external */ ++ ++.Ltype_structptr: ++ .uleb128 0x5 /* DW_TAG_pointer_type */ ++ .byte ADDR_SIZE /* DW_AT_byte_size */ ++ .4byte .Ltype_struct - d /* DW_AT_type */ ++ ++.Lvar_out: ++ .uleb128 0x4 /* (DW_TAG_variable) */ ++ .ascii "v\0" /* DW_AT_name */ ++ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */ ++1: ++ .byte 0x9e /* DW_OP_implicit_value */ ++ .uleb128 2f - 3f ++3: ++ .byte 1, 1, 1, 1 ++2: ++ .4byte .Ltype_struct - d /* DW_AT_type */ ++ ++ .uleb128 0x4 /* (DW_TAG_variable) */ ++ .ascii "p\0" /* DW_AT_name */ ++ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */ ++1: ++ .byte 0xf2 /* DW_OP_GNU_implicit_pointer */ ++ REF_ADDR .Lvar_out - d /* referenced DIE */ ++ .sleb128 0 /* offset */ ++2: ++ .4byte .Ltype_structptr - d /* DW_AT_type */ ++ ++ .byte 0x0 /* end of children of main */ ++ ++ .byte 0x0 /* end of children of CU */ ++debug_end: ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ ++ .uleb128 0x1 /* (abbrev code) */ ++ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* (DW_AT_producer) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x13 /* (DW_AT_language) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 0x2 /* (abbrev code) */ ++ .uleb128 0x13 /* (TAG: DW_TAG_structure_type) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .byte 0 ++ .byte 0 ++ ++ .uleb128 0x3 /* (abbrev code) */ ++ .uleb128 0xd /* (TAG: DW_TAG_member) */ ++ .byte 0 /* DW_children_no */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .uleb128 0x38 /* (DW_AT_data_member_location) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .byte 0 ++ .byte 0 ++ ++ .uleb128 0x4 /* (abbrev code) */ ++ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ ++ .byte 0x0 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x02 /* (DW_AT_location) */ ++ .uleb128 0xa /* (DW_FORM_block1) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 0x5 /* (abbrev code) */ ++ .uleb128 0xf /* (TAG: DW_TAG_pointer_type) */ ++ .byte 0x0 /* DW_children_no */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 0x7 /* (abbrev code) */ ++ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */ ++ .byte 0 /* DW_children_no */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3e /* (DW_AT_encoding) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0 ++ .byte 0 ++ ++ .byte 0x0 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp +@@ -0,0 +1,51 @@ ++# Copyright 2011 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 . ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++set testfile "implptr-64bit" ++set srcfile ${testfile}.S ++set mainfile main.c ++ ++proc test { dwarf_version offset_size addr_size ref_addr_size } { ++ global testfile srcfile mainfile ++ ++ set opts {} ++ foreach n { dwarf_version offset_size addr_size ref_addr_size } { ++ lappend opts "additional_flags=-D[string toupper $n]=[expr "\$$n"]" ++ } ++ ++ set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}" ++ set executable ${testfile}-${name} ++ if [prepare_for_testing ${testfile}.exp $executable "${srcfile} ${mainfile}" $opts] { ++ return -1 ++ } ++ ++ if ![runto_main] { ++ return -1 ++ } ++ ++ gdb_test "p/x p->f" " = 0x1010101" $name ++} ++ ++# DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE ++test 2 8 4 4 ++test 2 4 8 8 ++test 3 8 4 8 ++test 3 4 8 4 + diff --git a/gdb/patches/gdb-lineno-makeup-test.patch b/gdb/patches/gdb-lineno-makeup-test.patch new file mode 100644 index 000000000..073662ada --- /dev/null +++ b/gdb/patches/gdb-lineno-makeup-test.patch @@ -0,0 +1,151 @@ +New testcase for: +https://bugzilla.redhat.com/show_bug.cgi?id=466222 + (for the first / customer recommended fix) +and the upstream fix: +http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html + [rfc] Do not make up line information +http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html + +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c +@@ -0,0 +1,21 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++void ++func (void) ++{ ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.c +@@ -0,0 +1,35 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++/* 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'. */ ++ ++extern void func (void); ++asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\""); ++ ++int ++main (void) ++{ ++ func (); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.exp +@@ -0,0 +1,78 @@ ++# Copyright 2009 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 . ++ ++set testfile "lineno-makeup" ++set srcfuncfile ${testfile}-func.c ++set srcfile ${testfile}.c ++set objfuncfile ${objdir}/${subdir}/${testfile}-func.o ++set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output] ++verbose -log "objcopy=$objcopy: $output" ++if { $objcopy != 0 } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++set binfuncfilesize [file size $binfuncfile] ++verbose -log "file size $binfuncfile = $binfuncfilesize" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set b_addr "" ++set test "break func" ++gdb_test_multiple $test $test { ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ pass $test ++ } ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ fail $test ++ } ++} ++verbose -log "b_addr=<$b_addr>" ++ ++set p_addr "" ++set test "print func" ++gdb_test_multiple $test $test { ++ -re "\\$\[0-9\]+ = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { ++ set p_addr $expect_out(1,string) ++ pass $test ++ } ++} ++verbose -log "p_addr=<$p_addr>" ++ ++set test "break address belongs to func" ++if {$b_addr == $p_addr} { ++ pass "$test (exact match)" ++} else { ++ set skip [expr $b_addr - $p_addr] ++ if {$skip > 0 && $skip < $binfuncfilesize} { ++ pass "$test (prologue skip by $skip bytes)" ++ } else { ++ fail $test ++ } ++} diff --git a/gdb/patches/gdb-moribund-utrace-workaround.patch b/gdb/patches/gdb-moribund-utrace-workaround.patch new file mode 100644 index 000000000..6b50a8ef9 --- /dev/null +++ b/gdb/patches/gdb-moribund-utrace-workaround.patch @@ -0,0 +1,16 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=590623 +http://sources.redhat.com/bugzilla/show_bug.cgi?id=11593 + +Bug in FSF GDB exploited by the ptrace-on-utrace interaction. + +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -9084,6 +9084,8 @@ update_global_location_list (int should_insert) + traps we can no longer explain. */ + + old_loc->events_till_retirement = 3 * (thread_count () + 1); ++ /* Red Hat Bug 590623. */ ++ old_loc->events_till_retirement *= 10; + old_loc->owner = NULL; + + VEC_safe_push (bp_location_p, moribund_locations, old_loc); diff --git a/gdb/patches/gdb-optimized-out-internal-error.patch b/gdb/patches/gdb-optimized-out-internal-error.patch new file mode 100644 index 000000000..1588ce6c4 --- /dev/null +++ b/gdb/patches/gdb-optimized-out-internal-error.patch @@ -0,0 +1,302 @@ +http://sourceware.org/ml/gdb-patches/2011-09/msg00449.html +Subject: [patch] Fix internal error on optimized-out values (regression by me) + +Hi, + +since: + Re: [patch] Code cleanup: Introduce allocate_optimized_out_value + http://sourceware.org/ml/gdb-patches/2011-07/msg00327.html + acfe85f56075910a3ba5e8b76189e0770079b8d1 +can occur: + (gdb) p p->f + valops.c:1118: internal-error: Unexpected lazy value type. + A problem internal to GDB has been detected, + +in that mail referenced above: +# It is true it would be definitely a bug in a code incompatible with such +# change so one may rather fix that possible regression there. + +so this testcase exploits such case. The problem is formerly the code +allocated (in some cases) optimized out values as non-lazy ones. Now they are +allocated all as lazy (*) which breaks some code not expecting lazy values. + +(*) Such lazy optimized out value still gets silently allocate_value_contents + by value_fetch_lazy, allocate_value_contents should be suppressed in such + case; such more radical change has never been made. + +Formerly (incl. gdb-7.3) did: + (gdb) p p->f + $1 = 0 +which was also wrong, ((struct *) )->field should be IMO still +; just it became internal-error now. + +GDB usually does require_not_optimized_out throwing error() when it meets any +first value. I have just produced new optimized value +instead; require_not_optimized_out is not exported and I find it better this +way. + +Following the rule that it is better if GDB does something wrong rather then +it throws internal-error to make the patch from July above fully safe one +would have to change allocate_optimized_out_value to allocate everything as +non-lazy. I find that as a too ugly workaround of the codebase. + +No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. + + +Andre, do you still see the bug even with this patch? + + +Thanks, +Jan + + +gdb/ +2011-09-26 Jan Kratochvil + + Fix internal error regression. + * value.c (value_primitive_field): Handle value_optimized_out. Move + packed bitfields comment. + +gdb/testsuite/ +2011-09-26 Jan Kratochvil + + Fix internal error regression. + * gdb.dwarf2/implptr-optimized-out.S: New file. + * gdb.dwarf2/implptr-optimized-out.exp: New file. + +--- a/gdb/value.c ++++ b/gdb/value.c +@@ -2482,16 +2482,19 @@ value_primitive_field (struct value *arg1, int offset, + description correctly. */ + check_typedef (type); + +- /* Handle packed fields */ +- +- if (TYPE_FIELD_BITSIZE (arg_type, fieldno)) ++ if (value_optimized_out (arg1)) ++ v = allocate_optimized_out_value (type); ++ else if (TYPE_FIELD_BITSIZE (arg_type, fieldno)) + { +- /* Create a new value for the bitfield, with bitpos and bitsize ++ /* Handle packed fields. ++ ++ Create a new value for the bitfield, with bitpos and bitsize + set. If possible, arrange offset and bitpos so that we can + do a single aligned read of the size of the containing type. + Otherwise, adjust offset to the byte containing the first + bit. Assume that the address, offset, and embedded offset + are sufficiently aligned. */ ++ + int bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno); + int container_bitsize = TYPE_LENGTH (type) * 8; + +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.S +@@ -0,0 +1,166 @@ ++/* Copyright 2010, 2011 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 . */ ++ ++ .section .debug_info ++d: ++ .long debug_end - 1f /* Length of Compilation Unit Info */ ++1: ++ .2byte 0x3 /* DWARF version number */ ++ .long .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 0x4 /* Pointer Size (in bytes) */ ++ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ ++ .ascii "GNU C 4.4.3\0" /* DW_AT_producer */ ++ .byte 0x1 /* DW_AT_language */ ++ .ascii "1.c\0" /* DW_AT_name */ ++ ++.Ltype_int: ++ .uleb128 0x7 /* DW_TAG_base_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .byte 0x5 /* DW_AT_encoding */ ++ .ascii "int\0" /* DW_AT_name */ ++ ++.Ltype_struct: ++ .uleb128 0x2 /* DW_TAG_structure_type */ ++ .ascii "s\0" /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ ++ .uleb128 0x3 /* DW_TAG_member */ ++ .ascii "f\0" /* DW_AT_name */ ++ .4byte .Ltype_int - d /* DW_AT_type */ ++ .byte 0 /* DW_AT_data_member_location */ ++ ++ .byte 0x0 /* end of children of DW_TAG_structure_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_subprogram */ ++ .ascii "main\0" /* DW_AT_name */ ++ .4byte main /* DW_AT_low_pc */ ++ .4byte main + 0x100 /* DW_AT_high_pc */ ++ .4byte .Ltype_int - d /* DW_AT_type */ ++ .byte 1 /* DW_AT_external */ ++ ++.Ltype_structptr: ++ .uleb128 0x5 /* DW_TAG_pointer_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .long .Ltype_struct - d /* DW_AT_type */ ++ ++.Lvar_out: ++ .uleb128 0x4 /* (DW_TAG_variable) */ ++ .ascii "v\0" /* DW_AT_name */ ++ .byte 0 /* DW_AT_location: DW_FORM_block1 */ ++ .4byte .Ltype_struct - d /* DW_AT_type */ ++ ++ .uleb128 0x4 /* (DW_TAG_variable) */ ++ .ascii "p\0" /* DW_AT_name */ ++ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */ ++1: ++ .byte 0xf2 /* DW_OP_GNU_implicit_pointer */ ++ .4byte .Lvar_out - d /* referenced DIE */ ++ .sleb128 0 /* offset */ ++2: ++ .4byte .Ltype_structptr - d /* DW_AT_type */ ++ ++ .byte 0x0 /* end of children of main */ ++ ++ .byte 0x0 /* end of children of CU */ ++debug_end: ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ ++ .uleb128 0x1 /* (abbrev code) */ ++ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* (DW_AT_producer) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x13 /* (DW_AT_language) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 0x2 /* (abbrev code) */ ++ .uleb128 0x13 /* (TAG: DW_TAG_structure_type) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .byte 0 ++ .byte 0 ++ ++ .uleb128 0x3 /* (abbrev code) */ ++ .uleb128 0xd /* (TAG: DW_TAG_member) */ ++ .byte 0 /* DW_children_no */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .uleb128 0x38 /* (DW_AT_data_member_location) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .byte 0 ++ .byte 0 ++ ++ .uleb128 0x4 /* (abbrev code) */ ++ .uleb128 0x34 /* (TAG: DW_TAG_variable) */ ++ .byte 0x0 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x02 /* (DW_AT_location) */ ++ .uleb128 0xa /* (DW_FORM_block1) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 0x5 /* (abbrev code) */ ++ .uleb128 0xf /* (TAG: DW_TAG_pointer_type) */ ++ .byte 0x0 /* DW_children_no */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x49 /* (DW_AT_type) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0x0 ++ .byte 0x0 ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 0x7 /* (abbrev code) */ ++ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */ ++ .byte 0 /* DW_children_no */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3e /* (DW_AT_encoding) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0 ++ .byte 0 ++ ++ .byte 0x0 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp +@@ -0,0 +1,37 @@ ++# Copyright 2011 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 . ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++set testfile "implptr-optimized-out" ++set srcfile ${testfile}.S ++set mainfile main.c ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/${executable} ++ ++if [prepare_for_testing ${testfile}.exp $executable "${srcfile} ${mainfile}" {}] { ++ return -1 ++} ++ ++# DW_OP_GNU_implicit_pointer implementation requires a valid frame. ++if ![runto_main] { ++ return -1 ++} ++ ++gdb_test "p p->f" " = " + diff --git a/gdb/patches/gdb-ppc-power7-test.patch b/gdb/patches/gdb-ppc-power7-test.patch new file mode 100644 index 000000000..4d4772a67 --- /dev/null +++ b/gdb/patches/gdb-ppc-power7-test.patch @@ -0,0 +1,295 @@ +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp +@@ -0,0 +1,182 @@ ++# Copyright 2009 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. ++ ++# Test PowerPC Power7 instructions disassembly. ++ ++if {![istarget "powerpc*-*-*"]} then { ++ verbose "Skipping PowerPC Power7 instructions disassembly." ++ return ++} ++ ++set testfile "powerpc-power7" ++set srcfile ${testfile}.s ++set objfile ${objdir}/${subdir}/${testfile}.o ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } { ++ untested "PowerPC Power7 instructions disassembly" ++ return -1 ++} ++ ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${objfile} ++ ++ ++# Disassemble the function. ++ ++set test "disass func" ++gdb_test_multiple $test $test { ++ -re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" { ++ set func $expect_out(1,string) ++ pass $test ++ } ++} ++ ++proc instr_to_patt {offset instr} { ++ # 0x0000000000000018 : stxvd2x vs43,r4,r5 ++ return ".*\r\n\[ \t\]*[string map {0x 0x0*} $offset] <(func)?\\+?\[0-9\]*>:\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" ++} ++ ++# KFAIL strings would not exist if -Many would print the same as -Mpower7. ++# That means the power7 form should be the preferred one. ++# http://sourceware.org/ml/gdb-patches/2009-03/threads.html#00020 ++ ++proc func_check {offset instr {kfail ""}} { ++ global func ++ ++ set test "Found $offset: $instr" ++ if [regexp -nocase -line [instr_to_patt $offset $instr] $func] { ++ pass $test ++ } elseif {$kfail != "" && [regexp -nocase -line [instr_to_patt $offset $kfail] $func]} { ++ kfail gdb/NNNN $test ++ } else { ++ fail $test ++ } ++} ++ ++func_check 0x0 "lxvd2x vs3,r4,r5" ++# [PATCH] Remove support for POWER7 VSX load/store with update instructions ++# http://sourceware.org/ml/binutils/2009-09/msg00680.html ++# http://sourceware.org/ml/binutils-cvs/2009-09/msg00331.html ++# lxvd2ux vs3,r4,r5 ++func_check 0x4 ".long 0x7c642ed8" ++func_check 0x8 "lxvd2x vs43,r4,r5" ++# lxvd2ux vs43,r4,r5 ++func_check 0xc ".long 0x7d642ed9" ++func_check 0x10 "stxvd2x vs3,r4,r5" ++# stxvd2ux vs3,r4,r5 ++func_check 0x14 ".long 0x7c642fd8" ++func_check 0x18 "stxvd2x vs43,r4,r5" ++# stxvd2ux vs43,r4,r5 ++func_check 0x1c ".long 0x7d642fd9" ++func_check 0x20 "xxmrghd vs3,vs4,vs5" ++func_check 0x24 "xxmrghd vs43,vs44,vs45" ++func_check 0x28 "xxmrgld vs3,vs4,vs5" ++func_check 0x2c "xxmrgld vs43,vs44,vs45" ++func_check 0x30 "xxmrghd vs3,vs4,vs5" ++func_check 0x34 "xxmrghd vs43,vs44,vs45" ++func_check 0x38 "xxmrgld vs3,vs4,vs5" ++func_check 0x3c "xxmrgld vs43,vs44,vs45" ++func_check 0x40 "xxpermdi vs3,vs4,vs5,1" ++func_check 0x44 "xxpermdi vs43,vs44,vs45,1" ++func_check 0x48 "xxpermdi vs3,vs4,vs5,2" ++func_check 0x4c "xxpermdi vs43,vs44,vs45,2" ++func_check 0x50 "xvmovdp vs3,vs4" ++func_check 0x54 "xvmovdp vs43,vs44" ++func_check 0x58 "xvmovdp vs3,vs4" ++func_check 0x5c "xvmovdp vs43,vs44" ++func_check 0x60 "xvcpsgndp vs3,vs4,vs5" ++func_check 0x64 "xvcpsgndp vs43,vs44,vs45" ++func_check 0x68 "wait" ++func_check 0x6c "wait" ++func_check 0x70 "waitrsv" ++func_check 0x74 "waitrsv" ++func_check 0x78 "waitimpl" ++func_check 0x7c "waitimpl" ++func_check 0x80 "doze" ++func_check 0x84 "nap" ++func_check 0x88 "sleep" ++func_check 0x8c "rvwinkle" ++func_check 0x90 "prtyw r3,r4" ++func_check 0x94 "prtyd r13,r14" ++func_check 0x98 "mfcfar r10" "mfspr r10,28" ++func_check 0x9c "mtcfar r11" "mtspr 28,r11" ++func_check 0xa0 "cmpb r3,r4,r5" ++func_check 0xa4 "lwzcix r10,r11,r12" ++func_check 0xa8 "dadd f16,f17,f18" ++func_check 0xac "daddq f20,f22,f24" ++func_check 0xb0 "dss 3" ++func_check 0xb4 "dssall" ++func_check 0xb8 "dst r5,r4,1" ++func_check 0xbc "dstt r8,r7,0" ++func_check 0xc0 "dstst r5,r6,3" ++func_check 0xc4 "dststt r4,r5,2" ++func_check 0xc8 "divwe r10,r11,r12" ++func_check 0xcc "divwe. r11,r12,r13" ++func_check 0xd0 "divweo r12,r13,r14" ++func_check 0xd4 "divweo. r13,r14,r15" ++func_check 0xd8 "divweu r10,r11,r12" ++func_check 0xdc "divweu. r11,r12,r13" ++func_check 0xe0 "divweuo r12,r13,r14" ++func_check 0xe4 "divweuo. r13,r14,r15" ++func_check 0xe8 "bpermd r7,r17,r27" ++func_check 0xec "popcntw r10,r20" ++func_check 0xf0 "popcntd r10,r20" ++func_check 0xf4 "ldbrx r20,r21,r22" ++func_check 0xf8 "stdbrx r20,r21,r22" ++func_check 0xfc "lfiwzx f10,0,r10" ++func_check 0x100 "lfiwzx f10,r9,r10" ++func_check 0x104 "fcfids f4,f5" ++func_check 0x108 "fcfids. f4,f5" ++func_check 0x10c "fcfidus f4,f5" ++func_check 0x110 "fcfidus. f4,f5" ++func_check 0x114 "fctiwu f4,f5" ++func_check 0x118 "fctiwu. f4,f5" ++func_check 0x11c "fctiwuz f4,f5" ++func_check 0x120 "fctiwuz. f4,f5" ++func_check 0x124 "fctidu f4,f5" ++func_check 0x128 "fctidu. f4,f5" ++func_check 0x12c "fctiduz f4,f5" ++func_check 0x130 "fctiduz. f4,f5" ++func_check 0x134 "fcfidu f4,f5" ++func_check 0x138 "fcfidu. f4,f5" ++func_check 0x13c "ftdiv cr0,f10,f11" ++func_check 0x140 "ftdiv cr7,f10,f11" ++func_check 0x144 "ftsqrt cr0,f10" ++func_check 0x148 "ftsqrt cr7,f10" ++func_check 0x14c "dcbtt r8,r9" "dcbt 16,r8,r9" ++func_check 0x150 "dcbtstt r8,r9" "dcbtst 16,r8,r9" ++func_check 0x154 "dcffix f10,f12" ++func_check 0x158 "dcffix. f20,f22" ++func_check 0x15c "lbarx r10,r11,r12" ++func_check 0x160 "lbarx r10,r11,r12" ++func_check 0x164 "lbarx r10,r11,r12,1" ++func_check 0x168 "lharx r20,r21,r22" ++func_check 0x16c "lharx r20,r21,r22" ++func_check 0x170 "lharx r20,r21,r22,1" ++func_check 0x174 "stbcx. r10,r11,r12" ++func_check 0x178 "sthcx. r10,r11,r12" ++func_check 0x17c "fre f14,f15" ++func_check 0x180 "fre. f14,f15" ++func_check 0x184 "fres f14,f15" ++func_check 0x188 "fres. f14,f15" ++func_check 0x18c "frsqrte f14,f15" ++func_check 0x190 "frsqrte. f14,f15" ++func_check 0x194 "frsqrtes f14,f15" ++func_check 0x198 "frsqrtes. f14,f15" ++func_check 0x19c "isel r2,r3,r4,28" +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7.s +@@ -0,0 +1,107 @@ ++ .text ++ .globl func ++func: ++ .long 0x7c642e98 /* 0: lxvd2x vs3,r4,r5 */ ++ .long 0x7c642ed8 /* 4: lxvd2ux vs3,r4,r5 */ ++ .long 0x7d642e99 /* 8: lxvd2x vs43,r4,r5 */ ++ .long 0x7d642ed9 /* c: lxvd2ux vs43,r4,r5 */ ++ .long 0x7c642f98 /* 10: stxvd2x vs3,r4,r5 */ ++ .long 0x7c642fd8 /* 14: stxvd2ux vs3,r4,r5 */ ++ .long 0x7d642f99 /* 18: stxvd2x vs43,r4,r5 */ ++ .long 0x7d642fd9 /* 1c: stxvd2ux vs43,r4,r5 */ ++ .long 0xf0642850 /* 20: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 24: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 28: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 2c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642850 /* 30: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 34: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 38: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 3c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642950 /* 40: xxpermdi vs3,vs4,vs5,1 */ ++ .long 0xf16c6957 /* 44: xxpermdi vs43,vs44,vs45,1 */ ++ .long 0xf0642a50 /* 48: xxpermdi vs3,vs4,vs5,2 */ ++ .long 0xf16c6a57 /* 4c: xxpermdi vs43,vs44,vs45,2 */ ++ .long 0xf0642780 /* 50: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 54: xvmovdp vs43,vs44 */ ++ .long 0xf0642780 /* 58: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 5c: xvmovdp vs43,vs44 */ ++ .long 0xf0642f80 /* 60: xvcpsgndp vs3,vs4,vs5 */ ++ .long 0xf16c6f87 /* 64: xvcpsgndp vs43,vs44,vs45 */ ++ .long 0x7c00007c /* 68: wait */ ++ .long 0x7c00007c /* 6c: wait */ ++ .long 0x7c20007c /* 70: waitrsv */ ++ .long 0x7c20007c /* 74: waitrsv */ ++ .long 0x7c40007c /* 78: waitimpl */ ++ .long 0x7c40007c /* 7c: waitimpl */ ++ .long 0x4c000324 /* 80: doze */ ++ .long 0x4c000364 /* 84: nap */ ++ .long 0x4c0003a4 /* 88: sleep */ ++ .long 0x4c0003e4 /* 8c: rvwinkle */ ++ .long 0x7c830134 /* 90: prtyw r3,r4 */ ++ .long 0x7dcd0174 /* 94: prtyd r13,r14 */ ++ .long 0x7d5c02a6 /* 98: mfcfar r10 */ ++ .long 0x7d7c03a6 /* 9c: mtcfar r11 */ ++ .long 0x7c832bf8 /* a0: cmpb r3,r4,r5 */ ++ .long 0x7d4b662a /* a4: lwzcix r10,r11,r12 */ ++ .long 0xee119004 /* a8: dadd f16,f17,f18 */ ++ .long 0xfe96c004 /* ac: daddq f20,f22,f24 */ ++ .long 0x7c60066c /* b0: dss 3 */ ++ .long 0x7e00066c /* b4: dssall */ ++ .long 0x7c2522ac /* b8: dst r5,r4,1 */ ++ .long 0x7e083aac /* bc: dstt r8,r7,0 */ ++ .long 0x7c6532ec /* c0: dstst r5,r6,3 */ ++ .long 0x7e442aec /* c4: dststt r4,r5,2 */ ++ .long 0x7d4b6356 /* c8: divwe r10,r11,r12 */ ++ .long 0x7d6c6b57 /* cc: divwe. r11,r12,r13 */ ++ .long 0x7d8d7756 /* d0: divweo r12,r13,r14 */ ++ .long 0x7dae7f57 /* d4: divweo. r13,r14,r15 */ ++ .long 0x7d4b6316 /* d8: divweu r10,r11,r12 */ ++ .long 0x7d6c6b17 /* dc: divweu. r11,r12,r13 */ ++ .long 0x7d8d7716 /* e0: divweuo r12,r13,r14 */ ++ .long 0x7dae7f17 /* e4: divweuo. r13,r14,r15 */ ++ .long 0x7e27d9f8 /* e8: bpermd r7,r17,r27 */ ++ .long 0x7e8a02f4 /* ec: popcntw r10,r20 */ ++ .long 0x7e8a03f4 /* f0: popcntd r10,r20 */ ++ .long 0x7e95b428 /* f4: ldbrx r20,r21,r22 */ ++ .long 0x7e95b528 /* f8: stdbrx r20,r21,r22 */ ++ .long 0x7d4056ee /* fc: lfiwzx f10,0,r10 */ ++ .long 0x7d4956ee /* 100: lfiwzx f10,r9,r10 */ ++ .long 0xec802e9c /* 104: fcfids f4,f5 */ ++ .long 0xec802e9d /* 108: fcfids. f4,f5 */ ++ .long 0xec802f9c /* 10c: fcfidus f4,f5 */ ++ .long 0xec802f9d /* 110: fcfidus. f4,f5 */ ++ .long 0xfc80291c /* 114: fctiwu f4,f5 */ ++ .long 0xfc80291d /* 118: fctiwu. f4,f5 */ ++ .long 0xfc80291e /* 11c: fctiwuz f4,f5 */ ++ .long 0xfc80291f /* 120: fctiwuz. f4,f5 */ ++ .long 0xfc802f5c /* 124: fctidu f4,f5 */ ++ .long 0xfc802f5d /* 128: fctidu. f4,f5 */ ++ .long 0xfc802f5e /* 12c: fctiduz f4,f5 */ ++ .long 0xfc802f5f /* 130: fctiduz. f4,f5 */ ++ .long 0xfc802f9c /* 134: fcfidu f4,f5 */ ++ .long 0xfc802f9d /* 138: fcfidu. f4,f5 */ ++ .long 0xfc0a5900 /* 13c: ftdiv cr0,f10,f11 */ ++ .long 0xff8a5900 /* 140: ftdiv cr7,f10,f11 */ ++ .long 0xfc005140 /* 144: ftsqrt cr0,f10 */ ++ .long 0xff805140 /* 148: ftsqrt cr7,f10 */ ++ .long 0x7e084a2c /* 14c: dcbtt r8,r9 */ ++ .long 0x7e0849ec /* 150: dcbtstt r8,r9 */ ++ .long 0xed406644 /* 154: dcffix f10,f12 */ ++ .long 0xee80b645 /* 158: dcffix. f20,f22 */ ++ .long 0x7d4b6068 /* 15c: lbarx r10,r11,r12 */ ++ .long 0x7d4b6068 /* 160: lbarx r10,r11,r12 */ ++ .long 0x7d4b6069 /* 164: lbarx r10,r11,r12,1 */ ++ .long 0x7e95b0e8 /* 168: lharx r20,r21,r22 */ ++ .long 0x7e95b0e8 /* 16c: lharx r20,r21,r22 */ ++ .long 0x7e95b0e9 /* 170: lharx r20,r21,r22,1 */ ++ .long 0x7d4b656d /* 174: stbcx. r10,r11,r12 */ ++ .long 0x7d4b65ad /* 178: sthcx. r10,r11,r12 */ ++ .long 0xfdc07830 /* 17c: fre f14,f15 */ ++ .long 0xfdc07831 /* 180: fre. f14,f15 */ ++ .long 0xedc07830 /* 184: fres f14,f15 */ ++ .long 0xedc07831 /* 188: fres. f14,f15 */ ++ .long 0xfdc07834 /* 18c: frsqrte f14,f15 */ ++ .long 0xfdc07835 /* 190: frsqrte. f14,f15 */ ++ .long 0xedc07834 /* 194: frsqrtes f14,f15 */ ++ .long 0xedc07835 /* 198: frsqrtes. f14,f15 */ ++ .long 0x7c43271e /* 19c: isel r2,r3,r4,28 */ diff --git a/gdb/patches/gdb-runtest-pie-override.patch b/gdb/patches/gdb-runtest-pie-override.patch new file mode 100644 index 000000000..dc5449497 --- /dev/null +++ b/gdb/patches/gdb-runtest-pie-override.patch @@ -0,0 +1,40 @@ +make check//unix/-fPIE/-pie RUNTESTFLAGS=solib-display.exp + +gcc -fpic -c -fPIE -pie -o x.o x.c +/usr/lib/gcc/x86_64-redhat-linux/4.6.1/../../../../lib64/Scrt1.o: In function `_start': +(.text+0x20): undefined reference to `main' + +=> Change the order for overrides. + +One has to also use -fPIC rather than -fPIE, -fPIC is stronger. + +The correct way would be: +make check//unix RUNTESTFLAGS='CC_FOR_TARGET=gcc\ -fPIC\ -pie CXX_FOR_TARGET=g++\ -fPIC\ -pie solib-display.exp' + +But there is a problem with testsuite.unix non-unique subdir name and also +a problem with make -j parallelization of the testsuite. + +--- gdb-7.3.50.20110722/gdb/testsuite/lib/future.exp 2011-10-11 16:44:05.000000000 +0200 ++++ gdb-7.3.50.20110722/gdb/testsuite/lib/future.exp2 2011-10-11 16:44:10.000000000 +0200 +@@ -77,6 +77,10 @@ proc gdb_default_target_compile {source + set ldflags "" + set dest [target_info name] + ++ if {[board_info $dest exists multilib_flags]} { ++ append add_flags " [board_info $dest multilib_flags]" ++ } ++ + if {[info exists CFLAGS_FOR_TARGET]} { + append add_flags " $CFLAGS_FOR_TARGET" + } +@@ -333,10 +337,6 @@ proc gdb_default_target_compile {source + } + } + +- if {[board_info $dest exists multilib_flags]} { +- append add_flags " [board_info $dest multilib_flags]" +- } +- + verbose "doing compile" + + set sources "" diff --git a/gdb/patches/gdb-simultaneous-step-resume-breakpoint-test.patch b/gdb/patches/gdb-simultaneous-step-resume-breakpoint-test.patch new file mode 100644 index 000000000..e6e53bbd1 --- /dev/null +++ b/gdb/patches/gdb-simultaneous-step-resume-breakpoint-test.patch @@ -0,0 +1,150 @@ +--- /dev/null 2009-09-25 12:44:54.497650251 +0200 ++++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp 2009-09-25 17:27:12.000000000 +0200 +@@ -0,0 +1,65 @@ ++# Copyright (C) 2009 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 . */ ++ ++# Test multiple threads stepping into a .debug_line-less function with ++# a breakpoint placed on its return-to-caller point. ++ ++set testfile simultaneous-step-resume-breakpoint ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++# Ensure we have no debuginfo for the `sleep' call itself (=for libc). ++gdb_test "set debug-file-directory /DoesNotExist" ++ ++gdb_load ${binfile} ++if ![runto_main] { ++ return -1 ++} ++ ++# Red Hat vendor patch does set it to "step" by default. ++gdb_test "set scheduler-locking off" ++ ++gdb_breakpoint [gdb_get_line_number "final-exit"] ++ ++gdb_breakpoint [gdb_get_line_number "sleep-call"] ++gdb_continue_to_breakpoint "sleep-call" ++ ++gdb_test "step" "sleep-call.*" "step thread 1" ++gdb_test "step" "sleep-call.*" "step thread 2" ++gdb_test "step" "sleep-after.*" "step thread 3" ++ ++set test "first continue" ++gdb_test_multiple "continue" $test { ++ -re "final-exit.*$gdb_prompt $" { ++ # gdb-7.0. ++ pass $test ++ return ++ } ++ -re "sleep-after.*$gdb_prompt $" { ++ # Fedora/RHEL branch. ++ pass $test ++ } ++} ++ ++gdb_test "continue" "sleep-after.*" "second continue" ++gdb_test "continue" "final-exit.*" "third continue" +--- /dev/null 2009-09-25 12:44:54.497650251 +0200 ++++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c 2009-09-25 17:29:42.000000000 +0200 +@@ -0,0 +1,79 @@ ++/* Copyright 2009 Free Software Foundation, Inc. ++ ++ Written by Fred Fish of Cygnus Support ++ Contributed by Cygnus Support ++ ++ 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 . */ ++ ++/* Test multiple threads stepping into a .debug_line-less function with ++ a breakpoint placed on its return-to-caller point. */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define THREADS 3 ++ ++static void * ++func (void *unused) ++{ ++ int i; ++ ++ errno = 0; ++ i = 0xdeadf00d; ++ i = sleep (THREADS); /* sleep-call */ ++ if (errno != 0) /* sleep-after */ ++ perror ("sleep"); ++ ++ /* The GDB bug with forgotten step-resume breakpoint could leave stale ++ breakpoint on the I assignment making it a nop. */ ++ if (i == 0xdeadf00d) ++ assert (0); ++ ++ assert (i == 0); ++ ++ pthread_exit (NULL); ++} ++ ++int ++main (void) ++{ ++ pthread_t threads[THREADS]; ++ int threadi; ++ ++ for (threadi = 0; threadi < THREADS; threadi++) ++ { ++ int i; ++ ++ i = pthread_create (&threads[threadi], NULL, func, NULL); ++ assert (i == 0); ++ ++ i = sleep (1); ++ assert (i == 0); ++ } ++ ++ for (threadi = 0; threadi < THREADS; threadi++) ++ { ++ int i; ++ ++ i = pthread_join (threads[threadi], NULL); ++ assert (i == 0); ++ } ++ ++ return 0; /* final-exit */ ++} diff --git a/gdb/patches/gdb-test-bt-cfi-without-die.patch b/gdb/patches/gdb-test-bt-cfi-without-die.patch new file mode 100644 index 000000000..5f1f967a5 --- /dev/null +++ b/gdb/patches/gdb-test-bt-cfi-without-die.patch @@ -0,0 +1,220 @@ +http://sourceware.org/ml/archer/2010-q3/msg00028.html +Subject: [delayed-symfile] [commit] Fix a regression on CFI without DIE [Re: + +On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote: +> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5 +> +> There was a regression on gdb.base/savedregs.exp. +> +> quick_addrmap/require_partial_symbols should be used even for the unwind debug +> info checking as its load has been also delayed by this branch. +[...] +> --- a/gdb/dwarf2-frame.c +> +++ b/gdb/dwarf2-frame.c +[...] +> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) +> struct dwarf2_fde *fde; +> CORE_ADDR offset; +> +> + if (objfile->quick_addrmap) +> + { +> + if (!addrmap_find (objfile->quick_addrmap, *pc)) +> + continue; +> + } +> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */ +> + require_partial_symbols (objfile); +> + + +but this has caused a different regression (as discussed in the confcall). + +QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing +built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have +DWARF at all while they can feature CFIs (.eh_frame or .debug_frame). +It has been described by Daniel Jacobowitz at: + Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs + http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html + +Sorry for this regression by me (in that fix of a different regression). + +Fixed it the "slow way" as this branch is now obsoleted by .gdb-index. + +No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. + +Checked-in. + + +Thanks, +Jan + + +eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb + +Test CFI is parsed even for range (function) not described by any DIE. + +https://bugzilla.redhat.com/show_bug.cgi?id=614028 + +gdb/ + * dwarf2-frame.c (dwarf2_frame_find_fde): Remove the + OBJFILE->QUICK_ADDRMAP check. New comment why. + +gdb/testsuite/ + * gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c, + gdb.base/cfi-without-die-caller.c: New files. +--- + gdb/dwarf2-frame.c | 8 +-- + gdb/testsuite/gdb.base/cfi-without-die-caller.c | 28 ++++++++++ + gdb/testsuite/gdb.base/cfi-without-die-main.c | 32 +++++++++++ + gdb/testsuite/gdb.base/cfi-without-die.exp | 67 +++++++++++++++++++++++ + 4 files changed, 130 insertions(+), 5 deletions(-) + create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-caller.c + create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-main.c + create mode 100644 gdb/testsuite/gdb.base/cfi-without-die.exp + +diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c +new file mode 100644 +index 0000000..afdfd53 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c +@@ -0,0 +1,28 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007, 2008, 2009, 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 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 . */ ++ ++typedef int (*callback_t) (void); ++ ++int ++caller (callback_t callback) ++{ ++ /* Ensure some frame content to push away the return address. */ ++ volatile const long one = 1; ++ ++ /* Modify the return value to prevent any tail-call optimization. */ ++ return (*callback) () - one; ++} +diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c +new file mode 100644 +index 0000000..8451c4b +--- /dev/null ++++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c +@@ -0,0 +1,32 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007, 2008, 2009, 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 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 . */ ++ ++typedef int (*callback_t) (void); ++ ++extern int caller (callback_t callback); ++ ++int ++callback (void) ++{ ++ return 1; ++} ++ ++int ++main (void) ++{ ++ return caller (callback); ++} +diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp +new file mode 100644 +index 0000000..db6d248 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/cfi-without-die.exp +@@ -0,0 +1,67 @@ ++# 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 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 . ++ ++# Test CFI is parsed even for range (function) not described by any DIE. ++ ++set testfile cfi-without-die ++set srcmainfile ${testfile}-main.c ++set srccallerfile ${testfile}-caller.c ++set executable ${testfile} ++set objmainfile ${objdir}/${subdir}/${testfile}-main.o ++set objcallerfile ${objdir}/${subdir}/${testfile}-caller.o ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \ ++ object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != "" ++ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != "" ++ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++if ![runto callback] then { ++ fail "verify unwinding: Can't run to callback" ++ return 0 ++} ++set test "verify unwinding breaks without CFI" ++gdb_test_multiple "bt" $test { ++ -re " in main .*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \ ++ object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != "" ++ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != "" ++ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++if ![runto callback] then { ++ fail "test CFI without DIEs: Can't run to callback" ++ return 0 ++} ++# #0 callback () at ... ++# #1 0x00000000004004e9 in caller () ++# #2 0x00000000004004cd in main () at ... ++gdb_test "bt" "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 \[^\r\n\]+ in main \[^\r\n\]+" "verify unwindin works for CFI without DIEs" +-- +1.7.1.1 + diff --git a/gdb/patches/gdb-test-dw2-aranges.patch b/gdb/patches/gdb-test-dw2-aranges.patch new file mode 100644 index 000000000..5ddcf9d96 --- /dev/null +++ b/gdb/patches/gdb-test-dw2-aranges.patch @@ -0,0 +1,214 @@ +[archer-tromey-delayed-symfile] + +commit 77fa7778a37b0d28a7e4e5235f074a10ecf1815d +Author: Jan Kratochvil +Date: Sat Aug 15 15:05:54 2009 +0200 + + Test for "handle incorrect aranges". + + readelf: + Contents of the .debug_aranges section: + + Length: 8 + Version: 2 + Offset into .debug_info: 0x0 + Pointer Size: 0 + Segment Size: 0 + + Address Length + Floating point exception + + * gdb.dwarf2/dw2-aranges.exp, gdb.dwarf2/dw2-aranges.S: New files. + +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S +new file mode 100644 +index 0000000..d5b9ca5a +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S +@@ -0,0 +1,140 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2004, 2007, 2008, 2009 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 . */ ++ ++/* Test .debug_aranges containing zero address_size. */ ++ ++/* Dummy function to provide debug information for. */ ++ ++ .text ++.Lbegin_text1: ++ .globl main ++ .type main, %function ++main: ++.Lbegin_main: ++ .int 0 ++.Lend_main: ++ .size main, .-main ++.Lend_text1: ++ ++/* Debug information */ ++ ++ .section .debug_info ++.Lcu1_begin: ++ /* CU header */ ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF Version */ ++ .4byte .Labbrev1_begin /* Offset into abbrev section */ ++ .byte 4 /* Pointer size */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lend_text1 /* DW_AT_high_pc */ ++ .4byte .Lbegin_text1 /* DW_AT_low_pc */ ++ .ascii "file1.txt\0" /* DW_AT_name */ ++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ ++ .byte 1 /* DW_AT_language (C) */ ++ ++ /* main */ ++ .uleb128 2 /* Abbrev: DW_TAG_subprogram */ ++ .byte 1 /* DW_AT_external */ ++ .byte 1 /* DW_AT_decl_file */ ++ .byte 2 /* DW_AT_decl_line */ ++ .ascii "main\0" /* DW_AT_name */ ++ .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Lbegin_main /* DW_AT_low_pc */ ++ .4byte .Lend_main /* DW_AT_high_pc */ ++ .byte 1 /* DW_AT_frame_base: length */ ++ .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */ ++ ++.Ltype_int: ++ .uleb128 3 /* Abbrev: DW_TAG_base_type */ ++ .ascii "int\0" /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 5 /* DW_AT_encoding */ ++ ++ .byte 0 /* End of children of CU */ ++ ++.Lcu1_end: ++ ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3a /* DW_AT_decl_file */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3b /* DW_AT_decl_line */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x40 /* DW_AT_frame_base */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++/* aranges table */ ++ .section .debug_aranges ++ .long .Laranges_end - 1f ++1: ++ .2byte 2 /* aranges Version */ ++ .4byte .Lcu1_begin - .debug_info /* Offset into .debug_info section */ ++ /* The GDB crasher is this zero value. */ ++ .byte 0 /* aranges address_size */ ++ .byte 0 /* aranges segment_size */ ++ ++.Laranges_end: +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp +new file mode 100644 +index 0000000..39632d5 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp +@@ -0,0 +1,40 @@ ++# Copyright 2004, 2005, 2007, 2008, 2009 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 . ++ ++# Test .debug_aranges containing zero address_size. ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-aranges" ++set srcfile ${testfile}.S ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } { ++ return -1 ++} ++ ++clean_restart $testfile ++ ++# Failed gdb_load would abort the testcase execution earlier. ++pass "file loaded" diff --git a/gdb/patches/gdb-test-expr-cumulative-archer.patch b/gdb/patches/gdb-test-expr-cumulative-archer.patch new file mode 100644 index 000000000..232a52780 --- /dev/null +++ b/gdb/patches/gdb-test-expr-cumulative-archer.patch @@ -0,0 +1,207 @@ +archer archer-keiths-expr-cumulative +b5a7497340b24199f0c7ba7fdf0d54d4df44d6bc + +--- /dev/null 2011-01-12 06:28:36.282000001 +0100 ++++ ./gdb/testsuite/gdb.cp/namespace-nested-imports.cc 2009-09-25 06:50:38.000000000 +0200 +@@ -0,0 +1,36 @@ ++namespace A ++{ ++ namespace B ++ { ++ int ab = 11; ++ } ++} ++ ++namespace C ++{ ++ namespace D ++ { ++ using namespace A::B; ++ ++ int ++ second() ++ { ++ ab; ++ return 0; ++ } ++ } ++ ++ int ++ first() ++ { ++ //ab; ++ return D::second(); ++ } ++} ++ ++int ++main() ++{ ++ //ab; ++ return C::first(); ++} +--- /dev/null 2011-01-12 06:28:36.282000001 +0100 ++++ ./gdb/testsuite/gdb.cp/namespace-nested-imports.exp 2009-09-25 06:50:38.000000000 +0200 +@@ -0,0 +1,50 @@ ++# 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 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 . ++ ++set testfile namespace-nested-imports ++set srcfile ${testfile}.cc ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++# Get things started. ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++############################################ ++if ![runto_main] then { ++ perror "couldn't run to breakpoint main" ++ continue ++} ++ ++gdb_test "print ab" "No symbol .* in current context." ++ ++############################################ ++gdb_breakpoint C::first ++gdb_continue_to_breakpoint "C::first" ++ ++gdb_test "print ab" "No symbol .* in current context." ++gdb_test "print C::D::ab" "= 11" ++ ++############################################ ++gdb_breakpoint C::D::second ++gdb_continue_to_breakpoint "C::D::second" ++ ++gdb_test "print ab" "= 11" +--- /dev/null 2011-01-12 06:28:36.282000001 +0100 ++++ ./gdb/testsuite/gdb.cp/namespace-no-imports.cc 2009-09-25 06:50:38.000000000 +0200 +@@ -0,0 +1,37 @@ ++ ++namespace A ++{ ++ int _a = 11; ++ ++ namespace B{ ++ ++ int ab = 22; ++ ++ namespace C{ ++ ++ int abc = 33; ++ ++ int second(){ ++ return 0; ++ } ++ ++ } ++ ++ int first(){ ++ _a; ++ ab; ++ C::abc; ++ return C::second(); ++ } ++ } ++} ++ ++ ++int ++main() ++{ ++ A::_a; ++ A::B::ab; ++ A::B::C::abc; ++ return A::B::first(); ++} +--- /dev/null 2011-01-12 06:28:36.282000001 +0100 ++++ ./gdb/testsuite/gdb.cp/namespace-no-imports.exp 2009-09-25 06:50:38.000000000 +0200 +@@ -0,0 +1,69 @@ ++# 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 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 . ++ ++set testfile namespace-no-imports ++set srcfile ${testfile}.cc ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++# Get things started. ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++############################################ ++if ![runto_main] then { ++ perror "couldn't run to breakpoint main" ++ continue ++} ++ ++gdb_test "print A::_a" "= 11" ++gdb_test "print A::B::ab" "= 22" ++gdb_test "print A::B::C::abc" "= 33" ++ ++gdb_test "print _a" "No symbol .* in current context." ++gdb_test "print ab" "No symbol .* in current context." ++gdb_test "print abc" "No symbol .* in current context." ++ ++############################################ ++gdb_breakpoint A::B::first ++gdb_continue_to_breakpoint "A::B::first" ++ ++gdb_test "print A::_a" "= 11" ++gdb_test "print A::B::ab" "= 22" ++gdb_test "print A::B::C::abc" "= 33" ++ ++gdb_test "print _a" "= 11" ++gdb_test "print ab" "= 22" ++gdb_test "print C::abc" "= 33" ++ ++gdb_test "print abc" "No symbol .* in current context." ++ ++############################################ ++gdb_breakpoint A::B::C::second ++gdb_continue_to_breakpoint "A::B::C::second" ++ ++gdb_test "print A::_a" "= 11" ++gdb_test "print A::B::ab" "= 22" ++gdb_test "print A::B::C::abc" "= 33" ++ ++gdb_test "print _a" "= 11" ++gdb_test "print ab" "= 22" ++gdb_test "print abc" "= 33" diff --git a/gdb/patches/gdb-test-pid0-core.patch b/gdb/patches/gdb-test-pid0-core.patch new file mode 100644 index 000000000..1bc221bef --- /dev/null +++ b/gdb/patches/gdb-test-pid0-core.patch @@ -0,0 +1,80 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=611435 + +Fix: +Re: [RFA]corelow.c: Add tid to add_to_thread_list +http://sourceware.org/ml/gdb-patches/2010-08/msg00085.html +http://sourceware.org/ml/gdb-cvs/2010-08/msg00026.html +2e5bcfdef1ec3883d48c3f87a4be5c0dff25e17e + +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.core.bz2.uu +@@ -0,0 +1,20 @@ ++begin 600 x86_64-pid0-core.core.bz2 ++M0EIH.3%!629362,CA>P!$/'_____^*#EZ-A!SP36P&_:G0#=14``04A&8,'U ++M2*9`>$$)P`*RN"#*;#4R()IJ8C$TT&FC3$&@`T`#:C1H8C0T,@,FC,D"4T2! ++M"/2CU'B90]31ZAD#U`&AZF@/4:``!HT&F@!H<`#0-`-#0``#3$-&F@```#0R ++M``#")2FD]2>4]0TTT-!HTT--,0,"#$`R!I@AD`#1H,3&GZT.4TO$#H40/`0C ++M2$IRXS,<55!8T,&&,R.Z441"?J9I%G6GUA2!.[]Z"C5S[&19,%VS7E6[3"60 ++M@`-*2G)QEQ(;?0Y<=MK]/U?Q)LB%+F37TJ9BI*46)H'*Z@V"`"$"P7]&XZ:JE0E<*:#1M$P3G]>VCI)(A!O$64`5$4`E$$-.``7&(09`8HO`B6K!Q^& ++M562%N)2+0@*HB@%D@5$%!*0!L1&0D4D6\:-$A`)`+<6D82PP*H(J(H!?F;0$ ++M%PXB7N!2D4!44`W7"ADEQM6O9TBO5,_]1) ++M($Q2))#),UE,QQK)E$,3D\W.>!4)QO8A_@^Z_SXS4;Q8=HV6[:&$@2$@$R29IBW)K%3"O` ++M9^Y0YJ&BXY1U2HTZ5)2H-V\_(.DZHWE+C#WS($(!I"3CUH2#(+(OWUV"*<<9 ++MJ%A!J[%O.P&V%GI.`L7<1@0>,^1F\MY=V5UT,&NOG%7TTZ[03!@BHB@&)P` ++` ++end +--- /dev/null ++++ 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. ++ ++# Some kernel core files have PID 0 - for the idle task. ++ ++if ![istarget "x86_64-*-*"] { ++ verbose "Skipping x86_64-pid0-core test." ++ return ++} ++ ++set testfile "x86_64-pid0-core" ++set corebz2uufile ${srcdir}/${subdir}/${testfile}.core.bz2.uu ++set corefile ${objdir}/${subdir}/${testfile}.core ++ ++if {[catch "system \"uudecode -o - ${corebz2uufile} | bzip2 -dc >${corefile}\""] != 0} { ++ untested "failed uudecode or bzip2" ++ return -1 ++} ++file stat ${corefile} corestat ++if {$corestat(size) != 8798208} { ++ untested "uudecode or bzip2 produce invalid result" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++# Former crash was: ++# thread.c:884: internal-error: switch_to_thread: Assertion `inf != NULL' failed. ++gdb_test "core-file ${corefile}" "Program terminated with signal 11, Segmentation fault\\.\r\n.*" diff --git a/gdb/patches/gdb-tui-strip-stepi.patch b/gdb/patches/gdb-tui-strip-stepi.patch new file mode 100644 index 000000000..c4bdcb0ba --- /dev/null +++ b/gdb/patches/gdb-tui-strip-stepi.patch @@ -0,0 +1,73 @@ +http://sourceware.org/ml/gdb-patches/2011-08/msg00283.html +Subject: [patch] TUI: Permit stepi on stripped code + +Hi, + +nick on #gdb@freenode complained one cannot stepi on stripped binary. + +echo -e '#include\nint main(void){return alarm(0);}'|gcc -Wall -s -x c -;./gdbtui ./a.out -nx -ex 'layout asm' -ex 'b alarm' -ex r -ex fini +will: + 0x7ffff7ae25c0 mov $0x25,%eax + ------------------------------------------------- + (gdb) p/x $pc + $1 = 0x4004d2 + (gdb) stepi + No function contains program counter for selected frame. + (gdb) p/x $pc + $2 = 0x4004d2 + +That is the window still displays stale content, stepi does not work at all. + +#0 throw_verror (error=GENERIC_ERROR, fmt=0xe73d20 "No function contains program counter for selected frame.", ap=0x7fffdbd3b0a8) at exceptions.c:400 +#1 in error (string=0xe73d20 "No function contains program counter for selected frame.") at utils.c:780 +#2 in tui_show_frame_info (fi=0x3eca1e0) at ./tui/tui-stack.c:383 +#3 in tui_selected_frame_level_changed_hook (level=0) at ./tui/tui-hooks.c:218 +#4 in select_frame (fi=0x3eca1e0) at frame.c:1396 +#5 in restore_selected_frame (a_frame_id=..., frame_level=0) at thread.c:1049 +#6 in do_restore_current_thread_cleanup (arg=0x456dca0) at thread.c:1116 +#7 in do_my_cleanups (pmy_chain=0x1c865f0, old_chain=0x456de90) at utils.c:515 +#8 in do_cleanups (old_chain=0x456de90) at utils.c:497 +#9 in insert_breakpoint_locations () at breakpoint.c:2021 +#10 in insert_breakpoints () at breakpoint.c:1919 +#11 in proceed (addr=18446744073709551615, siggnal=TARGET_SIGNAL_DEFAULT, step=1) at infrun.c:2156 +#12 in step_once (skip_subroutines=0, single_inst=1, count=1, thread=-1) at infcmd.c:1068 +#13 in step_1 (skip_subroutines=0, single_inst=1, count_string=0x0) at infcmd.c:903 +#14 in stepi_command (count_string=0x0, from_tty=1) at infcmd.c:839 + +With the fix stepi works and the window correctly displays: + 0x4004d2 pop %rbp + ------------------------------------------------- + +I haven't found any TUI testsuite. + +I will check it in (after regression testing(?)) in some time. + + +Thanks, +Jan + + +gdb/ +2011-08-14 Jan Kratochvil + + Fix TUI stepi on code without symbols. + * tui/tui-stack.c (tui_show_frame_info): Remove error, set LOW for + current PC instead. + +--- a/gdb/tui/tui-stack.c ++++ b/gdb/tui/tui-stack.c +@@ -380,8 +380,11 @@ tui_show_frame_info (struct frame_info *fi) + { + if (find_pc_partial_function (get_frame_pc (fi), (char **) NULL, + &low, (CORE_ADDR) 0) == 0) +- error (_("No function contains program " +- "counter for selected frame.")); ++ { ++ /* There is no symbol available for current PC. There is no ++ safe way how to "disassemble backwards". */ ++ low = get_frame_pc (fi); ++ } + else + low = tui_get_low_disassembly_address (get_frame_arch (fi), + low, get_frame_pc (fi)); + diff --git a/gdb/patches/gdb-unused-revert.patch b/gdb/patches/gdb-unused-revert.patch new file mode 100644 index 000000000..2abe3cf69 --- /dev/null +++ b/gdb/patches/gdb-unused-revert.patch @@ -0,0 +1,44 @@ +[RFA/commit 5/5] Add -Wunused-function to compile flags. +http://sourceware.org/ml/gdb-patches/2010-01/msg00371.html +http://sourceware.org/ml/gdb-cvs/2010-01/msg00163.html + +REVERTED + +--- src/gdb/configure.ac 2010/01/15 00:34:37 1.112 ++++ src/gdb/configure.ac 2010/01/19 09:52:31 1.113 +@@ -1544,8 +1544,7 @@ + # gdb/doc/gdbint.texinfo. + build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ + -Wformat-nonliteral -Wno-pointer-sign \ +--Wno-unused -Wunused-value -Wunused-function \ +--Wno-switch -Wno-char-subscripts" ++-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" + + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. +--- src/gdb/configure 2010/01/15 00:34:37 1.297 ++++ src/gdb/configure 2010/01/19 09:52:32 1.298 +@@ -13435,8 +13435,7 @@ + # gdb/doc/gdbint.texinfo. + build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ + -Wformat-nonliteral -Wno-pointer-sign \ +--Wno-unused -Wunused-value -Wunused-function \ +--Wno-switch -Wno-char-subscripts" ++-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" + + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. +### src/gdb/ChangeLog 2010/01/19 09:50:48 1.11271 +### src/gdb/ChangeLog 2010/01/19 09:52:33 1.11272 +## -1,11 +1,5 @@ + 2010-01-19 Joel Brobecker + +- Add -Wunused-function to compile flags. +- * configure.ac: Add -Wunused-function to build_warnings. +- * configure: Regenerate. +- +-2010-01-19 Joel Brobecker +- + "delete" ada-lex.c:input function, not used. + * ada-lex.l: #define YY_NO_INPUT. + diff --git a/gdb/patches/gdb-upstream.patch b/gdb/patches/gdb-upstream.patch new file mode 100644 index 000000000..c81f72a92 --- /dev/null +++ b/gdb/patches/gdb-upstream.patch @@ -0,0 +1,1485 @@ +http://sourceware.org/ml/binutils-cvs/2011-07/msg00116.html + +### src/include/ChangeLog 2011/07/22 14:37:50 1.546 +### src/include/ChangeLog 2011/07/22 20:37:50 1.547 +## -1,5 +1,8 @@ + 2011-07-22 Jakub Jelinek + ++ * dwarf2.h (DW_AT_GNU_macros): New. ++ (enum dwarf_macro_record_type): New enum. Add DW_MACRO_GNU_*. ++ + PR c++/49756 + * libiberty.h (stack_limit_increase): New prototype. + +--- src/include/dwarf2.h 2011/06/22 15:03:19 1.26 ++++ src/include/dwarf2.h 2011/07/22 20:37:50 1.27 +@@ -366,6 +366,8 @@ + DW_AT_GNU_all_tail_call_sites = 0x2116, + DW_AT_GNU_all_call_sites = 0x2117, + DW_AT_GNU_all_source_call_sites = 0x2118, ++ /* Section offset into .debug_macro section. */ ++ DW_AT_GNU_macros = 0x2119, + /* VMS extensions. */ + DW_AT_VMS_rtnbeg_pd_address = 0x2201, + /* GNAT extensions. */ +@@ -879,6 +881,20 @@ + DW_MACINFO_end_file = 4, + DW_MACINFO_vendor_ext = 255 + }; ++ ++/* Names and codes for new style macro information. */ ++enum dwarf_macro_record_type ++ { ++ DW_MACRO_GNU_define = 1, ++ DW_MACRO_GNU_undef = 2, ++ DW_MACRO_GNU_start_file = 3, ++ DW_MACRO_GNU_end_file = 4, ++ DW_MACRO_GNU_define_indirect = 5, ++ DW_MACRO_GNU_undef_indirect = 6, ++ DW_MACRO_GNU_transparent_include = 7, ++ DW_MACRO_GNU_lo_user = 0xe0, ++ DW_MACRO_GNU_hi_user = 0xff ++ }; + + /* @@@ For use with GNU frame unwind information. */ + + + + +FYI: implement new DWARF macro proposal +http://sourceware.org/ml/gdb-patches/2011-07/msg00732.html +http://sourceware.org/ml/gdb-cvs/2011-07/msg00212.html + +### src/gdb/ChangeLog 2011/07/26 15:24:01 1.13224 +### src/gdb/ChangeLog 2011/07/26 17:04:21 1.13225 +## -1,3 +1,20 @@ ++2011-07-26 Tom Tromey ++ ++ * symfile.h (struct dwarf2_debug_sections) : New field. ++ * dwarf2read.c (read_indirect_string_at_offset): New function. ++ (read_indirect_string): Use it. ++ (dwarf_decode_macro_bytes): New function, taken from ++ dwarf_decode_macros. Handle DW_MACRO_GNU_*. ++ (dwarf_decode_macros): Use it. handle DW_MACRO_GNU_*. ++ (dwarf_parse_macro_header, skip_form_bytes, skip_unknown_opcode): ++ New functions. ++ (struct dwarf2_per_objfile) : New field. ++ (dwarf2_elf_names): Add .debug_macro. ++ (dwarf2_macros_too_long_complaint): Add 'section' argument. ++ (dwarf2_locate_sections): Handle new section. ++ (read_file_scope): Handle DW_AT_GNU_macros. ++ (dwarf2_per_objfile_free): Unmap the .debug_macro section. ++ + 2011-07-26 Paul Pluzhnikov + + * NEWS: Mention dcache configuration. +--- src/gdb/dwarf2read.c 2011/07/20 15:13:49 1.554 ++++ src/gdb/dwarf2read.c 2011/07/26 17:04:23 1.555 +@@ -187,6 +187,7 @@ + struct dwarf2_section_info line; + struct dwarf2_section_info loc; + struct dwarf2_section_info macinfo; ++ struct dwarf2_section_info macro; + struct dwarf2_section_info str; + struct dwarf2_section_info ranges; + struct dwarf2_section_info frame; +@@ -264,6 +265,7 @@ + { ".debug_line", ".zdebug_line" }, + { ".debug_loc", ".zdebug_loc" }, + { ".debug_macinfo", ".zdebug_macinfo" }, ++ { ".debug_macro", ".zdebug_macro" }, + { ".debug_str", ".zdebug_str" }, + { ".debug_ranges", ".zdebug_ranges" }, + { ".debug_types", ".zdebug_types" }, +@@ -858,10 +860,11 @@ + } + + static void +-dwarf2_macros_too_long_complaint (void) ++dwarf2_macros_too_long_complaint (struct dwarf2_section_info *section) + { + complaint (&symfile_complaints, +- _("macro info runs off end of `.debug_macinfo' section")); ++ _("macro info runs off end of `%s' section"), ++ section->asection->name); + } + + static void +@@ -1233,7 +1236,9 @@ + struct dwarf2_cu *); + + static void dwarf_decode_macros (struct line_header *, unsigned int, +- char *, bfd *, struct dwarf2_cu *); ++ char *, bfd *, struct dwarf2_cu *, ++ struct dwarf2_section_info *, ++ int); + + static int attr_form_is_block (struct attribute *); + +@@ -1438,6 +1443,11 @@ + dwarf2_per_objfile->macinfo.asection = sectp; + dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp); + } ++ else if (section_is_p (sectp->name, &names->macro)) ++ { ++ dwarf2_per_objfile->macro.asection = sectp; ++ dwarf2_per_objfile->macro.size = bfd_get_section_size (sectp); ++ } + else if (section_is_p (sectp->name, &names->str)) + { + dwarf2_per_objfile->str.asection = sectp; +@@ -5641,13 +5651,28 @@ + refers to information in the line number info statement program + header, so we can only read it if we've read the header + successfully. */ +- attr = dwarf2_attr (die, DW_AT_macro_info, cu); ++ attr = dwarf2_attr (die, DW_AT_GNU_macros, cu); + if (attr && cu->line_header) + { +- unsigned int macro_offset = DW_UNSND (attr); ++ if (dwarf2_attr (die, DW_AT_macro_info, cu)) ++ complaint (&symfile_complaints, ++ _("CU refers to both DW_AT_GNU_macros and DW_AT_macro_info")); ++ ++ dwarf_decode_macros (cu->line_header, DW_UNSND (attr), ++ comp_dir, abfd, cu, ++ &dwarf2_per_objfile->macro, 1); ++ } ++ else ++ { ++ attr = dwarf2_attr (die, DW_AT_macro_info, cu); ++ if (attr && cu->line_header) ++ { ++ unsigned int macro_offset = DW_UNSND (attr); + +- dwarf_decode_macros (cu->line_header, macro_offset, +- comp_dir, abfd, cu); ++ dwarf_decode_macros (cu->line_header, macro_offset, ++ comp_dir, abfd, cu, ++ &dwarf2_per_objfile->macinfo, 0); ++ } + } + do_cleanups (back_to); + } +@@ -10262,32 +10287,32 @@ + } + + static char * +-read_indirect_string (bfd *abfd, gdb_byte *buf, +- const struct comp_unit_head *cu_header, +- unsigned int *bytes_read_ptr) ++read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset) + { +- LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr); +- + dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->str); + if (dwarf2_per_objfile->str.buffer == NULL) +- { +- error (_("DW_FORM_strp used without .debug_str section [in module %s]"), +- bfd_get_filename (abfd)); +- return NULL; +- } ++ error (_("DW_FORM_strp used without .debug_str section [in module %s]"), ++ bfd_get_filename (abfd)); + if (str_offset >= dwarf2_per_objfile->str.size) +- { +- error (_("DW_FORM_strp pointing outside of " +- ".debug_str section [in module %s]"), +- bfd_get_filename (abfd)); +- return NULL; +- } ++ error (_("DW_FORM_strp pointing outside of " ++ ".debug_str section [in module %s]"), ++ bfd_get_filename (abfd)); + gdb_assert (HOST_CHAR_BIT == 8); + if (dwarf2_per_objfile->str.buffer[str_offset] == '\0') + return NULL; + return (char *) (dwarf2_per_objfile->str.buffer + str_offset); + } + ++static char * ++read_indirect_string (bfd *abfd, gdb_byte *buf, ++ const struct comp_unit_head *cu_header, ++ unsigned int *bytes_read_ptr) ++{ ++ LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr); ++ ++ return read_indirect_string_at_offset (abfd, str_offset); ++} ++ + static unsigned long + read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr) + { +@@ -14669,117 +14694,205 @@ + dwarf2_macro_malformed_definition_complaint (body); + } + ++/* Skip some bytes from BYTES according to the form given in FORM. ++ Returns the new pointer. */ + +-static void +-dwarf_decode_macros (struct line_header *lh, unsigned int offset, +- char *comp_dir, bfd *abfd, +- struct dwarf2_cu *cu) ++static gdb_byte * ++skip_form_bytes (bfd *abfd, gdb_byte *bytes, ++ enum dwarf_form form, ++ unsigned int offset_size, ++ struct dwarf2_section_info *section) + { +- gdb_byte *mac_ptr, *mac_end; +- struct macro_source_file *current_file = 0; +- enum dwarf_macinfo_record_type macinfo_type; +- int at_commandline; ++ unsigned int bytes_read; + +- dwarf2_read_section (dwarf2_per_objfile->objfile, +- &dwarf2_per_objfile->macinfo); +- if (dwarf2_per_objfile->macinfo.buffer == NULL) ++ switch (form) + { +- complaint (&symfile_complaints, _("missing .debug_macinfo section")); +- return; ++ case DW_FORM_data1: ++ case DW_FORM_flag: ++ ++bytes; ++ break; ++ ++ case DW_FORM_data2: ++ bytes += 2; ++ break; ++ ++ case DW_FORM_data4: ++ bytes += 4; ++ break; ++ ++ case DW_FORM_data8: ++ bytes += 8; ++ break; ++ ++ case DW_FORM_string: ++ read_direct_string (abfd, bytes, &bytes_read); ++ bytes += bytes_read; ++ break; ++ ++ case DW_FORM_sec_offset: ++ case DW_FORM_strp: ++ bytes += offset_size; ++ break; ++ ++ case DW_FORM_block: ++ bytes += read_unsigned_leb128 (abfd, bytes, &bytes_read); ++ bytes += bytes_read; ++ break; ++ ++ case DW_FORM_block1: ++ bytes += 1 + read_1_byte (abfd, bytes); ++ break; ++ case DW_FORM_block2: ++ bytes += 2 + read_2_bytes (abfd, bytes); ++ break; ++ case DW_FORM_block4: ++ bytes += 4 + read_4_bytes (abfd, bytes); ++ break; ++ ++ case DW_FORM_sdata: ++ case DW_FORM_udata: ++ bytes = skip_leb128 (abfd, bytes); ++ break; ++ ++ default: ++ { ++ complain: ++ complaint (&symfile_complaints, ++ _("invalid form 0x%x in `%s'"), ++ form, ++ section->asection->name); ++ return NULL; ++ } + } + +- /* First pass: Find the name of the base filename. +- This filename is needed in order to process all macros whose definition +- (or undefinition) comes from the command line. These macros are defined +- before the first DW_MACINFO_start_file entry, and yet still need to be +- associated to the base file. ++ return bytes; ++} + +- To determine the base file name, we scan the macro definitions until we +- reach the first DW_MACINFO_start_file entry. We then initialize +- CURRENT_FILE accordingly so that any macro definition found before the +- first DW_MACINFO_start_file can still be associated to the base file. */ ++/* A helper for dwarf_decode_macros that handles skipping an unknown ++ opcode. Returns an updated pointer to the macro data buffer; or, ++ on error, issues a complaint and returns NULL. */ + +- mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset; +- mac_end = dwarf2_per_objfile->macinfo.buffer +- + dwarf2_per_objfile->macinfo.size; ++static gdb_byte * ++skip_unknown_opcode (unsigned int opcode, ++ gdb_byte **opcode_definitions, ++ gdb_byte *mac_ptr, ++ bfd *abfd, ++ unsigned int offset_size, ++ struct dwarf2_section_info *section) ++{ ++ unsigned int bytes_read, i; ++ unsigned long arg; ++ gdb_byte *defn; + +- do ++ if (opcode_definitions[opcode] == NULL) + { +- /* Do we at least have room for a macinfo type byte? */ +- if (mac_ptr >= mac_end) +- { +- /* Complaint is printed during the second pass as GDB will probably +- stop the first pass earlier upon finding +- DW_MACINFO_start_file. */ +- break; +- } ++ complaint (&symfile_complaints, ++ _("unrecognized DW_MACFINO opcode 0x%x"), ++ opcode); ++ return NULL; ++ } + +- macinfo_type = read_1_byte (abfd, mac_ptr); +- mac_ptr++; ++ defn = opcode_definitions[opcode]; ++ arg = read_unsigned_leb128 (abfd, defn, &bytes_read); ++ defn += bytes_read; + +- switch (macinfo_type) +- { +- /* A zero macinfo type indicates the end of the macro +- information. */ +- case 0: +- break; ++ for (i = 0; i < arg; ++i) ++ { ++ mac_ptr = skip_form_bytes (abfd, mac_ptr, defn[i], offset_size, section); ++ if (mac_ptr == NULL) ++ { ++ /* skip_form_bytes already issued the complaint. */ ++ return NULL; ++ } ++ } + +- case DW_MACINFO_define: +- case DW_MACINFO_undef: +- /* Only skip the data by MAC_PTR. */ +- { +- unsigned int bytes_read; ++ return mac_ptr; ++} + +- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- read_direct_string (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- } +- break; ++/* A helper function which parses the header of a macro section. ++ If the macro section is the extended (for now called "GNU") type, ++ then this updates *OFFSET_SIZE. Returns a pointer to just after ++ the header, or issues a complaint and returns NULL on error. */ + +- case DW_MACINFO_start_file: +- { +- unsigned int bytes_read; +- int line, file; ++static gdb_byte * ++dwarf_parse_macro_header (gdb_byte **opcode_definitions, ++ bfd *abfd, ++ gdb_byte *mac_ptr, ++ unsigned int *offset_size, ++ int section_is_gnu) ++{ ++ memset (opcode_definitions, 0, 256 * sizeof (gdb_byte *)); + +- line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; ++ if (section_is_gnu) ++ { ++ unsigned int version, flags; + +- current_file = macro_start_file (file, line, current_file, +- comp_dir, lh, cu->objfile); +- } +- break; ++ version = read_2_bytes (abfd, mac_ptr); ++ if (version != 4) ++ { ++ complaint (&symfile_complaints, ++ _("unrecognized version `%d' in .debug_macro section"), ++ version); ++ return NULL; ++ } ++ mac_ptr += 2; + +- case DW_MACINFO_end_file: +- /* No data to skip by MAC_PTR. */ +- break; ++ flags = read_1_byte (abfd, mac_ptr); ++ ++mac_ptr; ++ *offset_size = (flags & 1) ? 8 : 4; + +- case DW_MACINFO_vendor_ext: +- /* Only skip the data by MAC_PTR. */ +- { +- unsigned int bytes_read; ++ if ((flags & 2) != 0) ++ /* We don't need the line table offset. */ ++ mac_ptr += *offset_size; + +- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- read_direct_string (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- } +- break; ++ /* Vendor opcode descriptions. */ ++ if ((flags & 4) != 0) ++ { ++ unsigned int i, count; + +- default: +- break; ++ count = read_1_byte (abfd, mac_ptr); ++ ++mac_ptr; ++ for (i = 0; i < count; ++i) ++ { ++ unsigned int opcode, bytes_read; ++ unsigned long arg; ++ ++ opcode = read_1_byte (abfd, mac_ptr); ++ ++mac_ptr; ++ opcode_definitions[opcode] = mac_ptr; ++ arg = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ mac_ptr += arg; ++ } + } +- } while (macinfo_type != 0 && current_file == NULL); ++ } + +- /* Second pass: Process all entries. ++ return mac_ptr; ++} + +- Use the AT_COMMAND_LINE flag to determine whether we are still processing +- command-line macro definitions/undefinitions. This flag is unset when we +- reach the first DW_MACINFO_start_file entry. */ ++/* A helper for dwarf_decode_macros that handles the GNU extensions, ++ including DW_GNU_MACINFO_transparent_include. */ ++ ++static void ++dwarf_decode_macro_bytes (bfd *abfd, gdb_byte *mac_ptr, gdb_byte *mac_end, ++ struct macro_source_file *current_file, ++ struct line_header *lh, char *comp_dir, ++ struct dwarf2_section_info *section, ++ int section_is_gnu, ++ unsigned int offset_size, ++ struct objfile *objfile) ++{ ++ enum dwarf_macro_record_type macinfo_type; ++ int at_commandline; ++ gdb_byte *opcode_definitions[256]; + +- mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset; ++ mac_ptr = dwarf_parse_macro_header (opcode_definitions, abfd, mac_ptr, ++ &offset_size, section_is_gnu); ++ if (mac_ptr == NULL) ++ { ++ /* We already issued a complaint. */ ++ return; ++ } + + /* Determines if GDB is still before first DW_MACINFO_start_file. If true + GDB is still reading the definitions from command line. First +@@ -14795,13 +14908,15 @@ + /* Do we at least have room for a macinfo type byte? */ + if (mac_ptr >= mac_end) + { +- dwarf2_macros_too_long_complaint (); ++ dwarf2_macros_too_long_complaint (section); + break; + } + + macinfo_type = read_1_byte (abfd, mac_ptr); + mac_ptr++; + ++ /* Note that we rely on the fact that the corresponding GNU and ++ DWARF constants are the same. */ + switch (macinfo_type) + { + /* A zero macinfo type indicates the end of the macro +@@ -14809,29 +14924,45 @@ + case 0: + break; + +- case DW_MACINFO_define: +- case DW_MACINFO_undef: ++ case DW_MACRO_GNU_define: ++ case DW_MACRO_GNU_undef: ++ case DW_MACRO_GNU_define_indirect: ++ case DW_MACRO_GNU_undef_indirect: + { + unsigned int bytes_read; + int line; + char *body; ++ int is_define; + +- line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- body = read_direct_string (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; ++ line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ ++ if (macinfo_type == DW_MACRO_GNU_define ++ || macinfo_type == DW_MACRO_GNU_undef) ++ { ++ body = read_direct_string (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ } ++ else ++ { ++ LONGEST str_offset; ++ ++ str_offset = read_offset_1 (abfd, mac_ptr, offset_size); ++ mac_ptr += offset_size; + ++ body = read_indirect_string_at_offset (abfd, str_offset); ++ } ++ ++ is_define = (macinfo_type == DW_MACRO_GNU_define ++ || macinfo_type == DW_MACRO_GNU_define_indirect); + if (! current_file) + { + /* DWARF violation as no main source is present. */ + complaint (&symfile_complaints, + _("debug info with no main source gives macro %s " + "on line %d: %s"), +- macinfo_type == DW_MACINFO_define ? +- _("definition") : +- macinfo_type == DW_MACINFO_undef ? +- _("undefinition") : +- _("something-or-other"), line, body); ++ is_define ? _("definition") : _("undefinition"), ++ line, body); + break; + } + if ((line == 0 && !at_commandline) +@@ -14839,21 +14970,21 @@ + complaint (&symfile_complaints, + _("debug info gives %s macro %s with %s line %d: %s"), + at_commandline ? _("command-line") : _("in-file"), +- macinfo_type == DW_MACINFO_define ? +- _("definition") : +- macinfo_type == DW_MACINFO_undef ? +- _("undefinition") : +- _("something-or-other"), ++ is_define ? _("definition") : _("undefinition"), + line == 0 ? _("zero") : _("non-zero"), line, body); + +- if (macinfo_type == DW_MACINFO_define) ++ if (is_define) + parse_macro_definition (current_file, line, body); +- else if (macinfo_type == DW_MACINFO_undef) +- macro_undef (current_file, line, body); ++ else ++ { ++ gdb_assert (macinfo_type == DW_MACRO_GNU_undef ++ || macinfo_type == DW_MACRO_GNU_undef_indirect); ++ macro_undef (current_file, line, body); ++ } + } + break; + +- case DW_MACINFO_start_file: ++ case DW_MACRO_GNU_start_file: + { + unsigned int bytes_read; + int line, file; +@@ -14873,17 +15004,18 @@ + + if (at_commandline) + { +- /* This DW_MACINFO_start_file was executed in the pass one. */ ++ /* This DW_MACRO_GNU_start_file was executed in the ++ pass one. */ + at_commandline = 0; + } + else + current_file = macro_start_file (file, line, + current_file, comp_dir, +- lh, cu->objfile); ++ lh, objfile); + } + break; + +- case DW_MACINFO_end_file: ++ case DW_MACRO_GNU_end_file: + if (! current_file) + complaint (&symfile_complaints, + _("macro debug info has an unmatched " +@@ -14893,7 +15025,7 @@ + current_file = current_file->included_by; + if (! current_file) + { +- enum dwarf_macinfo_record_type next_type; ++ enum dwarf_macro_record_type next_type; + + /* GCC circa March 2002 doesn't produce the zero + type byte marking the end of the compilation +@@ -14903,7 +15035,7 @@ + /* Do we at least have room for a macinfo type byte? */ + if (mac_ptr >= mac_end) + { +- dwarf2_macros_too_long_complaint (); ++ dwarf2_macros_too_long_complaint (section); + return; + } + +@@ -14920,23 +15052,199 @@ + } + break; + ++ case DW_MACRO_GNU_transparent_include: ++ { ++ LONGEST offset; ++ ++ offset = read_offset_1 (abfd, mac_ptr, offset_size); ++ mac_ptr += offset_size; ++ ++ dwarf_decode_macro_bytes (abfd, ++ section->buffer + offset, ++ mac_end, current_file, ++ lh, comp_dir, ++ section, section_is_gnu, ++ offset_size, objfile); ++ } ++ break; ++ + case DW_MACINFO_vendor_ext: +- { +- unsigned int bytes_read; +- int constant; ++ if (!section_is_gnu) ++ { ++ unsigned int bytes_read; ++ int constant; + +- constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; +- read_direct_string (abfd, mac_ptr, &bytes_read); +- mac_ptr += bytes_read; ++ constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ read_direct_string (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; + +- /* We don't recognize any vendor extensions. */ +- } +- break; ++ /* We don't recognize any vendor extensions. */ ++ break; ++ } ++ /* FALLTHROUGH */ ++ ++ default: ++ mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions, ++ mac_ptr, abfd, offset_size, ++ section); ++ if (mac_ptr == NULL) ++ return; ++ break; + } + } while (macinfo_type != 0); + } + ++static void ++dwarf_decode_macros (struct line_header *lh, unsigned int offset, ++ char *comp_dir, bfd *abfd, ++ struct dwarf2_cu *cu, ++ struct dwarf2_section_info *section, ++ int section_is_gnu) ++{ ++ gdb_byte *mac_ptr, *mac_end; ++ struct macro_source_file *current_file = 0; ++ enum dwarf_macro_record_type macinfo_type; ++ unsigned int offset_size = cu->header.offset_size; ++ gdb_byte *opcode_definitions[256]; ++ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, section); ++ if (section->buffer == NULL) ++ { ++ complaint (&symfile_complaints, _("missing %s section"), ++ section->asection->name); ++ return; ++ } ++ ++ /* First pass: Find the name of the base filename. ++ This filename is needed in order to process all macros whose definition ++ (or undefinition) comes from the command line. These macros are defined ++ before the first DW_MACINFO_start_file entry, and yet still need to be ++ associated to the base file. ++ ++ To determine the base file name, we scan the macro definitions until we ++ reach the first DW_MACINFO_start_file entry. We then initialize ++ CURRENT_FILE accordingly so that any macro definition found before the ++ first DW_MACINFO_start_file can still be associated to the base file. */ ++ ++ mac_ptr = section->buffer + offset; ++ mac_end = section->buffer + section->size; ++ ++ mac_ptr = dwarf_parse_macro_header (opcode_definitions, abfd, mac_ptr, ++ &offset_size, section_is_gnu); ++ if (mac_ptr == NULL) ++ { ++ /* We already issued a complaint. */ ++ return; ++ } ++ ++ do ++ { ++ /* Do we at least have room for a macinfo type byte? */ ++ if (mac_ptr >= mac_end) ++ { ++ /* Complaint is printed during the second pass as GDB will probably ++ stop the first pass earlier upon finding ++ DW_MACINFO_start_file. */ ++ break; ++ } ++ ++ macinfo_type = read_1_byte (abfd, mac_ptr); ++ mac_ptr++; ++ ++ /* Note that we rely on the fact that the corresponding GNU and ++ DWARF constants are the same. */ ++ switch (macinfo_type) ++ { ++ /* A zero macinfo type indicates the end of the macro ++ information. */ ++ case 0: ++ break; ++ ++ case DW_MACRO_GNU_define: ++ case DW_MACRO_GNU_undef: ++ /* Only skip the data by MAC_PTR. */ ++ { ++ unsigned int bytes_read; ++ ++ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ read_direct_string (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ } ++ break; ++ ++ case DW_MACRO_GNU_start_file: ++ { ++ unsigned int bytes_read; ++ int line, file; ++ ++ line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ ++ current_file = macro_start_file (file, line, current_file, ++ comp_dir, lh, cu->objfile); ++ } ++ break; ++ ++ case DW_MACRO_GNU_end_file: ++ /* No data to skip by MAC_PTR. */ ++ break; ++ ++ case DW_MACRO_GNU_define_indirect: ++ case DW_MACRO_GNU_undef_indirect: ++ { ++ unsigned int bytes_read; ++ ++ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ mac_ptr += offset_size; ++ } ++ break; ++ ++ case DW_MACRO_GNU_transparent_include: ++ /* Note that, according to the spec, a transparent include ++ chain cannot call DW_MACRO_GNU_start_file. So, we can just ++ skip this opcode. */ ++ mac_ptr += offset_size; ++ break; ++ ++ case DW_MACINFO_vendor_ext: ++ /* Only skip the data by MAC_PTR. */ ++ if (!section_is_gnu) ++ { ++ unsigned int bytes_read; ++ ++ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ read_direct_string (abfd, mac_ptr, &bytes_read); ++ mac_ptr += bytes_read; ++ } ++ /* FALLTHROUGH */ ++ ++ default: ++ mac_ptr = skip_unknown_opcode (macinfo_type, opcode_definitions, ++ mac_ptr, abfd, offset_size, ++ section); ++ if (mac_ptr == NULL) ++ return; ++ break; ++ } ++ } while (macinfo_type != 0 && current_file == NULL); ++ ++ /* Second pass: Process all entries. ++ ++ Use the AT_COMMAND_LINE flag to determine whether we are still processing ++ command-line macro definitions/undefinitions. This flag is unset when we ++ reach the first DW_MACINFO_start_file entry. */ ++ ++ dwarf_decode_macro_bytes (abfd, section->buffer + offset, mac_end, ++ current_file, lh, comp_dir, section, section_is_gnu, ++ offset_size, cu->objfile); ++} ++ + /* Check if the attribute's form is a DW_FORM_block* + if so return true else false. */ + static int +@@ -15663,6 +15971,7 @@ + munmap_section_buffer (&data->line); + munmap_section_buffer (&data->loc); + munmap_section_buffer (&data->macinfo); ++ munmap_section_buffer (&data->macro); + munmap_section_buffer (&data->str); + munmap_section_buffer (&data->ranges); + munmap_section_buffer (&data->frame); +--- src/gdb/symfile.h 2011/06/10 21:48:04 1.93 ++++ src/gdb/symfile.h 2011/07/26 17:04:23 1.94 +@@ -582,6 +582,7 @@ + struct dwarf2_section_names line; + struct dwarf2_section_names loc; + struct dwarf2_section_names macinfo; ++ struct dwarf2_section_names macro; + struct dwarf2_section_names str; + struct dwarf2_section_names ranges; + struct dwarf2_section_names types; + + + +Re: FYI: implement new DWARF macro proposal +http://sourceware.org/ml/gdb-patches/2011-07/msg00759.html +http://sourceware.org/ml/gdb-cvs/2011-07/msg00224.html + +### src/gdb/ChangeLog 2011/07/26 21:09:05 1.13229 +### src/gdb/ChangeLog 2011/07/27 14:45:36 1.13230 +## -1,3 +1,10 @@ ++2011-07-27 Tom Tromey ++ ++ * xcoffread.c (dwarf2_xcoff_names): Add 'macro' and 'sentinel' ++ entries. ++ * symfile.h (struct dwarf2_debug_sections) : New field. ++ * dwarf2read.c (dwarf2_elf_names): Add sentinel entry. ++ + 2011-07-26 Sterling Augustine + + * cli/cli-dump.c (dump_binary_file): Change parameter type to +--- src/gdb/dwarf2read.c 2011/07/26 17:04:23 1.555 ++++ src/gdb/dwarf2read.c 2011/07/27 14:45:37 1.556 +@@ -271,7 +271,8 @@ + { ".debug_types", ".zdebug_types" }, + { ".debug_frame", ".zdebug_frame" }, + { ".eh_frame", NULL }, +- { ".gdb_index", ".zgdb_index" } ++ { ".gdb_index", ".zgdb_index" }, ++ 23 + }; + + /* local data types */ +--- src/gdb/symfile.h 2011/07/26 17:04:23 1.94 ++++ src/gdb/symfile.h 2011/07/27 14:45:37 1.95 +@@ -589,6 +589,9 @@ + struct dwarf2_section_names frame; + struct dwarf2_section_names eh_frame; + struct dwarf2_section_names gdb_index; ++ /* This field has no meaning, but exists solely to catch changes to ++ this structure which are not reflected in some instance. */ ++ int sentinel; + }; + + extern int dwarf2_has_info (struct objfile *, +--- src/gdb/xcoffread.c 2011/06/07 12:31:07 1.89 ++++ src/gdb/xcoffread.c 2011/07/27 14:45:37 1.90 +@@ -160,12 +160,14 @@ + { ".dwline", NULL }, + { ".dwloc", NULL }, + { NULL, NULL }, /* debug_macinfo */ ++ { NULL, NULL }, /* debug_macro */ + { ".dwstr", NULL }, + { ".dwrnges", NULL }, + { NULL, NULL }, /* debug_types */ + { ".dwframe", NULL }, + { NULL, NULL }, /* eh_frame */ +- { NULL, NULL } /* gdb_index */ ++ { NULL, NULL }, /* gdb_index */ ++ 23 + }; + + static void + + + +[patch][python] Fix sigsegv when a printer fails to return a value and string_print is set. +http://sourceware.org/ml/gdb-patches/2011-07/msg00719.html +http://sourceware.org/ml/gdb-cvs/2011-07/msg00234.html + +### src/gdb/ChangeLog 2011/07/27 19:31:30 1.13236 +### src/gdb/ChangeLog 2011/07/28 10:36:37 1.13237 +## -1,3 +1,8 @@ ++2011-07-28 Phil Muldoon ++ ++ * varobj.c (value_get_print_value): Move hint check later into the ++ function. Comment function. Free thevalue before reusing it. ++ + 2011-07-27 Jan Kratochvil + Pedro Alves + +--- src/gdb/varobj.c 2011/07/18 09:21:43 1.180 ++++ src/gdb/varobj.c 2011/07/28 10:36:40 1.181 +@@ -2610,25 +2610,21 @@ + + if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst)) + { +- char *hint; + struct value *replacement; + PyObject *output = NULL; + +- hint = gdbpy_get_display_hint (value_formatter); +- if (hint) +- { +- if (!strcmp (hint, "string")) +- string_print = 1; +- xfree (hint); +- } +- + output = apply_varobj_pretty_printer (value_formatter, + &replacement, + stb); ++ ++ /* If we have string like output ... */ + if (output) + { + make_cleanup_py_decref (output); + ++ /* If this is a lazy string, extract it. For lazy ++ strings we always print as a string, so set ++ string_print. */ + if (gdbpy_is_lazy_string (output)) + { + gdbpy_extract_lazy_string (output, &str_addr, &type, +@@ -2638,12 +2634,27 @@ + } + else + { ++ /* If it is a regular (non-lazy) string, extract ++ it and copy the contents into THEVALUE. If the ++ hint says to print it as a string, set ++ string_print. Otherwise just return the extracted ++ string as a value. */ ++ + PyObject *py_str + = python_string_to_target_python_string (output); + + if (py_str) + { + char *s = PyString_AsString (py_str); ++ char *hint; ++ ++ hint = gdbpy_get_display_hint (value_formatter); ++ if (hint) ++ { ++ if (!strcmp (hint, "string")) ++ string_print = 1; ++ xfree (hint); ++ } + + len = PyString_Size (py_str); + thevalue = xmemdup (s, len + 1, len + 1); +@@ -2662,6 +2673,9 @@ + gdbpy_print_stack (); + } + } ++ /* If the printer returned a replacement value, set VALUE ++ to REPLACEMENT. If there is not a replacement value, ++ just use the value passed to this function. */ + if (replacement) + value = replacement; + } +@@ -2672,12 +2686,18 @@ + get_formatted_print_options (&opts, format_code[(int) format]); + opts.deref_ref = 0; + opts.raw = 1; ++ ++ /* If the THEVALUE has contents, it is a regular string. */ + if (thevalue) + LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts); + else if (string_print) ++ /* Otherwise, if string_print is set, and it is not a regular ++ string, it is a lazy string. */ + val_print_string (type, encoding, str_addr, len, stb, &opts); + else ++ /* All other cases. */ + common_val_print (value, stb, 0, &opts, current_language); ++ + thevalue = ui_file_xstrdup (stb, NULL); + + do_cleanups (old_chain); +### src/gdb/testsuite/ChangeLog 2011/07/27 21:18:39 1.2816 +### src/gdb/testsuite/ChangeLog 2011/07/28 10:36:40 1.2817 +## -1,3 +1,10 @@ ++2011-07-28 Phil Muldoon ++ ++ * gdb.python/py-mi.exp: Test printers returning string hint, and ++ also not returning a value. ++ * gdb.python/py-prettyprint.c: Add testcase for above. ++ * gdb.python/py-prettyprint.py: Add test printer for above. ++ + 2011-07-27 Jan Kratochvil + + * gdb.dwarf2/dw2-simple-locdesc.S: Change DWARF version to 3. +--- src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/26 18:38:55 1.13 ++++ src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/28 10:36:40 1.14 +@@ -284,6 +284,13 @@ mi_list_varobj_children nstype2 { + { {nstype2.} {} 6 {char \[6\]} } + } "list children after setting exception flag" + ++mi_create_varobj me me \ ++ "create me varobj" ++ ++mi_gdb_test "-var-evaluate-expression me" \ ++ "\\^done,value=\".*\"" \ ++ "evaluate me varobj" ++ + # C++ MI tests + gdb_exit + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ +--- src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/04/29 12:45:46 1.12 ++++ src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/07/28 10:36:40 1.13 +@@ -149,6 +149,11 @@ + + typedef struct justchildren nostring_type; + ++struct memory_error ++{ ++ const char *s; ++}; ++ + struct container + { + string name; +@@ -227,6 +232,7 @@ + /* Clearing by being `static' could invoke an other GDB C++ bug. */ + struct nullstr nullstr; + nostring_type nstype, nstype2; ++ struct memory_error me; + struct ns ns, ns2; + struct lazystring estring, estring2; + struct hint_error hint_error; +@@ -234,6 +240,8 @@ + nstype.elements = narray; + nstype.len = 0; + ++ me.s = "blah"; ++ + init_ss(&ss, 1, 2); + init_ss(ssa+0, 3, 4); + init_ss(ssa+1, 5, 6); +--- src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/04/11 17:40:41 1.11 ++++ src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/07/28 10:36:40 1.12 +@@ -17,6 +17,7 @@ + # printers. + + import re ++import gdb + + # Test returning a Value from a printer. + class string_print: +@@ -186,6 +187,18 @@ + yield 's', self.val['s'] + yield 'x', self.val['x'] + ++class MemoryErrorString: ++ "Raise an error" ++ ++ def __init__(self, val): ++ self.val = val ++ ++ def to_string(self): ++ raise gdb.MemoryError ("Cannot access memory."); ++ ++ def display_hint (self): ++ return 'string' ++ + def lookup_function (val): + "Look-up and return a pretty-printer that can print val." + +@@ -261,6 +274,8 @@ + pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error + pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error + ++ pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString ++ + pretty_printers_dict = {} + + register_pretty_printers () + + + +commit 84be2b4d0a55c95697c9ecc72bb31c2fbd316127 +Author: ian +Date: Tue Jul 26 14:28:23 2011 +0000 + + * cp-demangle.c (d_print_init): Initialize pack_index field. + (d_print_comp): Check for NULL template argument. + * testsuite/demangle-expected: Add test case. + + + git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176791 138bc75d-0d04-0410-961f-82ee72b054a4 + +### a/libiberty/ChangeLog +### b/libiberty/ChangeLog +## -1,3 +1,9 @@ ++2011-07-26 Ian Lance Taylor ++ ++ * cp-demangle.c (d_print_init): Initialize pack_index field. ++ (d_print_comp): Check for NULL template argument. ++ * testsuite/demangle-expected: Add test case. ++ + 2011-07-22 Gerald Pfeifer + + PR target/49817 +--- a/libiberty/cp-demangle.c ++++ b/libiberty/cp-demangle.c +@@ -1,5 +1,5 @@ + /* Demangler for g++ V3 ABI. +- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ++ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. + Written by Ian Lance Taylor . + +@@ -3306,6 +3306,7 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback, + dpi->last_char = '\0'; + dpi->templates = NULL; + dpi->modifiers = NULL; ++ dpi->pack_index = 0; + dpi->flush_count = 0; + + dpi->callback = callback; +@@ -3893,6 +3894,13 @@ d_print_comp (struct d_print_info *dpi, int options, + struct demangle_component *a = d_lookup_template_argument (dpi, sub); + if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) + a = d_index_template_argument (a, dpi->pack_index); ++ ++ if (a == NULL) ++ { ++ d_print_error (dpi); ++ return; ++ } ++ + sub = a; + } + +--- a/libiberty/testsuite/demangle-expected ++++ b/libiberty/testsuite/demangle-expected +@@ -4010,6 +4010,12 @@ K<1, &S::m>::f() + _ZN1KILi1EXadL_ZN1S1mEEEE1fEv + K<1, &S::m>::f() + # ++# Used to crash -- binutils PR 13030. ++--format=gnu-v3 ++_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_ ++_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_ ++_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_ ++# + # Ada (GNAT) tests. + # + # Simple test. + + + +http://sourceware.org/ml/gdb-cvs/2011-08/msg00047.html + +### src/gdb/ChangeLog 2011/08/08 21:41:12 1.13259 +### src/gdb/ChangeLog 2011/08/09 12:45:39 1.13260 +## -1,3 +1,13 @@ ++2011-08-09 Phil Muldoon ++ ++ * python/lib/gdb/__init__.py: Auto-load files in command and ++ function directories. ++ * python/python.c (finish_python_initialization): Use ++ os.path.join. ++ * python/lib/gdb/command/pretty_printers.py: Self register ++ command. ++ * NEWS: Document auto-loading. ++ + 2011-08-08 Jan Kratochvil + + * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) +--- src/gdb/NEWS 2011/07/26 20:57:53 1.446 ++++ src/gdb/NEWS 2011/08/09 12:45:39 1.447 +@@ -23,6 +23,11 @@ + ** A prompt subsitution hook (prompt_hook) is now available to the + Python API. + ++ ** Python commands and convenience-functions located in ++ 'data-directory'/python/gdb/command and ++ 'data-directory'/python/gdb/function are now automatically loaded ++ on GDB start-up. ++ + * libthread-db-search-path now supports two special values: $sdir and $pdir. + $sdir specifies the default system locations of shared libraries. + $pdir specifies the directory where the libpthread used by the application +### src/gdb/doc/ChangeLog 2011/07/26 16:59:23 1.1202 +### src/gdb/doc/ChangeLog 2011/08/09 12:45:39 1.1203 +## -1,3 +1,8 @@ ++2011-08-09 Phil Muldoon ++ ++ * gdb.texinfo (Python): Document command and function ++ auto-loading. ++ + 2011-07-26 Jan Kratochvil + Eli Zaretskii + +--- src/gdb/doc/gdb.texinfo 2011/07/26 20:57:54 1.851 ++++ src/gdb/doc/gdb.texinfo 2011/08/09 12:45:39 1.852 +@@ -20845,6 +20845,12 @@ + is automatically added to the Python Search Path in order to allow + the Python interpreter to locate all scripts installed at this location. + ++Additionally, @value{GDBN} commands and convenience functions which ++are written in Python and are located in the ++@file{@var{data-directory}/python/gdb/command} or ++@file{@var{data-directory}/python/gdb/function} directories are ++automatically imported when @value{GDBN} starts. ++ + @menu + * Python Commands:: Accessing Python from @value{GDBN}. + * Python API:: Accessing @value{GDBN} from Python. +--- src/gdb/python/python.c 2011/07/22 09:22:50 1.68 ++++ src/gdb/python/python.c 2011/08/09 12:45:40 1.69 +@@ -1302,13 +1302,13 @@ + sys.path.insert (0, gdb.PYTHONDIR)\n\ + \n\ + # Tell python where to find submodules of gdb.\n\ +- gdb.__path__ = [gdb.PYTHONDIR + '/gdb']\n\ ++ gdb.__path__ = [os.path.join (gdb.PYTHONDIR, 'gdb')]\n\ + \n\ + # The gdb module is implemented in C rather than in Python. As a result,\n\ + # the associated __init.py__ script is not not executed by default when\n\ + # the gdb module gets imported. Execute that script manually if it\n\ + # exists.\n\ +- ipy = gdb.PYTHONDIR + '/gdb/__init__.py'\n\ ++ ipy = os.path.join (gdb.PYTHONDIR, 'gdb', '__init__.py')\n\ + if os.path.exists (ipy):\n\ + execfile (ipy)\n\ + \n\ +--- src/gdb/python/lib/gdb/__init__.py 2011/01/01 15:33:26 1.3 ++++ src/gdb/python/lib/gdb/__init__.py 2011/08/09 12:45:40 1.4 +@@ -13,6 +13,29 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-import gdb.command.pretty_printers ++import traceback + +-gdb.command.pretty_printers.register_pretty_printer_commands() ++# Auto-load all functions/commands. ++ ++# Modules to auto-load, and the paths where those modules exist. ++ ++module_dict = { ++ 'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'), ++ 'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command') ++} ++ ++# Iterate the dictionary, collating the Python files in each module ++# path. Construct the module name, and import. ++ ++for module, location in module_dict.iteritems(): ++ if os.path.exists(location): ++ py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py', ++ os.listdir(location)) ++ ++ for py_file in py_files: ++ # Construct from foo.py, gdb.module.foo ++ py_file = module + '.' + py_file[:-3] ++ try: ++ exec('import ' + py_file) ++ except: ++ print >> sys.stderr, traceback.format_exc() +--- src/gdb/python/lib/gdb/command/pretty_printers.py 2011/01/01 15:33:27 1.4 ++++ src/gdb/python/lib/gdb/command/pretty_printers.py 2011/08/09 12:45:40 1.5 +@@ -368,3 +368,5 @@ + InfoPrettyPrinter() + EnablePrettyPrinter() + DisablePrettyPrinter() ++ ++register_pretty_printer_commands() + + + +http://sourceware.org/ml/gdb-patches/2011-08/msg00505.html +Subject: fix "info os processes" race -> crash (ext-run.exp racy FAIL) +http://sourceware.org/ml/gdb-cvs/2011-08/msg00116.html + +### src/gdb/ChangeLog 2011/08/26 17:58:57 1.13281 +### src/gdb/ChangeLog 2011/08/26 18:58:02 1.13282 +## -1,3 +1,8 @@ ++2011-08-26 Pedro Alves ++ ++ * common/linux-osdata.c (get_cores_used_by_process): Don't assume ++ opening /proc/PID/task always succeeds. ++ + 2011-08-26 Aleksandar Ristovski + + * linespec.c (symtab_from_filename): Check for the end of string. +--- src/gdb/common/linux-osdata.c 2011/07/21 23:46:09 1.1 ++++ src/gdb/common/linux-osdata.c 2011/08/26 18:58:04 1.2 +@@ -259,27 +259,29 @@ + + sprintf (taskdir, "/proc/%d/task", pid); + dir = opendir (taskdir); +- +- while ((dp = readdir (dir)) != NULL) ++ if (dir) + { +- pid_t tid; +- int core; ++ while ((dp = readdir (dir)) != NULL) ++ { ++ pid_t tid; ++ int core; + +- if (!isdigit (dp->d_name[0]) +- || NAMELEN (dp) > sizeof ("4294967295") - 1) +- continue; ++ if (!isdigit (dp->d_name[0]) ++ || NAMELEN (dp) > sizeof ("4294967295") - 1) ++ continue; + +- tid = atoi (dp->d_name); +- core = linux_common_core_of_thread (ptid_build (pid, tid, 0)); ++ tid = atoi (dp->d_name); ++ core = linux_common_core_of_thread (ptid_build (pid, tid, 0)); + +- if (core >= 0) +- { +- ++cores[core]; +- ++task_count; ++ if (core >= 0) ++ { ++ ++cores[core]; ++ ++task_count; ++ } + } +- } + +- closedir (dir); ++ closedir (dir); ++ } + + return task_count; + } + + + +Fix for https://bugzilla.redhat.com/show_bug.cgi?id=750341 +http://sourceware.org/ml/gdb-patches/2011-10/msg00570.html + + +http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html + +### src/gdb/ChangeLog 2011/10/20 13:34:13 1.13446 +### src/gdb/ChangeLog 2011/10/20 20:06:11 1.13447 +## -1,3 +1,15 @@ ++2011-10-20 Aleksandar Ristovski ++ ++ * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function ++ arguments by adding OBJFILE. Instead of getting objfile from ++ symbol's symtab, use new argument OBJFILE. ++ * cp-support.h (cp_scan_for_anonymous_namespaces): Changed function ++ arguments by adding OBJFILE. ++ * gdb/dwarf2read.c (new_symbol_full): Change call to ++ cp_scan_for_anonymous_namespaces to match new signature. ++ * gdb/stabsread.c (define_symbol): Change call to ++ cp_scan_for_anonymous_namespaces to match new signature. ++ + 2011-10-20 Phil Muldoon + + PR python/13308 +--- src/gdb/cp-namespace.c 2011/06/29 22:05:15 1.54 ++++ src/gdb/cp-namespace.c 2011/10/20 20:06:13 1.55 +@@ -53,7 +53,8 @@ + anonymous namespace; if so, add an appropriate using directive. */ + + void +-cp_scan_for_anonymous_namespaces (const struct symbol *symbol) ++cp_scan_for_anonymous_namespaces (const struct symbol *const symbol, ++ struct objfile *const objfile) + { + if (SYMBOL_DEMANGLED_NAME (symbol) != NULL) + { +@@ -96,7 +97,7 @@ + namespace given by the previous component if there is + one, or to the global namespace if there isn't. */ + cp_add_using_directive (dest, src, NULL, NULL, NULL, +- &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack); ++ &objfile->objfile_obstack); + } + /* The "+ 2" is for the "::". */ + previous_component = next_component + 2; +--- src/gdb/cp-support.h 2011/08/18 16:17:38 1.45 ++++ src/gdb/cp-support.h 2011/10/20 20:06:13 1.46 +@@ -197,7 +197,8 @@ + const char *processing_current_prefix, + int processing_has_namespace_info); + +-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol); ++extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol, ++ struct objfile *objfile); + + extern struct symbol *cp_lookup_symbol_nonlocal (const char *name, + const struct block *block, +--- src/gdb/dwarf2read.c 2011/10/20 01:11:34 1.576 ++++ src/gdb/dwarf2read.c 2011/10/20 20:06:13 1.577 +@@ -11992,7 +11992,7 @@ + namespaces based on the demangled name. */ + if (!processing_has_namespace_info + && cu->language == language_cplus) +- cp_scan_for_anonymous_namespaces (sym); ++ cp_scan_for_anonymous_namespaces (sym, objfile); + } + return (sym); + } +--- src/gdb/stabsread.c 2011/05/18 16:30:36 1.138 ++++ src/gdb/stabsread.c 2011/10/20 20:06:14 1.139 +@@ -729,7 +729,7 @@ + SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile); + + if (SYMBOL_LANGUAGE (sym) == language_cplus) +- cp_scan_for_anonymous_namespaces (sym); ++ cp_scan_for_anonymous_namespaces (sym, objfile); + + } + p++; diff --git a/gdb/patches/gdb-vla-frame-set.patch b/gdb/patches/gdb-vla-frame-set.patch new file mode 100644 index 000000000..87ddca19d --- /dev/null +++ b/gdb/patches/gdb-vla-frame-set.patch @@ -0,0 +1,91 @@ +commit 51dab9e418741ac7065cd5a6ec9b57285e90227c +https://bugzilla.redhat.com/show_bug.cgi?id=738482 + +--- a/gdb/printcmd.c ++++ b/gdb/printcmd.c +@@ -1981,6 +1981,10 @@ print_variable_and_value (const char *name, struct symbol *var, + struct value_print_options opts; + + val = read_var_value (var, frame); ++ ++ make_cleanup_restore_selected_frame (); ++ select_frame (frame); ++ + get_user_print_options (&opts); + common_val_print (val, stream, indent, &opts, current_language); + } +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-frame.c +@@ -0,0 +1,31 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011 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 . */ ++ ++#include ++ ++int ++main (int argc, char **argv) ++{ ++ char s[2 + argc]; ++ void (*f) (char *) = 0; ++ ++ memset (s, 0, sizeof (s)); ++ s[0] = 'X'; ++ ++ f (s); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-frame.exp +@@ -0,0 +1,38 @@ ++# Copyright 2011 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 . ++ ++set testfile vla-frame ++set executable ${testfile} ++ ++if { [prepare_for_testing ${testfile}.exp ${executable}] } { ++ return -1 ++} ++ ++if ![runto_main] { ++ return -1 ++} ++ ++set test "continue" ++gdb_test_multiple $test $test { ++ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ untested ${testfile}.exp ++ return ++ } ++} ++ ++gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*" diff --git a/gdb/patches/gdb-x86_64-i386-syscall-restart.patch b/gdb/patches/gdb-x86_64-i386-syscall-restart.patch new file mode 100644 index 000000000..d5d6b108b --- /dev/null +++ b/gdb/patches/gdb-x86_64-i386-syscall-restart.patch @@ -0,0 +1,121 @@ +http://sourceware.org/ml/gdb-patches/2009-11/msg00592.html +Subject: [patch] Fix syscall restarts for amd64->i386 biarch + +Hi, + +tested only on recent Linux kernels, it should apply also on vanilla ones. +There were various changes of the kernels behavior in the past. + +FSF GDB HEAD state: +kernel debugger inferior state +x86_64 x86_64 x86_64 PASS +x86_64 x86_64 i386 FAIL without this patch, PASS with this patch +x86_64 i386 i386 PASS on recent kernels + (FAIL: kernel-2.6.31.5-127.fc12.x86_64 - Fedora 12) + (PASS: kernel-2.6.32-0.55.rc8.git1.fc13.x86_64) +i386 i386 i386 PASS + + +Currently gdb.base/interrupt.exp fails on amd64 host running under +--target_board unix/-m32 with: + continue + Continuing. + Unknown error 512 + +: +/* + * These should never be seen by user programs. To return one of ERESTART* + * codes, signal_pending() MUST be set. Note that ptrace can observe these + * at syscall exit tracing, but they will never be left for the debugged user + * process to see. + */ +#define ERESTARTSYS 512 + +"Unknown error 512" printed above is printed by the inferior itself, not by GDB. + +It is because GDB reads it as 0xfffffffffffffe00 but writes it back as +0xfffffe00. ++ /* Sign-extend %eax as during return from a syscall it is being checked ++ for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by ++ interrupt.exp. */ + + +Quote of Roland McGrath from IRC: + +roland: in the user_regset model, there are 64-bit user_regset flavors and +32-bit user_regset flavors, so at the kabi level the (kernel) caller can say +what it means: calls on the 32-bit user_regset flavor will behave as if on +a 32-bit kernel/userland. in ptrace, there is no way for x86_64 ptrace calls +to say "i think of the inferior as being 32 bits, so act accordingly" (tho ppc +and/or sparc have ptr +roland: ace requests that do that iirc) +roland: ergo 64-bit ptrace callers must either save/restore full 64-bits so +the kernel's sign-extension choices are preserved, or else grok magic ways to +expand stored 32-bit register contents to 64-bit values to stuff via 64-bit +ptrace +[...] +roland: there is a "32-bit-flavored task", but it's not really true that it +has 32-bit registers. there is no 32-bit-only userland condition. any task +can always ljmp to the 64-bit code segment and run 64-bit insns including +a 64-bit syscall +roland: so a 64-bit debugger should see and be able to fiddle the full +registers. it can even change cs via ptrace to force the inferior into +running 32 or 64 bit code. + + +Saving whole 64bits for i386 targets on x86_64 hosts does not much match the +GDB architecture as `struct type' for these registers still should be 32bit +etc. Therefore provided just this exception. + +The problem is reproducible only if one does an inferior call during the +interruption to do full inferior save/restore from GDB regcache. + +Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. + + +Thanks, +Jan + + +gdb/ +2009-11-29 Jan Kratochvil + + * amd64-nat.c (amd64_collect_native_gregset): Do not pre-clear %eax. + Sign extend it afterwards. + +--- a/gdb/amd64-nat.c ++++ b/gdb/amd64-nat.c +@@ -131,9 +131,9 @@ amd64_collect_native_gregset (const struct regcache *regcache, + { + num_regs = amd64_native_gregset32_num_regs; + +- /* Make sure %eax, %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and ++ /* Make sure %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and + %eip get zero-extended to 64 bits. */ +- for (i = 0; i <= I386_EIP_REGNUM; i++) ++ for (i = I386_ECX_REGNUM; i <= I386_EIP_REGNUM; i++) + { + if (regnum == -1 || regnum == i) + memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), 0, 8); +@@ -159,4 +159,20 @@ amd64_collect_native_gregset (const struct regcache *regcache, + regcache_raw_collect (regcache, i, regs + offset); + } + } ++ ++ if (gdbarch_ptr_bit (gdbarch) == 32) ++ { ++ /* Sign-extend %eax as during return from a syscall it is being checked ++ for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by ++ interrupt.exp. */ ++ ++ int i = I386_EAX_REGNUM; ++ ++ if (regnum == -1 || regnum == i) ++ { ++ void *ptr = regs + amd64_native_gregset_reg_offset (gdbarch, i); ++ ++ *(int64_t *) ptr = *(int32_t *) ptr; ++ } ++ } + } + -- 2.39.2