--- gdb-7.0.1.orig/debian/changelog.old +++ gdb-7.0.1/debian/changelog.old @@ -0,0 +1,6 @@ +gdb (4.16-1) unstable; urgency=low + + * Updated to new upstream version (Bug#4373) + * Added a simple extended description (Bug#3599) + + -- David Engel --- gdb-7.0.1.orig/debian/gdbinit +++ gdb-7.0.1/debian/gdbinit @@ -0,0 +1 @@ +# System-wide GDB initialization file. --- gdb-7.0.1.orig/debian/rules +++ gdb-7.0.1/debian/rules @@ -0,0 +1,234 @@ +#!/usr/bin/make -f + +DEB_BUILDDIR := $(shell pwd)/objdir +DEB_DH_INSTALL_SOURCEDIR := $(shell pwd)/debian/tmp + +# This implements the .deb package creation using debhelper. +include /usr/share/cdbs/1/rules/debhelper.mk + +# This implements building using a configure script and Makefile. +include /usr/share/cdbs/1/class/autotools.mk + +# Quilt-based patches in debian/patches. +include /usr/share/cdbs/1/rules/patchsys-quilt.mk + +# Override CDBS's default CFLAGS, which also includes -Wall; gdb +# does not handle -Wunused well with -Werror, but defaults to +# -Werror. +unexport CFLAGS +CFLAGS = -g $(DEB_OPT_FLAG) + +# Always install into debian/tmp, even if we are only building one package. +DEB_DESTDIR := $(shell pwd)/debian/tmp + +install = /usr/bin/install -p + +# Rather paranoid than sorry. Make the shell exit with an error if an +# untested command fails. +SHELL += -e + +DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM) +DEB_HOST_GNU_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU) +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) + +# Cross configuration support. Check for an environment variable +# $GDB_TARGET, or a file debian/target. +ifndef GDB_TARGET +DEBIAN_TARGET_FILE := $(strip $(shell cat debian/target 2>/dev/null)) +ifneq ($(DEBIAN_TARGET_FILE),) +GDB_TARGET := $(DEBIAN_TARGET_FILE) +endif +endif + +DEB_TARGET_ARCH := $(shell dpkg-architecture -f \ + -a$(GDB_TARGET) -qDEB_HOST_ARCH 2>/dev/null) +DEB_TARGET_GNU_TYPE := $(shell dpkg-architecture -f \ + -a$(DEB_TARGET_ARCH) -qDEB_HOST_GNU_TYPE 2>/dev/null) +DEB_TARGET_ALIAS ?= $(DEB_TARGET_GNU_TYPE) + +ifeq ($(DEB_TARGET_ARCH),) +$(error GDB_TARGET value "$(GDB_TARGET)" is not a valid Debian architecture) +endif + +ifdef GDB_TARGET + DEB_CROSS = yes + # TP: Target Prefix. Used primarily as a prefix for cross tool + # names (e.g. powerpc-linux-gcc). + # TS: Target Suffix. Used primarily at the end of cross compiler + # package names (e.g. gcc-powerpc). + TP = $(DEB_TARGET_ALIAS)- + TS = -$(DEB_TARGET_ALIAS) + CROSS_FORCE = FORCE +else +ifneq (,$(filter $(DEB_HOST_ARCH),i386 powerpc sparc s390)) + build64 = yes + CC64 = gcc -m64 + CFLAGS64 = $(CFLAGS) + BUILDDIR64 = objdir64 + ifeq ($(DEB_HOST_ARCH),i386) + HOST64 = x86_64-linux-gnu + endif + ifeq ($(DEB_HOST_ARCH),powerpc) + HOST64 = powerpc64-linux-gnu + endif + ifeq ($(DEB_HOST_ARCH),sparc) + HOST64 = sparc64-linux-gnu + endif + ifeq ($(DEB_HOST_ARCH),s390) + HOST64 = s390x-linux-gnu + endif +endif +endif + +run_tests := yes + +ifneq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) + run_tests := no +endif + +ifeq (,$(findstring linux, $(DEB_HOST_GNU_SYSTEM))) + run_tests := no +endif + +ifeq ($(DEB_HOST_GNU_CPU),ia64) + arch_config_args := --with-libunwind +endif + +ifdef GDB_TARGET + run_tests := no + + arch_config_args += --program-prefix=$(TP) \ + --target=$(DEB_TARGET_ALIAS) --with-sysroot=/usr/$(DEB_TARGET_ALIAS) +else + # To avoid file conflicts, only enable the global gdbinit file for native + # debuggers. + arch_config_args += --with-system-gdbinit=/etc/gdb/gdbinit +endif + +INSTALL = $(install) +export INSTALL + +# We pass srcdir explicitly to avoid an extra '/.' at the end of it. That +# causes a harmless, but ugly, testsuite failure in maint.exp. +EXTRA_FLAGS := --disable-gdbtk --disable-shared --enable-tui \ + --srcdir=$(shell pwd) --with-system-readline \ + $(arch_config_args) --build=$(DEB_HOST_GNU_TYPE) + +# Debian does not include 64-bit expat packages yet, so --with-expat +# is here rather than in EXTRA_FLAGS. Similarly Python. +DEB_CONFIGURE_EXTRA_FLAGS := --host=$(DEB_HOST_GNU_TYPE) $(EXTRA_FLAGS) \ + --with-expat --with-python + +# Support parallel= in DEB_BUILD_OPTIONS (see #209008) +COMMA = , +ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) + NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) +endif + +DEB_MAKE_BUILD_TARGET = $(NJOBS) all +distribution := $(shell lsb_release -is | tr A-Z a-z) + +post-patches:: + if ! test -f gdb/version.in.backup; then \ + mv -f gdb/version.in gdb/version.in.backup; \ + sed -e 's/$$/-$(distribution)/' < gdb/version.in.backup > gdb/version.in; \ + fi + +# This should probably be common-post-build-arch, but that runs during +# install, under fakeroot, in CDBS 0.4.21. +build/gdb$(TS):: check-stamp + $(MAKE) -C $(DEB_BUILDDIR) info + $(MAKE) -C $(DEB_BUILDDIR)/gdb/doc refcard.dvi refcard.ps + +build/gdb64:: build64-stamp + +build64-stamp: + mkdir -p $(BUILDDIR64) + cd $(BUILDDIR64) && CC="$(CC64)" CFLAGS="$(CFLAGS64)" AR=ar \ + ../configure $(EXTRA_FLAGS) --host=$(HOST64) $(if $(filter sparc, $(DEB_HOST_ARCH)),--disable-werror) + cd $(BUILDDIR64) && $(DEB_MAKE_ENVVARS) $(MAKE) $(NJOBS) + touch $@ + +check-stamp: +ifeq ($(run_tests),yes) + -ulimit -c unlimited; \ + $(MAKE) -C objdir/gdb check +endif + touch $@ + +clean:: + rm -f check-stamp build64-stamp + rm -rf objdir $(BUILDDIR64) + + if test -f gdb/version.in.backup; then \ + mv -f gdb/version.in.backup gdb/version.in; \ + fi + +# # For snapshots this is appropriate; careful of release tarballs +# # which include .gmo files. +# find -type f -name '*.gmo' | xargs rm -f + + # Prevent gratuitous rebuilds of the BFD documentation, since it + # updates the copy in the source directory. + find bfd -name bfd.info\* | xargs --no-run-if-empty touch + +binary-post-install/gdb$(TS) :: + if [ -x debian/tmp/usr/bin/run ]; then \ + mv debian/tmp/usr/bin/run \ + debian/gdb$(TS)/usr/bin/$(DEB_TARGET_ALIAS)-run; \ + mv debian/tmp/usr/share/man/man1/run.1 \ + debian/gdb$(TS)/usr/share/man/man1/$(DEB_TARGET_ALIAS)-run.1; \ + fi +ifeq ($(run_tests),yes) + install -d debian/gdb$(TS)/usr/share/doc/gdb + install -m 644 objdir/gdb/testsuite/gdb.sum \ + debian/gdb$(TS)/usr/share/doc/gdb/check.log +endif + +ifneq ($(DEB_CROSS),yes) + # Gcore is only useful for native GDB. + $(INSTALL) -m 755 -o root -g root \ + gdb/gdb_gcore.sh debian/gdb$(TS)/usr/bin/$(TP)gcore + + # Only ship a global gdbinit for the native GDB. + install -d debian/gdb$(TS)/etc/gdb + install -m 644 debian/gdbinit debian/gdb$(TS)/etc/gdb/ +endif + + rm -f debian/gdb$(TS)/usr/bin/$(TP)gdbtui + install -m 755 debian/gdbtui debian/gdb$(TS)/usr/bin/$(TP)gdbtui + +binary-post-install/gdb64 :: + install -d debian/gdb64/usr/bin + install -s -m 755 $(BUILDDIR64)/gdb/gdb debian/gdb64/usr/bin/gdb64 + dh_link -pgdb64 usr/share/man/man1/gdb.1 usr/share/man/man1/gdb64.1 + +binary-post-install/libgdb-dev :: + install -m 644 $(DEB_BUILDDIR)/gdb/libgdb.a debian/libgdb-dev/usr/lib/ + if test -e $(DEB_BUILDDIR)/sim/*/libsim.a; then \ + install -m 644 $(DEB_BUILDDIR)/sim/*/libsim.a debian/libgdb-dev/usr/lib/; \ + fi + +debian/control:: debian/control.in $(CROSS_FORCE) + cat debian/control.in \ + | sed "s/@kfreebsd@/`type-handling any kfreebsd`/g" \ + | sed "s/@gnu@/`type-handling any gnu`/g" \ + | sed "s/@TS@/$(TS)/g" \ + > debian/control +ifeq ($(DEB_CROSS),yes) + sed -i "/Package: gdb64/,\$$ d" debian/control + cp debian/gdb.install debian/gdb$(TS).install +endif + +DEB_INSTALL_DOCS_gdb$(TS) = gdb/NEWS gdb/README gdb/doc/refcard.tex \ + objdir/gdb/doc/refcard.dvi objdir/gdb/doc/refcard.ps +DEB_INSTALL_CHANGELOGS_gdb$(TS) = gdb/ChangeLog +ifneq ($(DEB_CROSS),yes) +DEB_INSTALL_MANPAGES_gdb$(TS) = debian/gcore.1 +endif + +DEB_INSTALL_DOCS_libgdb-dev = gdb/NEWS gdb/README +DEB_INSTALL_CHANGELOGS_libgdb-dev = gdb/ChangeLog + +.PHONY: FORCE +FORCE: --- gdb-7.0.1.orig/debian/copyright +++ gdb-7.0.1/debian/copyright @@ -0,0 +1,27 @@ +This is the Debian GNU/Linux packaged version of the GNU debugger, GDB. + +Earlier versions of this package were assembled by David Engel +, Stuart Lamble , and others. + +GDB is 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 . + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses'. + +The file `gdb/doc/observer.texi' is normally distributed under the +GNU Free Documentation License, but certain lines from it are also +permitted to be distributed under the GPL. Only those lines are included in +this package. --- gdb-7.0.1.orig/debian/gdb.install +++ gdb-7.0.1/debian/gdb.install @@ -0,0 +1,2 @@ +usr/bin/*gdb* +usr/share/man/man1/*gdb*.1 --- gdb-7.0.1.orig/debian/gcore.1 +++ gdb-7.0.1/debian/gcore.1 @@ -0,0 +1,34 @@ +.TH gcore "1" "May 2007" "gdb 6.8" "GNU Tools" +.SH NAME +gcore \- Generate a core file for a running process +.SH SYNOPSIS +.B gcore +[-o \fIfilename\fR] \fIpid\fR +.SH DESCRIPTION +.\" Add any additional description here +.PP +gcore generates a core file for the process specified by its process ID, +\fIpid\fR. By default, the core file is written to core.\fIpid\fR, in the +current directory. +.TP +\fB\-o\fR \fIfilename\fR +write core file to \fIfilename\fR instead of core.\fIpid\fR +.SH COPYING +Copyright \(co 2003, 2005, 2007, 2008 Free Software Foundation, Inc. +.PP +Permission is granted to make and distribute verbatim copies of this manual +provided the copyright notice and this permission notice are preserved on +all copies. +.PP +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. +.PP +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be included in translations approved +by the Free Software Foundation instead of in the original English. +.SH "SEE ALSO" +.BR gdb (1), +.BR core (5) --- gdb-7.0.1.orig/debian/README.Debian +++ gdb-7.0.1/debian/README.Debian @@ -0,0 +1,12 @@ +GDB is a complex program. There is an excellent Info manual (`info gdb'), +which is available in the separate gdb-doc package. gdb-doc is not part of +Debian main; it is available in the non-free distribution (because it is +covered by the GNU Free Documentation License). + +GDB's documentation is also available online. Documentation from the +most recent release branch may be found at: + http://sourceware.org/gdb/onlinedocs/gdb.html + +There are also a number of books and tutorials devoted to GDB. One +particularly useful guide is Peter Jay Salzman's, at: + http://www.dirac.org/linux/gdb/ --- gdb-7.0.1.orig/debian/compat +++ gdb-7.0.1/debian/compat @@ -0,0 +1 @@ +7 --- gdb-7.0.1.orig/debian/libgdb-dev.install +++ gdb-7.0.1/debian/libgdb-dev.install @@ -0,0 +1 @@ +usr/lib/lib*.a usr/lib/gdb/ --- gdb-7.0.1.orig/debian/changelog +++ gdb-7.0.1/debian/changelog @@ -0,0 +1,1431 @@ +gdb (7.0.1-0ubuntu1) lucid; urgency=low + + * New upstream version. + + -- Matthias Klose Thu, 31 Dec 2009 10:07:48 +0100 + +gdb (7.0-1ubuntu2) lucid; urgency=low + + * [arm] Prevent disassembler from aborting on an invalid Thumb2 instruction, + taken from the trunk. + + -- Matthias Klose Tue, 15 Dec 2009 14:41:05 +0100 + +gdb (7.0-1ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - debian/rules: on sparc, configure the 64bit build with --disable-werror. + - Work around a build failure on the ia64 buildd. + - PIE support. + - Add patch to handle debug_info less frames better. + - Fix some typos in messages. + - reduce build-id verbosity. + - fixup PPC auxv prototype. + * Update to the 7.0 branch 20091120. + - Add Thumb2 debugging for armel. + + -- Matthias Klose Fri, 20 Nov 2009 14:48:57 -0600 + +gdb (7.0-1) unstable; urgency=low + + * New upstream release (Closes: #550567). + * Order options alphabetically in the man page (Closes: #540811). + + -- Daniel Jacobowitz Sun, 11 Oct 2009 17:16:26 -0400 + +gdb (7.0-0ubuntu1) karmic; urgency=low + + * 7.0 final release. + - Fix PR gdb/10649. + + -- Matthias Klose Fri, 09 Oct 2009 09:27:53 +0200 + +gdb (6.8.92-0ubuntu1) karmic; urgency=low + + * 7.0 prerelease 2. + + -- Matthias Klose Thu, 01 Oct 2009 15:04:44 +0200 + +gdb (6.8.90.20090918-0ubuntu2) karmic; urgency=low + + * Update gdb-workaround-rh-stack-off.patch: + - reduce build-id verbosity. + - fixup PPC auxv prototype. + + -- Kees Cook Sat, 19 Sep 2009 10:26:41 -0700 + +gdb (6.8.90.20090918-0ubuntu1) karmic; urgency=low + + [ Matthias Klose ] + * Merge with Debian; remaining changes: + - debian/rules: on sparc, configure the 64bit build with --disable-werror. + * Update to the 7.0 release branch. + + [ Kees Cook ] + * Add patches to support PIE, thanks to RH's 6.8.91.20090917 branch: + - gdb-6.3-test-pie-20050107.patch + - gdb-6.5-bz203661-emit-relocs.patch + - gdb-workaround-rh-stack-on.patch (workaround lack of Archer, CRC) + - gdb-6.6-buildid-locate.patch + - gdb-6.3-pie-20050110.patch + - gdb-workaround-rh-stack-off.patch (undo workarounds) + + -- Matthias Klose Sat, 19 Sep 2009 15:38:43 +0000 + +gdb (6.8.50.20090628-4) unstable; urgency=low + + * Mention online documentation in README.Debian (Closes: #537795). + * Fix GNU/Hurd support (Closes: #539351). + * Depend on libreadline-dev and lib64readline6-dev. + + -- Daniel Jacobowitz Mon, 14 Sep 2009 16:17:50 -0400 + +gdb (6.8.50.20090628-3) unstable; urgency=low + + * Remove stray "set -x" from gdbtui script. + + -- Daniel Jacobowitz Mon, 13 Jul 2009 16:49:41 -0400 + +gdb (6.8.50.20090628-2) unstable; urgency=low + + * Re-enable gobjc testing on armel (Closes: #497161). + * Do not install an extra copy of the GDB man page in cross-debugger + packages (Closes: #492846). + * Add i386 %ebp backtrace patch from Michael Matz (Closes: #498030). + This improves backtraces on 32-bit programs with missing debug info + for some functions on the stack. + * Replace the separate gdbtui binary with a shell script (suggested + by Matthias Klose). + * Support parallel= in DEB_BUILD_OPTIONS (from Matthias Klose). + * Support nocheck in DEB_BUILD_OPTIONS (from Matthias Klose). + * Run the testsuite on linux-gnueabi and linux-gnulp systems also + (from Matthias Klose). + * Package the DejaGNU .sum file instead of part of the build log. + It's bigger, but more useful (especially with parallel=). + + -- Daniel Jacobowitz Mon, 06 Jul 2009 14:52:31 -0400 + +gdb (6.8.50.20090628-1ubuntu3) karmic; urgency=low + + * Refresh PIE support patches to gain analysis of PIE core files. + + -- Kees Cook Tue, 14 Jul 2009 13:20:57 -0700 + +gdb (6.8.50.20090628-1ubuntu2) karmic; urgency=low + + * Replace the gdbtui binary by a shell script. LP: #244065. + * Enable parallel builds. + + -- Matthias Klose Mon, 06 Jul 2009 13:59:42 +0200 + +gdb (6.8.50.20090628-1ubuntu1) karmic; urgency=low + + * Merge with Debian; remaining changes: + - debian/rules: on sparc, configure the 64bit build with --disable-werror. + - Support nocheck and parallel= in DEB_BUILD_OPTIONS. + - lpia fix for running the check target. + - Work around a build failure on the ia64 buildd. + * Disable patches (not yet updated): pie-support-alt, pie-support-tests, + handle-nodebuginfo-better. + + -- Matthias Klose Mon, 06 Jul 2009 09:51:58 +0200 + +gdb (6.8.50.20090628-1) unstable; urgency=low + + * New snapshot from trunk. The experimental packages used the + archer-tromey-python branch; the whole branch has not been merged + to trunk, but significant portions of it have, and will be in GDB 7. + So this includes some Python scripting support. Other highlights + since the last experimental package: + - Reverse debugging commands. With a remote target that supports + reverse debugging, you can step backwards as easily as forwards. + - Process record and replay, a native Linux implementation of + reverse debugging. Only 32-bit IA32 Linux is currently supported. + - MIPS/Linux hardware watchpoint support. + - Multi-byte and wide character set support, including wchar_t display. + - Inlined function support, including in backtrace and step/next/finish. + - Improved C++ template name parsing. + - Non-stop debugging (some threads remain running while others + are stopped in the debugger). Only implemented so far for i386, + x86-64, and powerpc. + - A bug fix for discontiguous code, e.g. as found in the Linux kernel + (Closes: #513816). + - A build fix that affected SPARC (Closes: #512121). + - A build fix for casts on hurd-i386 (Closes: #494839). + - A fix for debugging multi-threaded programs that call exec, including + Eclipse with the Sun JVM (Closes: #490046). + * Removed thread-db-multiple-libraries.patch. This let one GDB work with + both LinuxThreads and NPTL, but no Debian platform has both now. + * GDB now reads /etc/gdb/gdbinit at startup (Closes: #33187). + * Ship required libraries (libbfd, libopcodes, and libiberty) in + /usr/lib/gdb in the libgdb-dev package, in case binutils-dev's versions + are not close enough (Closes: #509873). + * Add dev package dependencies to libgdb-dev. + + -- Daniel Jacobowitz Sun, 05 Jul 2009 16:25:07 -0400 + +gdb (6.8.50.20090519.python-1) experimental; urgency=low + + * New snapshot from archer-tromey-python branch. + * Update debhelper compatibility level to 7. + * Update to Standards-Version: 3.8.1. + + -- Daniel Jacobowitz Thu, 04 Jun 2009 09:38:13 -0400 + +gdb (6.8.50.20090116.python-1) experimental; urgency=low + + * New snapshot from archer-tromey-python branch. + * Make sure that Python is enabled for the main gdb package. + + -- Daniel Jacobowitz Fri, 12 Dec 2008 11:30:41 -0500 + +gdb (6.8.50.20081210.python-1) experimental; urgency=low + + * New snapshot from archer-tromey-python branch. + + -- Daniel Jacobowitz Wed, 10 Dec 2008 21:36:26 -0500 + +gdb (6.8.50.20081120.python-1) experimental; urgency=low + + * Package archer-tromey-python branch for experimental. Highlights since + GDB 6.8 (for more, see the NEWS file): + - Python scripting support. This is experimental; the interfaces + are subject to change. Some example scripts are packaged, including + STL pretty-printers for libstdc++. + - Improved preprocessor macro support. + - Non-stop debugging support (for 32-bit i386 only). You can stop just + one thread of interest while the others continue to run. + - Improved tab completion, including C structure fields. + - Faster remote debugging. + - Compressed debug information support; the new "gold" linker can generate + compressed debug sections. + - New "find" command to search memory. + - Native i386 debugger does not get confused about watchpoints when + using "target remote" (Closes: #513678). + * Build depend on zlib1g-dev and python-dev. + * Removed bfd-get-mtime-less.patch, gdb-rbreak-quoting.patch, + ia64-array-bound.patch, cp-support-uninit.patch, + and m68k-nat-build-fix.patch, merged upstream. + * Build depend on procps for testsuite cleanup calls to "kill". + * Remove use of -p0 in series file (Closes: #484945). + + -- Daniel Jacobowitz Fri, 28 Nov 2008 14:28:47 -0500 + +gdb (6.8-3ubuntu2) intrepid; urgency=low + + * debian/rules: on sparc, configure the 64bit build with --disable-werror. + * Reapply debian/patches/gdb-cvs-reinit_frame_cache.patch. LP: #196274. + + -- Matthias Klose Tue, 24 Jun 2008 15:42:23 +0200 + +gdb (6.8-3ubuntu1) intrepid; urgency=low + + * Merge with Debian; remaining changes: + - PIE support. + - dwarf2-stack-boundry.diff - security fix for CVE-2006-4146. + - Add patch to handle debug_info less frames better. + - Fix some typos in messages. + * Fix build errors with gcc-4.3. + * TODO: Fix testcases failing with default hardening options. + + -- Matthias Klose Tue, 24 Jun 2008 15:42:23 +0200 + +gdb (6.8-3) unstable; urgency=low + + * Initialize some uninitialized variables (Closes: #479561). + * Drop gdb-arm and insight conflict/replace. + * Fix build on m68k. + + -- Daniel Jacobowitz Wed, 07 May 2008 08:40:02 -0400 + +gdb (6.8-2) unstable; urgency=low + + * Make removal of stamp files the first action of the clean target + (from Justin Pryzby). + * Correct array access in ia64 port to fix build failure. + * Fix GDB_TARGET support (reported by Fathi BOUDRA). + * Update gcj build dependencies (Closes: #477863, #479111). + * Add a man page for gcore, from Nicolas Bonifas (Closes: #479066). + + -- Daniel Jacobowitz Fri, 02 May 2008 18:28:37 -0400 + +gdb (6.8-1ubuntu2) hardy-proposed; urgency=low + + [ Robert Collins ] + * Add patch from Michael Matz to handle debug_info less frames better. + Origin of patch: https://bugzilla.novell.com/show_bug.cgi?id=390722#c25 + (LP: #111869). + + [ Martin Pitt ] + * Port above patch for amd64, too, since it suffers from the same problem. + + -- Robert Collins Mon, 26 May 2008 11:49:07 +0200 + +gdb (6.8-1ubuntu1) hardy; urgency=low + + * Merge with Debian; remaining changes: + - PIE support. + - dwarf2-stack-boundry.diff - security fix for CVE-2006-4146. + * Remove patches merged upstream. + * Update pie-support patch. + + -- Matthias Klose Tue, 01 Apr 2008 15:25:20 +0200 + +gdb (6.8-1) unstable; urgency=low + + * New upstream release. + - Remove patches merged upstream. + - GDB automatically sets breakpoints in every copy of C++ templates + and cloned constructors (Closes: #421540). + - Improved support for debugging optimized code - local variables are + displayed more often. + - Automatically recognizes ObjC sources (Closes: #462882). + * Backported patch to fix quoting for rbreak (Closes: #357319). + * Adjust copyright file, quilt build dependency, and oldest changelog entry + on lintian's advice. + * Add libsim.a to libgdb-dev (Closes: #473295). + + -- Daniel Jacobowitz Thu, 27 Mar 2008 18:13:39 -0400 + +gdb (6.7.1-2ubuntu3) hardy; urgency=low + + * debian/patches/pie-support.patch: updated for 6.7.1; works for + attach and core, but not "run". + * debian/patches/pie-support-tests.patch: re-enabled, some failures remain. + * debian/rules: fix logic to enable running testsuite by default. + + -- Kees Cook Thu, 20 Mar 2008 02:00:27 -0700 + +gdb (6.7.1-2ubuntu2) hardy; urgency=low + + * debian/patches/gdb-cvs-reinit_frame_cache.patch: upstream fix for SEGV + when dealing with register caches (LP: #196274). + + -- Kees Cook Fri, 07 Mar 2008 09:51:58 -0800 + +gdb (6.7.1-2ubuntu1) hardy; urgency=low + + * Merge with Debian; remaining changes: + - Do not depend on type-handling. + - PIE support. + - dwarf2-stack-boundry.diff - security fix for CVE-2006-4146. + * Add patch from Ulrich Weigand to fix stepping over shared library + functions on PowerPC (Closes: #432461). LP: #137312. + + -- Matthias Klose Mon, 14 Jan 2008 17:32:12 +0100 + +gdb (6.7.1-2) unstable; urgency=low + + * Add patch from Ulrich Weigand to fix stepping over shared library + functions on PowerPC (Closes: #432461). + * Add libgdb-dev package for fp-ide (Closes: #458250). + * Avoid gcc-4.3 uninitialized warnings (Closes: #455669). + * Updated Standards-Version to 3.7.3 + - Correct Apps -> Applications in gdb.menu. + + -- Daniel Jacobowitz Wed, 02 Jan 2008 08:49:43 -0500 + +gdb (6.7.1-1ubuntu1) hardy; urgency=low + + * Merge with Debian; remaining changes: + - Do not depend on type-handling. + - PIE support. + - dwarf2-stack-boundry.diff - security fix for CVE-2006-4146. + * Add build-dependency on lib64expat1-dev. + + -- Matthias Klose Tue, 04 Dec 2007 09:13:57 +0100 + +gdb (6.7.1-1) unstable; urgency=low + + * New upstream release. + - Correct makeinfo version check (Closes: #453202). + * Merge Ubuntu support for a gdb64 package (Closes: #254270). + * Run the testsuite on all GNU/Linux platforms. + * Remove old support for skipping thread tests. + * Add an expat build dependency and add --with-expat. + * Update copyright notice. + * Do not freeze on division by zero (Closes: #414887). + * Rewrite HPPA kernel offsets patch to support HPPA64. + * Include Vladimir Prus's varobj fix for kdevelop (Closes: #443080). + + -- Daniel Jacobowitz Mon, 03 Dec 2007 10:12:27 -0500 + +gdb (6.6.dfsg.90.20070912-1) unstable; urgency=low + + * New upstream snapshot (pre-release for GDB 6.7). + - Patches 10.selected-frame.patch, dwarf2-long-size.patch merged upstream. + - Backports unwind-check-pc-regnum.patch, ia64-unwind-signedness.patch + removed. + - Patch 13.use-dynamic-readline.patch replaced by + --with-system-readline. + - Patch sim-destdir.patch unnecessary. + * Disable gcj and gobjc build dependencies for armel (Closes: #441741). + * Replace tetex-bin build dependency with texlive-base. + * Include kernel offsets for HPPA. + + -- Daniel Jacobowitz Sat, 15 Sep 2007 13:40:34 -0400 + +gdb (6.6.dfsg-3) unstable; urgency=low + + * Correct signedness error in ia64-tdep.c (Closes: #423631) (again). + + -- Daniel Jacobowitz Fri, 24 Aug 2007 15:48:11 -0400 + +gdb (6.6.dfsg-2) unstable; urgency=low + + * Check PC_REGNUM before using it (Closes: #423631). + + -- Daniel Jacobowitz Thu, 23 Aug 2007 22:26:20 -0400 + +gdb (6.6.dfsg-1ubuntu7) gutsy; urgency=low + + * Cross-compile gdb64. + * Don't try to install gdbserver on architectures where it doesn't exist. + + -- Matthias Klose Mon, 10 Sep 2007 21:28:07 +0200 + +gdb (6.6.dfsg-1ubuntu6) gutsy; urgency=low + + * Fix build failures on targets only building gdb. + * Remove the gdb32 package. + * Fix typos in message strings (LP: #63200). + + -- Matthias Klose Fri, 07 Sep 2007 18:06:20 +0000 + +gdb (6.6.dfsg-1ubuntu5) gutsy; urgency=low + + * Build a gdb64/gdb32 package on biarch architectures. LP: #25559. + * Set Ubuntu maintainer address. + + -- Matthias Klose Wed, 15 Aug 2007 19:01:05 +0000 + +gdb (6.6.dfsg-1ubuntu4) gutsy; urgency=low + + * Fix register definitions for hppa (Randolph Chung). + + -- Matthias Klose Fri, 03 Aug 2007 17:11:20 +0000 + +gdb (6.6.dfsg-1ubuntu3) gutsy; urgency=low + + * Run the testsuite on lpia. + + -- Matthias Klose Sat, 28 Jul 2007 18:32:30 +0200 + +gdb (6.6.dfsg-1ubuntu2) feisty; urgency=low + + * Reenable the workaround for a build failure on the ia64 buildd. + + -- Matthias Klose Sun, 11 Feb 2007 23:34:47 +0100 + +gdb (6.6.dfsg-1ubuntu1) feisty; urgency=low + + * Merge with Debian unstable; remaining changes: + - Do not depend on type-handling. + - PIE support. + - dwarf2-stack-boundry.diff - security fix for CVE-2006-4146. + + -- Matthias Klose Sun, 11 Feb 2007 14:54:38 +0100 + +gdb (6.6.dfsg-1) unstable; urgency=low + + [ Matthias Klose ] + * New upstream version. + - Prints a newline after EOF (Closes: #233467). + * sim-destdir.patch, gdbinit-ownership.patch, bfd-get-mtime-less.patch, + pie-support.patch, thread-db-multiple-libraries.patch: Update. + * thread-db-live-threads.patch, fork-context-switch.patch: Remove, + applied upstream. + + [ Daniel Jacobowitz ] + * Merge changes from Matthias Klose (thanks). + * Refresh all patches. + * Fix "corrupted DWARF expression" error (Closes: #405116). + * Do not crash if loading libthread_db failed (Closes: #408402). + * Initial support for building cross-GDB packages, based on the work of + Raphael Bossek and Kazuhiro Inaoka (Closes: #313340, #343419, #373927). + * Change priority to optional (since ftpmaster did). + + -- Daniel Jacobowitz Sat, 27 Jan 2007 21:59:06 -0500 + +gdb (6.6-0ubuntu1) feisty; urgency=low + + * New upstream version. + * sim-destdir.patch, gdbinit-ownership.patch, bfd-get-mtime-less.patch, + pie-support.patch, thread-db-multiple-libraries.patch: Update. + * thread-db-live-threads.patch, fork-context-switch.patch, + glibc2.5-gnu-hash.patch: Remove, applied upstream. + + -- Matthias Klose Thu, 4 Jan 2007 15:11:39 +0100 + +gdb (6.5.dfsg-2ubuntu3) feisty; urgency=low + + * Add PIE support, taken from Fedora patch bundle: + - debian/patches/pie-support.patch: core PIE support. + - debian/patches/pie-support-tests.patch: PIE operational tests. + * debian/rules: drop use of "tee" to solve strange hangs on i386/amd64. + + -- Kees Cook Thu, 14 Dec 2006 15:05:33 -0800 + +gdb (6.5.dfsg-2ubuntu2) feisty; urgency=low + + * Add debian/patches/glibc2.5-gnu-hash.patch: + - Teach gdb how to deal with glibc 2.5's .gnu.hash sections, so that gdb + works on feisty at all. + - Patch taken from upstream CVS head. + - Closes: LP#73724 + + -- Martin Pitt Thu, 14 Dec 2006 09:17:51 +0100 + +gdb (6.5.dfsg-2ubuntu1) feisty; urgency=low + + * Merge from debian unstable. Changes left: + - type-handling + - 'dwarf2-stack-boundry.diff' - security fix for CVE-2006-4146 + + -- Michael Vogt Thu, 23 Nov 2006 06:56:42 +0100 + +gdb (6.5.dfsg-2) unstable; urgency=low + + * Backport a patch to fix GDB segfaults on threaded programs. + * Backport a patch to fix errors on fork/vfork in threaded programs. + + -- Daniel Jacobowitz Thu, 16 Nov 2006 11:06:50 -0500 + +gdb (6.5.dfsg-1) unstable; urgency=low + + * New upstream release (Closes: #386586). + * Update Standards-Version to 3.7.2 (no changes required). + * Mention --args in the man page (Closes: #394150). + * Mention gdbtui and -tui (Closes: #362795). + * Correctly detect changed executables when rerunning. + + -- Daniel Jacobowitz Sun, 5 Nov 2006 18:33:48 -0500 + +gdb (6.4.90.dfsg-1ubuntu3) edgy; urgency=low + + * SECURITY UPDATE: fix local arbitrary code execution in DWARF processing. + * Add 'dwarf2-stack-boundry.diff': limits the DWARF operation stack. + Without this, arbitrary code execution would be possible if a user + were tricked into debugging an executable with malicious DWARF headers. + * References: + CVE-2006-4146 + https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=204845 + + -- Kees Cook Thu, 28 Sep 2006 11:13:50 -0700 + +gdb (6.4.90.dfsg-1ubuntu2) edgy; urgency=low + + * debian/patches/from_upstream_fix_context_switch.patch: + - upstream patch (http://sourceware.org/ml/gdb-cvs/2006-09/msg00053.html), + should fix a multi-threading issue (Ubuntu: #56391) + + -- Sebastien Bacher Fri, 29 Sep 2006 17:42:43 +0200 + +gdb (6.4.90.dfsg-1ubuntu1) edgy; urgency=low + + * Merge from debian unstable: + - left only type-handling bit. + + -- Fabio M. Di Nitto Tue, 04 Jul 2006 07:46:08 +0200 + +gdb (6.4.90.dfsg-1) unstable; urgency=low + + * New upstream snapshot (GDB 6.5 prerelease). + - BFD build fix for GCC 4.2 (Closes: #364124). + - xstrvprintf error message corrected (Closes: #296483). + - Rewritten printf command (Closes: #186037, #231162). + - Build fix for hurd-i386 (Closes: #345108). + * Split the GDB package into DFSG and non-DFSG portions (Closes: #212522). + The documentation has been moved to the new gdb-doc package, which + this one Suggests. + - Remove packaging for info files. + - Remove GFDL section from debian/copyright. + - Update README.Debian. + * Correct control.in to also use libreadline5-dev. + * Update type-handling usage. + * Update copyright file with the new FSF address. + * Update gcj build dependency (allow mips and mipsel, skip kfreebsd) + (Closes: #343199). + + -- Daniel Jacobowitz Tue, 6 Jun 2006 09:23:45 -0400 + +gdb (6.4-1ubuntu5) dapper; urgency=low + + Changes by David S. Miller: + + * Fix linux_nat regression introduced with the last upload. + + -- Fabio M. Di Nitto Tue, 09 May 2006 07:48:51 +0200 + +gdb (6.4-1ubuntu4) dapper; urgency=low + + Changes by David S. Miller: + + * Fix core file generation on sparc. + + * sparc patches split and clean up as applied upstream. + + -- Fabio M. Di Nitto Sat, 06 May 2006 06:44:31 +0200 + +gdb (6.4-1ubuntu3) dapper; urgency=low + + Changes by David S. Miller: + + * Fix signal frame handling on sparc and use dwarf2 frame unwinding on + sparc/linux: + - Add patch sparc-dwarf2-and-sigframe.patch. + - Update debian/patches/series. + + -- Fabio M. Di Nitto Thu, 06 Apr 2006 07:16:23 +0200 + +gdb (6.4-1ubuntu2) dapper; urgency=low + + Changes by David S. Miller: + + * Fix sparc threads support: + - Add patch gdb-sparclinux-threads.patch. + - Update debian/patches/series. + + NOTE: the patch will work only with properly patched kernel. + The patch should be in 2.6.15-20 kernel serie. + + -- Fabio M. Di Nitto Sun, 02 Apr 2006 09:42:13 +0200 + +gdb (6.4-1ubuntu1) dapper; urgency=low + + * merged with debian, + * debian/control, debian/rules: Remove type-handling. + + -- Michael Vogt Wed, 28 Dec 2005 11:19:23 +0100 + +gdb (6.4-1) unstable; urgency=low + + * New upstream release. + * Reset core ulimit before running the testsuite (Closes: #342343). + * Ignore cancellation signal for NPTL by default (Closes: #324683). + * Include a description of the front cover texts, et cetera for the + manual in the copyright file (Closes: #321803). + * Set the default name of main to MAIN__ for Fortran programs + (Closes: #319520). + * Handle PowerPC PIC prologues a little better (Closes: #312059). + * Cope with attaching to threaded programs after the exit of a threaded + program (Closes: #303736). + + -- Daniel Jacobowitz Sun, 11 Dec 2005 13:14:04 -0500 + +gdb (6.3.90.20051119-1ubuntu1) dapper; urgency=low + + * debian/control, debian/rules: Remove type-handling. + + -- Martin Pitt Mon, 21 Nov 2005 19:50:49 +0000 + +gdb (6.3.90.20051119-1) unstable; urgency=low + + * New upstream snapshot (6.4 branch prerelease). + - Many Debian patches merged. + - Selected frame and C++ pass-by-reference patches updated. + - Fixes segfault when executing malformed TUI window commands + (Closes: #317317). + - Behaves more gracefully when the executable disappears, et cetera + (Closes: #293637, #323217, #332184). + - Handle vfork from threaded programs using NPTL (Closes: #320391). + * Do not rebuild bfd.info. + * Build depend on a version of debhelper which will put menu fils + in /usr/share. + * Don't build depend on gcj on the Hurd (Closes: #298088). + * Prevent unnecessary SIGTTOU when resolving pending breakpoints + (Closes: #306267). + * Enable the testsuite on amd64. + * Use libreadline5 instead of libreadline4 (Closes: #309538, #326358). + * Install gdb_gcore.sh as gcore (Closes: #328580). + * Add GPC support (Closes: #261330). + + -- Daniel Jacobowitz Sun, 20 Nov 2005 13:40:44 -0500 + +gdb (6.3-6) unstable; urgency=high + + * Do not crash on certain malformed input files [CAN-2005-1704] + (Closes: #308624, #310972). + * Do not load untrusted .gdbinit files [CAN-2005-1705] (Closes: #310728). + + -- Daniel Jacobowitz Sun, 29 May 2005 18:55:44 -0400 + +gdb (6.3-5) unstable; urgency=low + + * Fix NPTL debugging using gdbserver. + * Disable the "Incomplete CFI data" warning. + * Really include the menu file this time (Closes: #80010). + * Include a patch to handle strange binaries produced by Kylix + (Closes: #249008). + * Fix printing of fork status messages, and disable them by default + (Closes: #254039). + + -- Daniel Jacobowitz Wed, 8 Dec 2004 18:35:02 -0500 + +gdb (6.3-4) unstable; urgency=low + + * Backport a patch for a warning about the vsyscall DSO. + * Backport a spelling fix for PTRACE_EVENT_VFORK_DONE to fix S/390 + build failure. + + -- Daniel Jacobowitz Mon, 15 Nov 2004 11:52:13 -0500 + +gdb (6.3-3) unstable; urgency=low + + * Add flex to build dependencies for ada-lex.l. + + -- Daniel Jacobowitz Sun, 14 Nov 2004 00:28:18 -0500 + +gdb (6.3-2) unstable; urgency=low + + * Backport a patch for a C++ / stabs debug info crash (Closes: #251322). + * Correct build dependency for gcj (missed a !). + * Correct build dependency for libunwind (it's libunwind7-dev now). + * Update fix for fork tracing. This removes a warning on 2.4 kernels, + and fixes UML debugging (Closes: #271069). + * Fix single-stepping through a call to NULL on SPARC (Closes: #256012). + + -- Daniel Jacobowitz Sat, 13 Nov 2004 16:50:55 -0500 + +gdb (6.3-1) unstable; urgency=low + + * New upstream release (Closes: #259219). + - Give an error for division by 0 (Closes: #280051). + - Includes support for -feliminate-dwarf2-dups. + - Limited support for Ada is included; more to come + (Closes: #39516, #46470, #57876, #85947). + * Update build dependency on texinfo; 4.7-1 could not build GDB. + * Build depend on gcj on all architectures other than mips and mipsel + (Closes: #272327). + * Build depend on libkvm-dev for kfreebsd-gnu (Closes: #264103). + * Add libunwind support on ia64 (Closes: #279596). + * Make the fork tracing checks more robust. Prevents stray processes + on 2.6.10-rc1. + * Add a Debian menu entry for GDB (Closes: #80010). + + -- Daniel Jacobowitz Fri, 12 Nov 2004 18:45:46 -0500 + +gdb (6.1-3) unstable; urgency=low + + * Fix passing and returning of non-trivial C++ objects (Closes: #160459). + * Update hppa patches (Closes: #247948). + * Add a patch for finding C++ member variables in base classes + (Closes: #239535). + * Replace versions of insight which contain gdbtui. Partial fix for + #242498. + + -- Daniel Jacobowitz Thu, 27 May 2004 11:30:23 -0400 + +gdb (6.1-2) unstable; urgency=low + + * Add an NPTL thread-exit patch. Short-lived threads could cause GDB + to leave unattached threads, which would crash as soon as they hit + a breakpoint. + * Testsuite patches - no unexpected FAILs on i386-linux. + + -- Daniel Jacobowitz Mon, 19 Apr 2004 11:43:07 -0400 + +gdb (6.1-1) unstable; urgency=low + + * New upstream version. + * Re-add the -debian suffix to GDB's version number. This got lost in the + transition to CDBS. + * Revised HPPA port. Thanks to Randolph Chung, as usual. + * Run the testsuite on SPARC again. The SPARC port is much improved + (it has been basically rewritten from scratch). + + -- Daniel Jacobowitz Tue, 6 Apr 2004 00:13:00 -0400 + +gdb (6.0-6) unstable; urgency=low + + * Also add DESTDIR to the ranlib invocation. + * Fix typo in moving run.1 manpage. + * Link linux-nat.o on HPPA. + + -- Daniel Jacobowitz Tue, 3 Feb 2004 11:07:27 -0500 + +gdb (6.0-5) unstable; urgency=low + + * Add DESTDIR support to sim/, to fix build failures on targets with a + simulator. + + -- Daniel Jacobowitz Mon, 2 Feb 2004 15:32:23 -0500 + +gdb (6.0-4) unstable; urgency=low + + * Switch to CDBS and quilt. + * Suppress warning about "" on re-run with a vsyscall DSO. + * Import gdb 6.0 CVS branch; fixes a segfault with development GCC + and frequent segfaults when rereading changed binaries + (Closes: #230550). + + -- Daniel Jacobowitz Mon, 2 Feb 2004 10:03:19 -0500 + +gdb (6.0-3) unstable; urgency=low + + * Include instead of on HPPA + (Closes: #208928). + * Support backtraces through the vsyscall DSO on i386. + * Do not run testsuite on hurd-i386 (Closes: #221956). + * Fix up texinfo files so that dh_installinfo puts them in the right + section. + * Update build dependency on texinfo (Closes: #219337). + + -- Daniel Jacobowitz Sun, 25 Jan 2004 18:04:24 -0500 + +gdb (6.0-2) unstable; urgency=low + + * Add build dependency on mig for hurd-i386 (Closes: #216428). + * Don't paginate symbol file progress messages. In combination + with recent changes to dwarf2-frame.c this fixes some potential + internal errors (Closes: #199889). + - 28.symfile-unfiltered.patch + + -- Daniel Jacobowitz Mon, 27 Oct 2003 23:32:39 -0500 + +gdb (6.0-1) unstable; urgency=low + + * New upstream release + - 11.read-var-value.patch merged upstream. + - 12.dwarf-loc-register.patch merged upstream. + - -data-list-changed-registers no longer segfaults (Closes: #204561). + * Include the text of the GFDL in the copyright file (Closes: #212890). + * Include a threading patch which may fix #212949. + - 26.lin-lwp-assert.patch + * Include a patch which should improve Control-C handling for LinuxThreads + on 2.6 kernels. + - 27.lin-lwp-2.6.patch + + -- Daniel Jacobowitz Sat, 4 Oct 2003 17:47:35 -0400 + +gdb (5.3.20030824-1) unstable; urgency=low + + * New upstream CVS snapshot, from the GDB 6.0 branch. + - 27.tui-paginate-backtrace.patch merged upstream. + - 28.minsym-section.patch merged upstream. + - Watchpoint handling bug for ia64 fixed (Closes: #205241). + * Squash some warnings for HPPA. + + -- Daniel Jacobowitz Sun, 24 Aug 2003 14:26:52 -0400 + +gdb (5.3.20030801-1) unstable; urgency=low + + * New upstream CVS snapshot, from the GDB 6.0 branch. + - 26.fix-sparc-build-two.patch merged upstream. + - Includes a fix for backtracing from noreturn functions like abort (). + - Insert a space between the address and code when disassembling, + even if we don't have a function name (Closes: #199672). + * Update HPPA patch again; is anyone ever going to submit this + upstream? Better do it soon. (Closes: #200980). + * Make filtered output paginate correctly again. + - 27.tui-paginate-backtrace.patch + * Fix an internal error on -data-list-changed-registers, and possibly + many others (Closes: #203553). + - 10.selected-frame.patch + * Add two patches for watchpoints in optimized programs (Closes: #203000). + - 11.read-var-value.patch + - 12.dwarf-loc-register.patch + * Add a patch for several shared library single-stepping bugs. + - 28.minsym-section.patch + + -- Daniel Jacobowitz Sun, 3 Aug 2003 23:09:56 -0400 + +gdb (5.3.20030629-2) unstable; urgency=low + + * Yet another sparc build fix. + - 26.fix-sparc-build-two.patch + + -- Daniel Jacobowitz Sun, 29 Jun 2003 17:11:12 -0400 + +gdb (5.3.20030629-1) unstable; urgency=low + + * New upstream CVS snapshot, from the GDB 6.0 branch. + - Remote debugging isn't totally broken any more. + * Remove merge or obsoleted patches. + - Parts of 23.static-thread-apps.patch + - 26.fix-tui-build.patch + - 27.fix-sparc-build-two.patch + - 28.dwarf2-reread-segv.patch + + -- Daniel Jacobowitz Sat, 28 Jun 2003 21:17:13 -0400 + +gdb (5.3.20030606-3) unstable; urgency=low + + * Fix build failure on HPPA. + * Fix a segfault when reread applications (Closes: #197226). + - 28.dwarf2-reread-segv.patch + + -- Daniel Jacobowitz Sun, 22 Jun 2003 14:30:49 -0400 + +gdb (5.3.20030606-2) unstable; urgency=low + + * Add 27.fix-sparc-build-two.patch to fix build failure on sparc. + * Disable the testsuite on sparc, since it's completely broken. + * Conditionalize gcj build dependency for architectures which both + have gcj and run the testsuite. + + -- Daniel Jacobowitz Sat, 14 Jun 2003 12:30:33 -0400 + +gdb (5.3.20030606-1) unstable; urgency=low + + * New upstream snapshot, with lots of nice features. + - Improved prologue analyzer and DWARF-2 frame unwind support for i386. + - Overhauled Alpha support. + - More C++ namespace support (still not complete). + - DW_AT_ranges support - if you've noticed local variables in your code + being missing in GDB, this is the most likely cause. + - Integrated Objective C support, finally! It's got some rough edges + but it works (Closes: #62081, #24598, #57824, #86506). + - "set cp-abi" command for debugging combined v2 and v3 C++ code. + - Some bug fixes in the parsing for gdb --args (Closes: #33361, #193413). + - Support for debug info in separate files, coming soon to a Debian + near you. + * Removed integrated or obsoleted patches: + - 01.const-tilde_expand.patch + - 05.i386-backtrace-to-main.patch + - 08.max-ui-out.patch + - 12.tui-readline.patch + - 15.m68k-build.patch + - 16.use-rl-prefixed-function.patch + - 19.alpha-doublest-correction.patch + - 21.lin-lwp-schedlock.patch + * Disabled some patches which I hope are no longer needed: + - 06.java-testsuite-jmisc.patch + - 11.thread-confused-exit.patch + - 20.alpha-testsuite.patch + - 22.alpha-proc-desc-stack.patch + * Updated HPPA patches for this snapshot. + - 02.gdb-hppa.patch + - 03.hppa-core.patch + - 04.hppa-func-returns.patch + * Add some build fixes for TUI. + - 26.fix-tui-build.patch + * Build with an absolute path to configure, to work around three failing + MI tests. + * Don't bother running the testsuite for two debug formats any more. + * Add build-dependencies for gcj and gobjc, for the testsuite. + * Adjust configure --mandir argument to match more stupid quoting. + * Re-enable thread testsuite on Alpha. + * Enable the testsuite on ia64, hppa, and s390. + + -- Daniel Jacobowitz Sun, 8 Jun 2003 20:15:55 -0400 + +gdb (5.3-2) unstable; urgency=low + + * Fix build on SPARC. + * Fix buid on HPPA. + + -- Daniel Jacobowitz Sat, 4 Jan 2003 01:02:36 -0500 + +gdb (5.3-1) unstable; urgency=low + + * New upstream release. + * Patches updated for new release. + - Patch 14.gdb-maint-its-typo.patch included. + - Patch 17.tui-fixes.patch included. + - Patch 18.threads-much-faster.patch included. + + -- Daniel Jacobowitz Mon, 16 Dec 2002 14:43:03 -0500 + +gdb (5.2.debian90.cvs20021120-4) unstable; urgency=low + + * Fix thread debugging for statically linked applications + (Closes: #170107). + * Prevent a segfault when entering tracepoint actions if you hit EOF + (Closes: #167997). + + -- Daniel Jacobowitz Tue, 3 Dec 2002 14:46:07 -0500 + +gdb (5.2.debian90.cvs20021120-3) unstable; urgency=low + + * Add another Alpha patch for setting breakpoints after the process exits. + * Disable running the thread tests on Alpha (ew). It hangs the build + daemon; the problem appears to be in glibc. It returns nonexistant + and duplicate threads. + + -- Daniel Jacobowitz Sun, 24 Nov 2002 23:16:36 -0500 + +gdb (5.2.debian90.cvs20021120-2) unstable; urgency=low + + * Add patch for testsuite false failures on Alpha. + * Add patch for floating point support on Alpha. + * Add a patch from the CVS HEAD for schedule-lock mode and for software + single step platforms. + * Correct the testsuite to match "help maint dump-me". + + -- Daniel Jacobowitz Sun, 24 Nov 2002 18:11:26 -0500 + +gdb (5.2.debian90.cvs20021120-1) unstable; urgency=low + + * New upstream CVS snapshot from 5.3 CVS branch. + - Builds with new bison (Closes: #169656). + - Fixes crashes without SSE support or when loading core files without + applications. + - TUI no longer crashes if there is no debugging information for main + (Closes: #141491). + - GDB no longer crashes on "info win" if there are no windows + (Closes: #158186). + - Setting some C++ breakpoints works the first time instead of having + to do it twice (Closes: #110684). + * Patches updated for new release. + - Patch 07.manual-vector.dpatch included in CVS. + - Patch 09.mips-linux-buildfixes-aug02.patch included in CVS. + - Patch 10.no-readline-docs.patch removed - we still use readline, + I believe that leaving it as an appendix to the GDB manual is + appropriate. + - Patch 12.tui-readline.patch updated. + - Patch 17.tui-fixes.patch added to fix a TUI problem with -i=mi. + * Remove useless --enable-shared. + * Fix a typo in "help maint dump-me" (Closes: #168495). + * Add a patch to fix build on m68k, from Michael Fedrowitz + (Closes: #163543). + * Added a patch to call rl_filename_completion_function instead of + filename_completion_function, from Matt Chapman + (Closes: #165366). + * Tag GDB version with "-debian" because we apply patches. + * Add a patch which makes debugging threaded applications drastically + (5x - 10x) faster. Whee! + + -- Daniel Jacobowitz Fri, 22 Nov 2002 17:30:26 -0500 + +gdb (5.2.cvs20020818-3) unstable; urgency=low + + * HPPA fix from Randolph Chung (Closes: #158055). + + -- Daniel Jacobowitz Sun, 25 Aug 2002 00:37:34 -0400 + +gdb (5.2.cvs20020818-2) unstable; urgency=low + + * MIPS and MIPSel build fixes. + * Apply and remove patches in numbered order. + * HPPA build fixes. + + -- Daniel Jacobowitz Mon, 19 Aug 2002 10:49:40 -0400 + +gdb (5.2.cvs20020818-1) unstable; urgency=low + + * New upstream CVS snapshot. + - Don't include in TUI (Closes: #145040). + - Don't use libthread_db with core files (Closes: #133778). + * Recompile against current readline package (Closes: #153972). + * Reduce some thread-db errors to warnings + (Closes: #123675, #126614, #134693). + * Bump MAX_UI_OUT_LEVELS for the Hurd (Closes: #145630). + * Include patch from Richard Hirst to improve function return printing + on HPPA. It looks like there's finally a little progress on getting + the HPPA code in upstream... (Closes: #148672). + * Mention Peter Jay Salzman's GDB tutorial in the documentation + (Closes: #151128). + + -- Daniel Jacobowitz Sun, 18 Aug 2002 23:09:46 -0400 + +gdb (5.2.cvs20020401-6) unstable; urgency=medium + + * More HPPA build fixes - I forgot linux-proc.o again + (Closes: #143707). + * Add support for HPPA core files, patch from Randolph Chung + (Closes: #137316). + + -- Daniel Jacobowitz Sun, 21 Apr 2002 10:29:40 -0400 + +gdb (5.2.cvs20020401-5) unstable; urgency=low + + * More HPPA build fixes. + + -- Daniel Jacobowitz Fri, 19 Apr 2002 12:43:56 -0400 + +gdb (5.2.cvs20020401-4) unstable; urgency=medium + + * Add linux-proc.o to NATDEPFILES for S/390; should fix S/390 build. + * Change `value_ptr' to `struct value *' in HPPA patch. Should fix + HPPA build in combination with libc6 2.2.5-4.0.2. + + -- Daniel Jacobowitz Wed, 17 Apr 2002 00:43:32 -0400 + +gdb (5.2.cvs20020401-3) unstable; urgency=low + + * Add a patch to fix initialization on non-multi-arch targets + (particularly Alpha and Sparc). + * Enable testsuite on Alpha and Sparc. + + -- Daniel Jacobowitz Thu, 4 Apr 2002 21:49:24 -0500 + +gdb (5.2.cvs20020401-2) unstable; urgency=low + + * My apologies to all you autobuilders out there. Results were worse than + I feared. Testsuite is now run only on PowerPC and i386 until I can + clean up the results everywhere else. + + -- Daniel Jacobowitz Wed, 3 Apr 2002 17:24:17 -0500 + +gdb (5.2.cvs20020401-1) unstable; urgency=low + + * The "Ahhhhhhhhhhhhhhhhhh!" Release. + * New snapshot from CVS (post-5.2) (yes, I know 5.2 isn't out yet). + - Fixes crash on printing large types + (Closes: #111017, #130592, #131033). + - In one upstream patch and one pending patch, greatly improve + debugging with GCC 2.95. If you've ever breakpointed the + beginning of a function and been frustrated when arguments + printed incorrectly, this release is for you! It should fix most + occurances of that problem. + * Patches from J.H.M. Dassen to use system readline. Slightly tweaked. + - [debian/rules] Build the refcard; figure out patches automatically. + - [debian/use-dynamic-readline.patch] Link against dynamic readline again. + - [debian/no-readline-docs.patch] Remove readline documentation. + - [debian/const-tilde_expand.patch] Bring extern declaration of tilde_expand + in sync with current readline headers. + - [debian/rules] Ensure we don't build against the local readline copy by + mistake; remove generated config.status files. + * Include gdbserver if it is built. + * Include a version of GDB with the TUI interface enabled + (Closes: #137503). + * Run 'make check' during build, for stabs and DWARF-2. + * Add --disable-gdbtk (Closes: #115429). + * Add a patch to prevent a hang while running the Java testsuite if + gcj-3.0 is installed. + * Include simulator in the binary package if one is built (PPC, ARM, + MIPS) (Closes: #123185). + + -- Daniel Jacobowitz Mon, 1 Apr 2002 17:17:30 -0500 + +gdb (5.1.1-1) unstable; urgency=low + + * New upstream release (Closes: #132314). + - Corrected manual licenses (Closes: #129311). + * Apply HPPA patch (Closes: #127301). + * Add patch to fix conflict with new ncurses. + + -- Daniel Jacobowitz Wed, 13 Feb 2002 16:39:32 -0500 + +gdb (5.1-1) unstable; urgency=low + + * New upstream release. + * All patches merged upstream, including (hopefully) everything needed + for S/390. + + -- Daniel Jacobowitz Fri, 7 Dec 2001 13:04:15 -0500 + +gdb (5.0.cvs20011007-3) unstable; urgency=low + + * Add ARM patch (committed to upstream CVS). + + -- Daniel Jacobowitz Wed, 31 Oct 2001 10:59:21 -0500 + +gdb (5.0.cvs20011007-2) unstable; urgency=low + + * Updated S/390 patch from Gerhard Tonn. + + -- Daniel Jacobowitz Mon, 8 Oct 2001 13:55:06 -0400 + +gdb (5.0.cvs20011007-1) unstable; urgency=low + + * New upstream release. + * Remove obsolete patches (gdb-docs, gdb-ppc-core). + * Add S/390 support patch. + * Configure for $(DEB_HOST_GNU_TYPE) (Closes: #109715). + + -- Daniel Jacobowitz Sun, 7 Oct 2001 14:06:20 -0400 + +gdb (5.0.cvs20010729-2) unstable; urgency=low + + * Fix m68k build. Again. (Closes: #107807). + + -- Daniel Jacobowitz Sat, 25 Aug 2001 15:32:16 -0700 + +gdb (5.0.cvs20010729-1) unstable; urgency=low + + * Call dh_installinfo from rules file (Closes: #107119). + * Put info files in "Development" to match other Debian development tools. + * Fix malformed gdbint.info file. + * Use DH_COMPAT=3 to make dh_installinfo work better with wildcards, + and bump debhelper build dependency. + * Update to 5.1 release branch (Closes: #103992). + * Fix PowerPC core files (Re: bug #107072). + * Fix up patch handling in rules file a little bit. + + -- Daniel Jacobowitz Mon, 30 Jul 2001 13:48:27 -0700 + +gdb (5.0.cvs20010704-1) unstable; urgency=low + + * The "Independence Day" release - CVS snapshot from July 4th. + * New maintainer. + * Update build-depends (Closes: #96835, #96897). + * New version includes thread support - for some platforms. I'm not going + to close the related bugs until I've verified it on a few more targets. + * Debhelperize (Closes: #97715, #97593). + * Add Replaces: gdb-arm for upgrades (Closes: #79992). + + -- Daniel Jacobowitz Thu, 5 Jul 2001 12:46:06 -0700 + +gdb (5.0-4) unstable; urgency=low + + * Made almost lintian clean: + - added Section: and Priority: fields in gdb binary package + - info files are now installed in /usr/share/info + - binaries get now stripped + - debian/copyright now refers to '/usr/share/common-licenses' for + full GPL license text + (patch by Domenico Andreoli ) + * added texinfo & tetex-bin to the build-dependencies. + + -- Vincent Renardias Sun, 6 May 2001 21:19:16 +0200 + +gdb (5.0-3) unstable; urgency=low + + * Include upstream README & NEWS files. + closes: #37978 gdb documentation. + * s|usr/doc|usr/share/doc|g. + closes: #69272: gdb: docs should be in /usr/share/doc according policy. + * Fix description. + + -- Vincent Renardias Wed, 16 Aug 2000 21:58:45 +0200 + +gdb (5.0-2) unstable; urgency=low + + * Include patch to get it to work on m68k. + closes: #69185: gdb doesn't build on m68k. + + -- Vincent Renardias Wed, 16 Aug 2000 19:33:16 +0200 + +gdb (5.0-1) unstable; urgency=low + + * New upstream code. + (Foreign patches not re-applied for now. Will see if they + are necessary) + closes: #66221 New major upstream version (5.0) out. + closes: #63337 gdb: Recompilation with libncurse5 needed. + closes: #58450 gdb: Won't compile on PowerPC. + closes: #54738 gdb does not compile on i386 under current glibc. + + -- Vincent Renardias Sun, 13 Aug 2000 01:27:40 +0200 + +gdb (4.18.19990928-1) unstable; urgency=low + + * New upstream code. + Fixes some problems related to the C++ code: + closes: #46125: gdb seg faults calling C++ functions. + closes: #46195: gdb is broken for C++ + closes: #43955: gdb can't resolve virtual methods with new g++ + closes: #36341: gdb: Gives a parse error when casting an expression + * Include patch from David N. Welton : + closes: #45308: gdb: Patch for gdb debian/rules + * ACK NMU: + closes: #39661: gdb is broken on ppc arch. + * Now compiles on non-i386 archs: + closes: #32267 + * Updated my email address. + + -- Vincent Renardias Wed, 29 Sep 1999 17:39:17 +0200 + +gdb (4.18-1.1) unstable; urgency=low + + * Applied some ppc patch i got from the linuxppc gdb. + + -- Sven LUTHER Mon, 14 Jun 1999 19:54:49 +0200 + +gdb (4.18-1) unstable; urgency=low + + * New upstream version! + + -- Vincent Renardias Thu, 22 Apr 1999 17:35:41 +0200 + +gdb (4.17.19981224-3.m68k.objc.threads.hwwp.fpu.gnat) unstable; urgency=low + + * Upgrade to new code. + * Apply HJL's 4.17.0.4 -> 4.17.0.8 patch. + * Fix #30463. + + -- Vincent Renardias Mon, 18 Jan 1999 23:38:36 +0100 + +gdb (4.17-4.m68k.objc.threads.hwwp.fpu.gnat.3) frozen unstable; urgency=low + + * Non-maintainer upload. + * Apply threads patch (dynamically) only if building on i386; the patch + works currently only correct on i386 and breaks compilation at least + on m68k and sparc. + + -- Roman Hodek Fri, 11 Dec 1998 13:56:00 +0100 + +gdb (4.17-4.m68k.objc.threads.hwwp.fpu.gnat.2) unstable; urgency=low + + * Non-maintainer upload. + * debian/rules (checkroot): use tab not spaces, thanks to Roman Hodek + . [#26798] + + -- James Troup Tue, 20 Oct 1998 02:41:26 +0100 + +gdb (4.17-4.m68k.objc.threads.hwwp.fpu.gnat.1) unstable; urgency=low + + * NMU with yet more hideous revision. + * PowerPC support via Matt McLean. + * Clean up corrupted m68k files a little bit - move config/m68k/* to + gdb/config/m68k/* and remove literal ^L's. + + -- Daniel Jacobowitz Fri, 11 Sep 1998 22:40:22 -0400 + +gdb (4.17-4.m68k.objc.threads.hwwp.fpu.gnat) unstable; urgency=low + + * Apply yet another patch to improve Objective-C support (Fix #24599). + + -- Vincent Renardias Wed, 15 Jul 1998 12:34:47 +0200 + +gdb (4.17-3.m68k.objc.threads.hwwp.fpu.gnat) unstable; urgency=low + + * re-integrated gnat support. + (Was repported as a bug against 4.16, patch had been integrated then, + but dropped while switching to version 4.17). + (NB: Not being an ADA expert, I'd appreciate if s/o could confirm + it now works properly, thanx) + + -- Vincent Renardias Fri, 3 Jul 1998 18:46:28 +0200 + +gdb (4.17-2.m68k.objc.threads.hwwp.fpu) unstable; urgency=low + + * Include patch to support debugging of multithreaded programs + (Bug #23823) + Note: Needs a patch to libc6 to work (submitted as #24213). + * Include JH Lu patch to have hardware watchpoint and FPU support + (Fix bug #660!! (40 months old!!!) & bug #16435) + * Bug #8861 also appears to be fixed... Isn't that great? :) + * Now provide the reference card (Bug #20772). + + -- Vincent Renardias Fri, 3 Jul 1998 18:46:28 +0200 + +gdb (4.17-1) unstable; urgency=low + + * Fix #22555 (enable building on sparc) + * Fix #21932 (acknowledge NMU) + + -- Vincent Renardias Mon, 18 May 1998 17:56:10 +0200 + +gdb (4.17-0.1) frozen unstable; urgency=low + + * New upstream release (differences with upstream 4.16.98 are negligable). + * Non-maintainer upload. + * Disabled linking -rpath: + * bfd/configure.in, opcodes/configure.in: applied libtool-rpath-workaround + * gdb/configure.in, gdb/configure: don't use -rpath on Linux. + * regenerate "configure" scripts involved. + + -- J.H.M. Dassen (Ray) Thu, 30 Apr 1998 19:47:34 +0200 + +gdb (4.16.98-1) frozen unstable; urgency=low + + * New upstream code. Only change relevant on Linux: Patch by + H.J. Lu so debugging of shared library works properly (That was + the important patch motivating this upload). + This release _is_ supposed to be the final gdb-4.17 (from the announce: + 'I wanted to make a "this is the release unless something is + very wrong" release and then kick 4.17 out'). + + -- Vincent Renardias Thu, 23 Apr 1998 20:44:36 +0200 + +gdb (4.16.86-1) unstable; urgency=low + + * New upstream code. (still unreleased). + * Re-added the m68k stuff that didn't make it upstream (Bug #19539, #19635). + * Re-added the Objective-C stuff (Bug #19630) + + -- Vincent Renardias Sat, 14 Mar 1998 23:40:06 +0100 + +gdb (4.16.85-2) unstable; urgency=low + + * debian/rules: Also remove gdb/doc/GDBvn.texi and config.log when cleaning up. + * The following has been done by : + * TODO: this version of gdb uses an evil new version of libtool which + forces -rpath. With lesstif, I got around this by replacing the libtool + scripts with those from the Debian libtool package. + * Use dynamic readline library. + * Install with preserved timestamps. + * Clean out .tab.c files missed by "make distclean", so the .diff.gz is + smaller. + * Clean out symlinks, so dpkg-source works after debian/rules build clean. + * Several other minor clean-ups of the rules file. + * Updated FSF address (lintian). + * Bumped Standards-Version. + + -- Vincent Renardias Fri, 6 Mar 1998 20:49:54 +0100 + +gdb (4.16.85-1) unstable; urgency=low + + * New upstream code (Although not released yet). + + -- Vincent Renardias Thu, 5 Mar 1998 20:19:14 +0100 + +gdb (4.16-12) unstable; urgency=low + + * Applied alpha patches (#11841). + + -- Vincent Renardias Mon, 4 Aug 1997 22:28:54 +0200 + +gdb (4.16-11) unstable; urgency=low + + * Included patch to fix bugs (#11552,#11324). + + -- Vincent Renardias Wed, 30 Jul 1997 20:40:01 +0200 + +gdb (4.16-10) unstable; urgency=low + + * Fixed #11136 (support for Ada; + Thanx to Marc Eichin for pointing this patch). + + -- Vincent Renardias Thu, 10 Jul 1997 19:38:07 +0200 + +gdb (4.16-9) unstable; urgency=low + + * Fixed #11037 (compilation on m68k). + + -- Vincent Renardias Sat, 5 Jul 1997 16:14:39 +0200 + +gdb (4.16-8) unstable; urgency=low + + * Compiled with libc6/ncurses3.4/libreadline2.1. + * Fixed #9654 (cosmetic fix). + * Updated debian/control file (now supports Objective-C). + + -- Vincent Renardias Sat, 21 Jun 1997 15:15:13 +0200 + +gdb (4.16-7) unstable; urgency=low + + * Fixed typo. in documentation (Fixes bug #5477). + + -- Vincent Renardias Mon, 7 Apr 1997 16:35:53 +0200 + +gdb (4.16-6) unstable; urgency=low + + * Corrected texinfo documentation (Fixes bug #3823). + * Added upstream ChangeLog file. + + -- Vincent Renardias Sun, 16 Mar 1997 18:32:23 +0100 + +gdb (4.16-5) unstable; urgency=low + + * Included patch for glibc-2.0 support. + + -- Vincent Renardias Sun, 16 Mar 1997 07:46:29 +0100 + +gdb (4.16-4) unstable; urgency=low + + * Included patch for Objective-C support (Fixes bug #7063). + + -- Vincent Renardias Sun, 16 Mar 1997 03:12:13 +0100 + +gdb (4.16-3) unstable; urgency=low + + * New maintainer. + * Included patches for m68k support. + + -- Vincent Renardias Fri, 14 Mar 1997 22:07:58 +0100 + +gdb (4.16-2) unstable; urgency=MEDIUM + + * New caretaker: Stuart Lamble (note: this package is still up + for adoption, as I would prefer not to be maintaining it + full-time.) + * Upgraded to the 2.1.1.0 source format. + * Recompiled, with a corrected procfs.h, to correct problems with + ELF coredumps. + * Reformatted the changelog :-) + + -- Stuart Lamble Sun, 20 Oct 1996 18:48:40 +1000 --- gdb-7.0.1.orig/debian/control.in +++ gdb-7.0.1/debian/control.in @@ -0,0 +1,46 @@ +Source: gdb +Maintainer: Ubuntu Core developers +XSBC-Original-Maintainer: Daniel Jacobowitz +Section: devel +Priority: optional +Standards-Version: 3.8.1 +Build-Depends: autoconf, libtool, texinfo (>= 4.7-2.2), texlive-base, libncurses5-dev, libreadline-dev, bison, gettext, debhelper (>= 7), dejagnu, gcj [!kfreebsd-amd64 !kfreebsd-i386 !hurd-i386 !alpha !arm !hppa], gobjc, mig [@gnu@], cdbs (>= 0.4.17), quilt (>= 0.30), libkvm-dev [@kfreebsd@], type-handling (>= 0.2.1), libunwind7-dev [ia64], flex | flex-old, libexpat1-dev, g++-multilib [i386 powerpc s390 sparc], lib64readline6-dev [i386 powerpc s390 sparc], python-dev, zlib1g-dev, procps, lsb-release + +Package: gdb@TS@ +Architecture: any +Section: devel +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: gdb-doc +Description: The GNU Debugger + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran, + Modula 2 and Java programs. A must-have for any serious + programmer. + +Package: gdb64 +Architecture: i386 powerpc s390 sparc +Section: devel +Depends: ${shlibs:Depends}, gdb, ${misc:Depends} +Description: The GNU Debugger (64-bit) + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran + Modula 2 and Java programs. A must-have for any serious + programmer. + +Package: libgdb-dev +Architecture: any +Section: libdevel +Depends: ${shlibs:Depends}, ${misc:Depends}, binutils-dev, libexpat1-dev, python-dev, zlib1g-dev, libncurses5-dev, libreadline-dev +Priority: extra +Description: The GNU Debugger (libgdb.a) + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran + Modula 2 and Java programs. A must-have for any serious + programmer. + . + This package contains libgdb.a, the bulk of GDB as a linkable + library. It is provided for an IDE which links to libgdb.a. Please + do not use libgdb.a for new projects. --- gdb-7.0.1.orig/debian/gdbtui +++ gdb-7.0.1/debian/gdbtui @@ -0,0 +1,10 @@ +#!/bin/sh + +prog=$(basename $0 tui) + +dir=$(dirname $0) +if [ "$dir" != "." ]; then + prog=$dir/$prog +fi + +exec $prog --tui "$@" --- gdb-7.0.1.orig/debian/control +++ gdb-7.0.1/debian/control @@ -0,0 +1,46 @@ +Source: gdb +Maintainer: Ubuntu Core developers +XSBC-Original-Maintainer: Daniel Jacobowitz +Section: devel +Priority: optional +Standards-Version: 3.8.1 +Build-Depends: autoconf, libtool, texinfo (>= 4.7-2.2), texlive-base, libncurses5-dev, libreadline-dev, bison, gettext, debhelper (>= 7), dejagnu, gcj [!kfreebsd-amd64 !kfreebsd-i386 !hurd-i386 !alpha !arm !hppa], gobjc, mig [hurd-alpha hurd-amd64 hurd-arm hurd-armeb hurd-avr32 hurd-hppa hurd-i386 hurd-i686 hurd-ia64 hurd-m32r hurd-m68k hurd-mips hurd-mipsel hurd-powerpc hurd-ppc64 hurd-s390 hurd-s390x hurd-sh3 hurd-sh3eb hurd-sh4 hurd-sh4eb hurd-sparc], cdbs (>= 0.4.17), quilt (>= 0.30), libkvm-dev [kfreebsd-alpha kfreebsd-amd64 kfreebsd-arm kfreebsd-armeb kfreebsd-avr32 kfreebsd-hppa kfreebsd-i386 kfreebsd-i686 kfreebsd-ia64 kfreebsd-m32r kfreebsd-m68k kfreebsd-mips kfreebsd-mipsel kfreebsd-powerpc kfreebsd-ppc64 kfreebsd-s390 kfreebsd-s390x kfreebsd-sh3 kfreebsd-sh3eb kfreebsd-sh4 kfreebsd-sh4eb kfreebsd-sparc], type-handling (>= 0.2.1), libunwind7-dev [ia64], flex | flex-old, libexpat1-dev, g++-multilib [i386 powerpc s390 sparc], lib64readline6-dev [i386 powerpc s390 sparc], python-dev, zlib1g-dev, procps, lsb-release + +Package: gdb +Architecture: any +Section: devel +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: gdb-doc +Description: The GNU Debugger + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran, + Modula 2 and Java programs. A must-have for any serious + programmer. + +Package: gdb64 +Architecture: i386 powerpc s390 sparc +Section: devel +Depends: ${shlibs:Depends}, gdb, ${misc:Depends} +Description: The GNU Debugger (64-bit) + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran + Modula 2 and Java programs. A must-have for any serious + programmer. + +Package: libgdb-dev +Architecture: any +Section: libdevel +Depends: ${shlibs:Depends}, ${misc:Depends}, binutils-dev, libexpat1-dev, python-dev, zlib1g-dev, libncurses5-dev, libreadline-dev +Priority: extra +Description: The GNU Debugger (libgdb.a) + GDB is a source-level debugger, capable of breaking programs at + any specific line, displaying variable values, and determining + where errors occurred. Currently, it works for C, C++, Fortran + Modula 2 and Java programs. A must-have for any serious + programmer. + . + This package contains libgdb.a, the bulk of GDB as a linkable + library. It is provided for an IDE which links to libgdb.a. Please + do not use libgdb.a for new projects. --- gdb-7.0.1.orig/debian/gdb.menu +++ gdb-7.0.1/debian/gdb.menu @@ -0,0 +1,3 @@ +?package(gdb):needs="text" title="GDB" section="Applications/Programming"\ + hints="Debuggers" command="/usr/bin/gdb" + --- gdb-7.0.1.orig/debian/source.lintian-overrides +++ gdb-7.0.1/debian/source.lintian-overrides @@ -0,0 +1,3 @@ +# We do not use the included readline. +gdb source: outdated-autotools-helper-file readline/support/config.guess 2004-02-16 +gdb source: outdated-autotools-helper-file readline/support/config.sub 2004-02-16 --- gdb-7.0.1.orig/debian/patches/man-page-order.patch +++ gdb-7.0.1/debian/patches/man-page-order.patch @@ -0,0 +1,203 @@ +From 539edd1a9af966d16f3391edece93702a86c7155 Mon Sep 17 00:00:00 2001 +From: Jari Aalto +Date: Sat, 8 Aug 2009 10:18:20 +0300 +Subject: [PATCH] gdb.1: Order options alphabetically + +Signed-off-by: Jari Aalto +--- + gdb/gdb.1 | 148 +++++++++++++++++++++++++------------------------------------ + 1 files changed, 60 insertions(+), 88 deletions(-) + +diff --git a/gdb/gdb.1 b/gdb/gdb.1 +index 809578f..18550b4 100644 +--- a/gdb/gdb.1 ++++ b/gdb/gdb.1 +@@ -205,90 +205,11 @@ in sequential order. The order makes a difference when the + `\|\c + .B \-x\c + \&\|' option is used. +- +-.TP +-.B \-help +-.TP +-.B \-h +-List all options, with brief explanations. +- +-.TP +-.BI "\-symbols=" "file"\c +-.TP +-.BI "\-s " "file"\c +-\& +-Read symbol table from file \c +-.I file\c +-\&. +- +-.TP +-.B \-write +-Enable writing into executable and core files. +- +-.TP +-.BI "\-exec=" "file"\c +-.TP +-.BI "\-e " "file"\c +-\& +-Use file \c +-.I file\c +-\& as the executable file to execute when +-appropriate, and for examining pure data in conjunction with a core +-dump. +- +-.TP +-.BI "\-se=" "file"\c +-\& +-Read symbol table from file \c +-.I file\c +-\& and use it as the executable +-file. +- +-.TP +-.BI "\-core=" "file"\c +-.TP +-.BI "\-c " "file"\c +-\& +-Use file \c +-.I file\c +-\& as a core dump to examine. +- +-.TP +-.BI "\-command=" "file"\c +-.TP +-.BI "\-x " "file"\c +-\& +-Execute GDB commands from file \c +-.I file\c +-\&. +- +-.TP +-.BI "\-directory=" "directory"\c + .TP +-.BI "\-d " "directory"\c ++.BI "\-b " "bps"\c + \& +-Add \c +-.I directory\c +-\& to the path to search for source files. +-.PP +- +-.TP +-.B \-nx +-.TP +-.B \-n +-Do not execute commands from any `\|\c +-.B .gdbinit\c +-\&\|' initialization files. +-Normally, the commands in these files are executed after all the +-command options and arguments have been processed. +- +- +-.TP +-.B \-quiet +-.TP +-.B \-q +-``Quiet''. Do not print the introductory and copyright messages. These +-messages are also suppressed in batch mode. ++Set the line speed (baud rate or bits per second) of any serial ++interface used by GDB for remote debugging. + + .TP + .B \-batch +@@ -316,6 +237,12 @@ Program\ exited\ normally. + terminates) is not issued when running in batch mode. + + .TP ++.B \-c FILE, \-core=FILE ++Use file \c ++.I file\c ++\& as a core dump to examine. ++ ++.TP + .BI "\-cd=" "directory"\c + \& + Run GDB using \c +@@ -324,9 +251,21 @@ Run GDB using \c + instead of the current directory. + + .TP +-.B \-fullname ++.B \-d DIRECTORY, \-directory=DIRECTORY ++Add \c ++.I directory\c ++\& to the path to search for source files. ++ ++.TP ++.B \-e FILE, -exec=FILE ++Use file \c ++.I file\c ++\& as the executable file to execute when ++appropriate, and for examining pure data in conjunction with a core ++dump. ++ + .TP +-.B \-f ++.B \-f, \-fullname + Emacs sets this option when it runs GDB as a subprocess. It tells GDB + to output the full file name and line number in a standard, + recognizable fashion each time a stack frame is displayed (which +@@ -341,10 +280,34 @@ Emacs-to-GDB interface program uses the two `\|\c + a signal to display the source code for the frame. + + .TP +-.BI "\-b " "bps"\c +-\& +-Set the line speed (baud rate or bits per second) of any serial +-interface used by GDB for remote debugging. ++.B \-h, \-help ++List all options, with brief explanations. ++ ++.TP ++.B \-n, \-nx ++Do not execute commands from any `\|\c ++.B .gdbinit\c ++\&\|' initialization files. ++Normally, the commands in these files are executed after all the ++command options and arguments have been processed. ++ ++.TP ++.B -s FILE, \-symbols=FILE ++Read symbol table from file \c ++.I file\c ++\&. ++ ++.TP ++.BI "\-se=" "file"\c ++Read symbol table from file \c ++.I file\c ++\& and use it as the executable ++file. ++ ++.TP ++.B \q, \-quiet ++``Quiet''. Do not print the introductory and copyright messages. These ++messages are also suppressed in batch mode. + + .TP + .BI "\-tty=" "device"\c +@@ -354,6 +317,15 @@ Run using \c + \& for your program's standard input and output. + .PP + ++.TP ++.B \-write ++Enable writing into executable and core files. ++ ++.TP ++.B \-x FILE, \-command=FILE ++Execute GDB commands from file \c ++.I file\c ++\&. + .SH "SEE ALSO" + .RB "`\|" gdb "\|'" + entry in +-- +1.6.3.3 + --- gdb-7.0.1.orig/debian/patches/handle-nodebuginfo-better.patch +++ gdb-7.0.1/debian/patches/handle-nodebuginfo-better.patch @@ -0,0 +1,38 @@ +Index: gdb/i386-tdep.c +=================================================================== +--- gdb/i386-tdep.c.orig 2008-03-04 20:49:39.000000000 +0100 ++++ gdb/i386-tdep.c 2008-05-26 11:48:43.000000000 +0200 +@@ -1023,11 +1023,13 @@ + /* This will be added back below. */ + cache->saved_regs[I386_EIP_REGNUM] -= cache->base; + } +- else ++ else if (cache->pc) + { + frame_unwind_register (next_frame, I386_ESP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset; + } ++ else ++ cache->saved_regs[I386_EBP_REGNUM] = 0; + } + + /* Now that we have the base address for the stack frame we can +Index: gdb/amd64-tdep.c +=================================================================== +--- gdb/amd64-tdep.c.orig 2008-05-26 11:48:50.000000000 +0200 ++++ gdb/amd64-tdep.c 2008-05-26 11:48:15.000000000 +0200 +@@ -868,11 +868,13 @@ + frame_unwind_register (next_frame, AMD64_RSP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 8) + cache->sp_offset; + } +- else ++ else if (cache->pc) + { + frame_unwind_register (next_frame, AMD64_RBP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 8); + } ++ else ++ cache->saved_regs[AMD64_RBP_REGNUM] = 0; + + /* Now that we have the base address for the stack frame we can + calculate the value of %rsp in the calling frame. */ --- gdb-7.0.1.orig/debian/patches/series +++ gdb-7.0.1/debian/patches/series @@ -0,0 +1,25 @@ +member-field-symtab.patch +dwarf2-cfi-warning.patch +gdbinit-ownership.patch +gdb-pascal-support.patch +gdb-fortran-main.patch +linux-clear-thread-list.patch +man-page-args.patch +i386-assume-frame.patch +gdb-readline-6.0.patch +man-page-order.patch + +# Ubuntu additions +gdb-strings.patch +arm_dis_thumb2.patch + +# XXX, doesn't apply / handle-nodebuginfo-better.patch -p0 +# +# RH stack that seems to be needed for sane PIE handling +# http://cvs.fedora.redhat.com/viewvc/devel/gdb/ +gdb-6.3-test-pie-20050107.patch +gdb-6.5-bz203661-emit-relocs.patch +gdb-workaround-rh-stack-on.patch +gdb-6.6-buildid-locate.patch +gdb-6.3-pie-20050110.patch +gdb-workaround-rh-stack-off.patch --- gdb-7.0.1.orig/debian/patches/linux-clear-thread-list.patch +++ gdb-7.0.1/debian/patches/linux-clear-thread-list.patch @@ -0,0 +1,23 @@ +Status: unsubmitted + +This patch was for Debian bug #303736. I now believe it's in the wrong +place; the generic mourn inferior should do this, perhaps. + +--- + gdb/linux-thread-db.c | 3 +++ + 1 file changed, 3 insertions(+) + +Index: gdb-6.8.50.20090628/gdb/linux-thread-db.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/linux-thread-db.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/linux-thread-db.c 2009-07-03 18:53:44.000000000 -0400 +@@ -1256,6 +1256,9 @@ thread_db_mourn_inferior (struct target_ + + target_beneath->to_mourn_inferior (target_beneath); + ++ /* Destroy thread info; it's no longer valid. */ ++ init_thread_list (); ++ + /* Detach thread_db target ops. */ + if (!thread_db_list) + unpush_target (ops); --- gdb-7.0.1.orig/debian/patches/gdbinit-ownership.patch +++ gdb-7.0.1/debian/patches/gdbinit-ownership.patch @@ -0,0 +1,113 @@ +This patch was not popular upstream; there was no fundamental objection, but +several problems with the implementation. It needs to be revisited. + +--- + gdb/cli/cli-cmds.c | 44 ++++++++++++++++++++++++++++++++++++++++---- + gdb/main.c | 4 ++-- + 2 files changed, 42 insertions(+), 6 deletions(-) + +Index: gdb-6.8.50.20090628/gdb/cli/cli-cmds.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/cli/cli-cmds.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/cli/cli-cmds.c 2009-07-03 18:44:51.000000000 -0400 +@@ -36,6 +36,7 @@ + #include "objfiles.h" + #include "source.h" + #include "disasm.h" ++#include "gdb_stat.h" + + #include "ui-out.h" + +@@ -432,6 +433,10 @@ cd_command (char *dir, int from_tty) + pwd_command ((char *) 0, 1); + } + ++/* Load a GDB command file whose name is given in ARGS. FROM_TTY may ++ be -1, in which case we are loading a gdbinit file; in that case, ++ be paranoid about unsafe files. */ ++ + void + source_script (char *file, int from_tty) + { +@@ -441,9 +446,7 @@ source_script (char *file, int from_tty) + int fd; + + if (file == NULL || *file == 0) +- { +- error (_("source command requires file name of file to source.")); +- } ++ error (_("source command requires file name of file to source.")); + + file = tilde_expand (file); + old_cleanups = make_cleanup (xfree, file); +@@ -462,7 +465,7 @@ source_script (char *file, int from_tty) + + if (fd == -1) + { +- if (from_tty) ++ if (from_tty > 0) + perror_with_name (file); + else + { +@@ -472,6 +475,39 @@ source_script (char *file, int from_tty) + } + + stream = fdopen (fd, FOPEN_RT); ++ ++ if (stream == NULL) ++ { ++ if (from_tty) ++ perror_with_name (file); ++ else ++ { ++ do_cleanups (old_cleanups); ++ return; ++ } ++ } ++ ++#ifdef HAVE_GETUID ++ if (from_tty == -1) ++ { ++ struct stat statbuf; ++ if (fstat (fd, &statbuf) < 0) ++ { ++ perror_with_name (file); ++ fclose (stream); ++ do_cleanups (old_cleanups); ++ return; ++ } ++ if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH)) ++ { ++ warning ("not using untrusted file \"%s\"", file); ++ fclose (stream); ++ do_cleanups (old_cleanups); ++ return; ++ } ++ } ++#endif ++ + script_from_file (stream, file); + + do_cleanups (old_cleanups); +Index: gdb-6.8.50.20090628/gdb/main.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/main.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/main.c 2009-07-03 18:43:51.000000000 -0400 +@@ -781,7 +781,7 @@ Excess command line arguments ignored. ( + 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) +@@ -850,7 +850,7 @@ Can't attach to process and specify a co + /* 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); + + for (i = 0; i < ncmd; i++) + { --- gdb-7.0.1.orig/debian/patches/gdb-workaround-rh-stack-off.patch +++ gdb-7.0.1/debian/patches/gdb-workaround-rh-stack-off.patch @@ -0,0 +1,85 @@ +Index: gdb-6.8.90.20090918/gdb/symfile.c +=================================================================== +--- gdb-6.8.90.20090918.orig/gdb/symfile.c 2009-09-19 10:08:40.000000000 -0700 ++++ gdb-6.8.90.20090918/gdb/symfile.c 2009-09-19 10:08:40.000000000 -0700 +@@ -965,10 +965,10 @@ + /* Give user a chance to burp if we'd be + interactively wiping out any existing symbols. */ + +- if ((add_flags & SYMFILE_MAINLINE) && !(add_flags & SYMFILE_MAINLINE2_ONLY) +- && (have_full_symbols () || have_partial_symbols ()) ++ if ((have_full_symbols () || have_partial_symbols ()) ++ && (add_flags & SYMFILE_MAINLINE) ++ && !(add_flags & SYMFILE_MAINLINE2_ONLY) + && from_tty +- && (have_full_symbols () || have_partial_symbols ()) + && !query (_("Load new symbol table from \"%s\"? "), name)) + error (_("Not confirmed.")); + +@@ -1172,7 +1172,7 @@ + #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 int build_id_verbose = BUILD_ID_VERBOSE_NONE; + static void + show_build_id_verbose (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +@@ -1908,8 +1908,6 @@ + basename = get_debug_link_info (objfile, &crc32); + + if (basename == NULL) +- /* There's no separate debug info, hence there's no way we could +- load it => no warning. */ + goto cleanup_return_debugfile; + + dir = xstrdup (objfile->name); +@@ -1943,7 +1941,7 @@ + strcpy (debugfile, dir); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32, objfile->name)) ++ if (separate_debug_file_exists (debugfile, crc32)) + goto cleanup_return_debugfile; + + /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ +@@ -1952,7 +1950,7 @@ + strcat (debugfile, "/"); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32, objfile->name)) ++ if (separate_debug_file_exists (debugfile, crc32)) + goto cleanup_return_debugfile; + + /* Then try in the global debugfile directory. */ +@@ -1961,7 +1959,7 @@ + strcat (debugfile, dir); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32, objfile->name)) ++ if (separate_debug_file_exists (debugfile, crc32)) + goto cleanup_return_debugfile; + + /* If the file is in the sysroot, try using its base path in the +@@ -1975,7 +1973,7 @@ + strcat (debugfile, "/"); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32, objfile->name)) ++ if (separate_debug_file_exists (debugfile, crc32)) + goto cleanup_return_debugfile; + } + +Index: gdb-6.8.90.20090918/gdb/ppc-linux-nat.c +=================================================================== +--- gdb-6.8.90.20090918.orig/gdb/ppc-linux-nat.c 2009-09-19 10:14:16.000000000 -0700 ++++ gdb-6.8.90.20090918/gdb/ppc-linux-nat.c 2009-09-19 10:15:24.000000000 -0700 +@@ -1523,7 +1523,7 @@ + + static int + ppc_linux_auxv_parse (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp) + { + int sizeof_auxv_field = ppc_linux_target_wordsize (); + enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); --- gdb-7.0.1.orig/debian/patches/gdb-fortran-main.patch +++ gdb-7.0.1/debian/patches/gdb-fortran-main.patch @@ -0,0 +1,86 @@ +Daniel, + +Although the proper way of adding case insensitivity to symbol lookup is +still under discussion, I think it might be desirable to set the main +function of Fortran programs to "MAIN__" first. Because it can at least +let GDB recognize that the language is Fortran after loading a Fortran +executable only. What is your idea on this? Please comments. TIA! + +Here is the patch to set the main function in Fortran programs to +"MAIN__". And followed is a patch to verify this. Tested with g77 and +gfortran on x86, and g77 on ppc64. With the first patch, it reported +PASS; without, report FAIL. No regression is found in gdb.fortran +testcases. + +P.S: if there is a symbol named "MAIN__" in sources of other languages, it +might disturb the debugging. But I am not sure how much it is. + +--- + gdb/symtab.c | 8 +++++-- + gdb/testsuite/gdb.fortran/lang.exp | 40 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 46 insertions(+), 2 deletions(-) + +Index: gdb-6.8.50.20090628/gdb/symtab.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/symtab.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/symtab.c 2009-07-03 18:45:11.000000000 -0400 +@@ -4532,8 +4532,12 @@ find_main_name (void) + } + + /* The languages above didn't identify the name of the main procedure. +- Fallback to "main". */ +- set_main_name ("main"); ++ Fallback to "MAIN__" (g77 and gfortran) if we can find it in the ++ minimal symtab, to "main" otherwise. */ ++ if (lookup_minimal_symbol ("MAIN__", NULL, NULL)) ++ set_main_name ("MAIN__"); ++ else ++ set_main_name ("main"); + } + + char * +Index: gdb-6.8.50.20090628/gdb/testsuite/gdb.fortran/lang.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.fortran/lang.exp 2009-07-03 18:45:11.000000000 -0400 +@@ -0,0 +1,40 @@ ++# 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 file was written by Wu Zhou. (woodzltc@cn.ibm.com) ++ ++# This file is part of the gdb testsuite. It is intended to test that gdb ++# could recognize the Fortran language after loading the binary ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile "array-element" ++set srcfile ${srcdir}/${subdir}/${testfile}.f ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcfile}" "${binfile}" executable {debug f77}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++gdb_test "show language" ".*currently fortran.*" "show language(fortran)" --- gdb-7.0.1.orig/debian/patches/gdb-workaround-rh-stack-on.patch +++ gdb-7.0.1/debian/patches/gdb-workaround-rh-stack-on.patch @@ -0,0 +1,62 @@ +Index: gdb-6.8.90.20090918/gdb/symfile.c +=================================================================== +--- gdb-6.8.90.20090918.orig/gdb/symfile.c 2009-09-19 07:47:52.000000000 -0700 ++++ gdb-6.8.90.20090918/gdb/symfile.c 2009-09-19 07:48:01.000000000 -0700 +@@ -958,9 +958,10 @@ + /* Give user a chance to burp if we'd be + interactively wiping out any existing symbols. */ + +- if ((have_full_symbols () || have_partial_symbols ()) +- && (add_flags & SYMFILE_MAINLINE) ++ if ((add_flags & SYMFILE_MAINLINE) ++ && (have_full_symbols () || have_partial_symbols ()) + && from_tty ++ && (have_full_symbols () || have_partial_symbols ()) + && !query (_("Load new symbol table from \"%s\"? "), name)) + error (_("Not confirmed.")); + +@@ -1356,6 +1357,8 @@ + basename = get_debug_link_info (objfile, &crc32); + + if (basename == NULL) ++ /* There's no separate debug info, hence there's no way we could ++ load it => no warning. */ + return NULL; + + dir = xstrdup (objfile->name); +@@ -1389,7 +1392,7 @@ + strcpy (debugfile, dir); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32)) ++ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) + { + xfree (basename); + xfree (dir); +@@ -1403,7 +1406,7 @@ + strcat (debugfile, "/"); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32)) ++ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) + { + xfree (basename); + xfree (dir); +@@ -1417,7 +1420,7 @@ + strcat (debugfile, dir); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32)) ++ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) + { + xfree (basename); + xfree (dir); +@@ -1436,7 +1439,7 @@ + strcat (debugfile, "/"); + strcat (debugfile, basename); + +- if (separate_debug_file_exists (debugfile, crc32)) ++ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) + { + xfree (canon_name); + xfree (basename); --- gdb-7.0.1.orig/debian/patches/gdb-readline-6.0.patch +++ gdb-7.0.1/debian/patches/gdb-readline-6.0.patch @@ -0,0 +1,119 @@ +gdb/ +2009-07-31 Jan Kratochvil + + Fix compatibility of --with-system-readline and readline-6.0+. + * configure.ac <--with-system-readline> (for readline_echoing_p): New + test. + * config.in: Regenerate. + * configure: Regenerate. + +--- a/gdb/configure.ac ++++ b/gdb/configure.ac +@@ -536,6 +536,21 @@ if test "$with_system_readline" = yes; then + READLINE=-lreadline + READLINE_DEPS= + READLINE_CFLAGS= ++ ++ # readline-6.0 started to use the name `_rl_echoing_p'. ++ # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. ++ ++ AC_MSG_CHECKING([for readline_echoing_p]) ++ save_LIBS=$LIBS ++ LIBS="$LIBS $READLINE" ++ AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int readline_echoing_p; ++ return readline_echoing_p;]]), ++ [READLINE_ECHOING_P=yes], ++ [READLINE_ECHOING_P=no ++ AC_DEFINE([readline_echoing_p], [_rl_echoing_p], ++ [readline-6.0 started to use different name.])]) ++ LIBS="$save_LIBS" ++ AC_MSG_RESULT([$READLINE_ECHOING_P]) + else + READLINE='$(READLINE_DIR)/libreadline.a' + READLINE_DEPS='$(READLINE)' +--- a/gdb/config.in ++++ b/gdb/config.in +@@ -790,6 +790,9 @@ + /* Define to `int' if does not define. */ + #undef pid_t + ++/* readline-6.0 started to use different name. */ ++#undef readline_echoing_p ++ + /* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +--- a/gdb/configure ++++ b/gdb/configure +@@ -10763,6 +10763,69 @@ if test "$with_system_readline" = yes; then + READLINE=-lreadline + READLINE_DEPS= + READLINE_CFLAGS= ++ ++ # readline-6.0 started to use the name `_rl_echoing_p'. ++ # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. ++ ++ echo "$as_me:$LINENO: checking for readline_echoing_p" >&5 ++echo $ECHO_N "checking for readline_echoing_p... $ECHO_C" >&6 ++ save_LIBS=$LIBS ++ LIBS="$LIBS $READLINE" ++ cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++extern int readline_echoing_p; ++ return readline_echoing_p; ++ ; ++ return 0; ++} ++_ACEOF ++rm -f conftest.$ac_objext conftest$ac_exeext ++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ++ (eval $ac_link) 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && ++ { ac_try='test -z "$ac_c_werror_flag" ++ || test ! -s conftest.err' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; } && ++ { ac_try='test -s conftest$ac_exeext' ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; }; then ++ READLINE_ECHOING_P=yes ++else ++ echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++READLINE_ECHOING_P=no ++ ++cat >>confdefs.h <<\_ACEOF ++#define readline_echoing_p _rl_echoing_p ++_ACEOF ++ ++fi ++rm -f conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LIBS="$save_LIBS" ++ echo "$as_me:$LINENO: result: $READLINE_ECHOING_P" >&5 ++echo "${ECHO_T}$READLINE_ECHOING_P" >&6 + else + READLINE='$(READLINE_DIR)/libreadline.a' + READLINE_DEPS='$(READLINE)' + + --- gdb-7.0.1.orig/debian/patches/gdb-6.3-pie-20050110.patch +++ gdb-7.0.1/debian/patches/gdb-6.3-pie-20050110.patch @@ -0,0 +1,1329 @@ +2007-11-02 Jan Kratochvil + + Port to GDB-6.7.1. + +2007-11-02 Jan Kratochvil + + Port to post-GDB-6.7.1 multi-PC breakpoints. + +2007-11-09 Jan Kratochvil + + * solib-svr4.c (svr4_current_sos): Fix segfault on NULL EXEC_BFD. + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. + +2008-02-27 Jan Kratochvil + + Port to gdb-6.7.50.20080227. + +2008-06-01 Jan Kratochvil + + Fix crash on a watchpoint update on an inferior stop. + +2008-09-01 Jan Kratochvil + + Fix scan_dyntag() for binaries provided by valgrind (BZ 460319). + +Index: gdb-6.8.91.20090917/gdb/amd64-tdep.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/amd64-tdep.c 2009-09-17 12:48:49.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/amd64-tdep.c 2009-09-17 12:50:07.000000000 +0200 +@@ -36,6 +36,7 @@ + #include "regcache.h" + #include "regset.h" + #include "symfile.h" ++#include "exceptions.h" + + #include "gdb_assert.h" + +@@ -1591,18 +1592,31 @@ amd64_analyze_stack_align (CORE_ADDR pc, + Any function that doesn't start with this sequence will be assumed + to have no prologue and thus no valid frame pointer in %rbp. */ + +-static CORE_ADDR +-amd64_analyze_prologue (struct gdbarch *gdbarch, +- CORE_ADDR pc, CORE_ADDR current_pc, +- struct amd64_frame_cache *cache) ++struct amd64_analyze_prologue_data ++ { ++ struct gdbarch *gdbarch; ++ CORE_ADDR pc, current_pc; ++ struct amd64_frame_cache *cache; ++ CORE_ADDR retval; ++ }; ++ ++static int ++amd64_analyze_prologue_1 (void *data_pointer) + { ++ struct amd64_analyze_prologue_data *data = data_pointer; ++ struct gdbarch *gdbarch = data->gdbarch; ++ CORE_ADDR pc = data->pc, current_pc = data->current_pc; ++ struct amd64_frame_cache *cache = data->cache; + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */ + gdb_byte buf[3]; + gdb_byte op; + + if (current_pc <= pc) +- return current_pc; ++ { ++ data->retval = current_pc; ++ return 1; ++ } + + pc = amd64_analyze_stack_align (pc, current_pc, cache); + +@@ -1617,18 +1631,59 @@ amd64_analyze_prologue (struct gdbarch * + + /* If that's all, return now. */ + if (current_pc <= pc + 1) +- return current_pc; ++ { ++ data->retval = current_pc; ++ return 1; ++ } + + /* Check for `movq %rsp, %rbp'. */ + read_memory (pc + 1, buf, 3); + if (memcmp (buf, proto, 3) != 0) +- return pc + 1; ++ { ++ data->retval = pc + 1; ++ return 1; ++ } + + /* OK, we actually have a frame. */ + cache->frameless_p = 0; +- return pc + 4; ++ data->retval = pc + 4; ++ return 1; + } + ++ data->retval = pc; ++ return 1; ++} ++ ++/* Catch memory read errors and return just PC in such case. ++ It occurs very early on enable_break->new_symfile_objfile-> ++ ->breakpoint_re_set->decode_line_1->decode_variable_1-> ++ ->find_function_start_sal */ ++ ++static CORE_ADDR ++amd64_analyze_prologue (struct gdbarch *gdbarch, ++ CORE_ADDR pc, CORE_ADDR current_pc, ++ struct amd64_frame_cache *cache) ++{ ++ int status; ++ struct amd64_analyze_prologue_data data; ++ struct ui_file *saved_gdb_stderr; ++ ++ /* Suppress error messages. */ ++ saved_gdb_stderr = gdb_stderr; ++ gdb_stderr = ui_file_new (); ++ ++ data.gdbarch = gdbarch; ++ data.pc = pc; ++ data.current_pc = current_pc; ++ data.cache = cache; ++ status = catch_errors (amd64_analyze_prologue_1, &data, "", RETURN_MASK_ALL); ++ ++ /* Stop suppressing error messages. */ ++ ui_file_delete (gdb_stderr); ++ gdb_stderr = saved_gdb_stderr; ++ ++ if (status) ++ return data.retval; + return pc; + } + +Index: gdb-6.8.91.20090917/gdb/auxv.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/auxv.c 2009-07-02 19:25:52.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/auxv.c 2009-09-17 12:50:07.000000000 +0200 +@@ -78,7 +78,7 @@ procfs_xfer_auxv (struct target_ops *ops + Return 1 if an entry was read into *TYPEP and *VALP. */ + static int + default_auxv_parse (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp) + { + const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch) + / TARGET_CHAR_BIT; +@@ -106,7 +106,7 @@ default_auxv_parse (struct target_ops *o + Return 1 if an entry was read into *TYPEP and *VALP. */ + int + target_auxv_parse (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp) + { + struct target_ops *t; + for (t = ops; t != NULL; t = t->beneath) +@@ -121,9 +121,10 @@ target_auxv_parse (struct target_ops *op + an error getting the information. On success, return 1 after + storing the entry's value field in *VALP. */ + int +-target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp) ++target_auxv_search (struct target_ops *ops, ULONGEST match, CORE_ADDR *valp) + { +- CORE_ADDR type, val; ++ CORE_ADDR val; ++ ULONGEST at_type; + gdb_byte *data; + LONGEST n = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, &data); + gdb_byte *ptr = data; +@@ -133,10 +134,10 @@ target_auxv_search (struct target_ops *o + return n; + + while (1) +- switch (target_auxv_parse (ops, &ptr, data + n, &type, &val)) ++ switch (target_auxv_parse (ops, &ptr, data + n, &at_type, &val)) + { + case 1: /* Here's an entry, check it. */ +- if (type == match) ++ if (at_type == match) + { + xfree (data); + *valp = val; +@@ -159,7 +160,8 @@ target_auxv_search (struct target_ops *o + int + fprint_target_auxv (struct ui_file *file, struct target_ops *ops) + { +- CORE_ADDR type, val; ++ CORE_ADDR val; ++ ULONGEST at_type; + gdb_byte *data; + LONGEST len = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, + &data); +@@ -169,13 +171,13 @@ fprint_target_auxv (struct ui_file *file + if (len <= 0) + return len; + +- while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0) ++ while (target_auxv_parse (ops, &ptr, data + len, &at_type, &val) > 0) + { + const char *name = "???"; + const char *description = ""; + enum { dec, hex, str } flavor = hex; + +- switch (type) ++ switch (at_type) + { + #define TAG(tag, text, kind) \ + case tag: name = #tag; description = text; flavor = kind; break +@@ -231,7 +233,7 @@ fprint_target_auxv (struct ui_file *file + } + + fprintf_filtered (file, "%-4s %-20s %-30s ", +- plongest (type), name, description); ++ plongest (at_type), name, description); + switch (flavor) + { + case dec: +@@ -253,7 +255,7 @@ fprint_target_auxv (struct ui_file *file + break; + } + ++ents; +- if (type == AT_NULL) ++ if (at_type == AT_NULL) + break; + } + +Index: gdb-6.8.91.20090917/gdb/auxv.h +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/auxv.h 2009-06-07 21:07:08.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/auxv.h 2009-09-17 12:50:07.000000000 +0200 +@@ -31,14 +31,14 @@ + Return 1 if an entry was read into *TYPEP and *VALP. */ + extern int target_auxv_parse (struct target_ops *ops, + gdb_byte **readptr, gdb_byte *endptr, +- CORE_ADDR *typep, CORE_ADDR *valp); ++ ULONGEST *typep, CORE_ADDR *valp); + + /* Extract the auxiliary vector entry with a_type matching MATCH. + Return zero if no such entry was found, or -1 if there was + an error getting the information. On success, return 1 after + storing the entry's value field in *VALP. */ + extern int target_auxv_search (struct target_ops *ops, +- CORE_ADDR match, CORE_ADDR *valp); ++ ULONGEST match, CORE_ADDR *valp); + + /* Print the contents of the target's AUXV on the specified file. */ + extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); +Index: gdb-6.8.91.20090917/gdb/dwarf2read.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/dwarf2read.c 2009-09-17 12:49:20.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/dwarf2read.c 2009-09-17 12:50:07.000000000 +0200 +@@ -1717,7 +1717,7 @@ dwarf2_build_psymtabs (struct objfile *o + dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame); + dwarf2_read_section (objfile, &dwarf2_per_objfile->frame); + +- if (mainline ++ if ((mainline == 1) + || (objfile->global_psymbols.size == 0 + && objfile->static_psymbols.size == 0)) + { +Index: gdb-6.8.91.20090917/gdb/elfread.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/elfread.c 2009-09-17 12:47:07.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/elfread.c 2009-09-17 12:50:07.000000000 +0200 +@@ -681,7 +681,7 @@ elf_symfile_read (struct objfile *objfil + /* If we are reinitializing, or if we have never loaded syms yet, + set table to empty. MAINLINE is cleared so that *_read_psymtab + functions do not all also re-initialize the psymbol table. */ +- if (mainline) ++ if (mainline == 1) + { + init_psymbol_list (objfile, 0); + mainline = 0; +Index: gdb-6.8.91.20090917/gdb/infrun.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/infrun.c 2009-09-17 12:48:50.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/infrun.c 2009-09-17 12:50:07.000000000 +0200 +@@ -3659,6 +3659,10 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME ( + #endif + target_terminal_inferior (); + ++ /* For PIE executables, we dont really know where the ++ breakpoints are going to be until we start up the inferior. */ ++ enable_breakpoints_after_startup (); ++ + /* If requested, stop when the dynamic linker notifies + gdb of events. This allows the user to get control + and place breakpoints in initializer routines for +Index: gdb-6.8.91.20090917/gdb/objfiles.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/objfiles.c 2009-09-17 12:47:07.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/objfiles.c 2009-09-17 12:50:20.000000000 +0200 +@@ -53,6 +53,9 @@ + #include "observer.h" + #include "complaints.h" + ++#include "auxv.h" ++#include "elf/common.h" ++ + /* Prototypes for local functions */ + + static void objfile_alloc_data (struct objfile *objfile); +@@ -280,9 +283,17 @@ init_entry_point_info (struct objfile *o + CORE_ADDR + entry_point_address (void) + { ++ int ret; ++ + struct gdbarch *gdbarch; + CORE_ADDR entry_point; + ++ /* Find the address of the entry point of the program from the ++ auxv vector. */ ++ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_point); ++ if (ret == 1) ++ return entry_point; ++ + if (symfile_objfile == NULL) + return 0; + +@@ -467,6 +478,9 @@ free_objfile (struct objfile *objfile) + if (objfile == symfile_objfile) + symfile_objfile = NULL; + ++ if (objfile == symfile_objfile) ++ symfile_objfile = NULL; ++ + /* Before the symbol table code was redone to make it easier to + selectively load and remove information particular to a specific + linkage unit, gdb used to do these things whenever the monolithic +Index: gdb-6.8.91.20090917/gdb/solib-svr4.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/solib-svr4.c 2009-09-17 12:48:50.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/solib-svr4.c 2009-09-17 12:50:07.000000000 +0200 +@@ -47,6 +47,7 @@ + #include "exec.h" + #include "auxv.h" + #include "exceptions.h" ++#include "command.h" + + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); + static int svr4_have_link_map_offsets (void); +@@ -359,7 +360,9 @@ solib_svr4_inferior_exit (int pid) + + /* Local function prototypes */ + ++#if 0 + static int match_main (char *); ++#endif + + static CORE_ADDR bfd_lookup_symbol (bfd *, char *); + +@@ -600,10 +603,12 @@ scan_dyntag (int dyntag, bfd *abfd, CORE + int arch_size, step, sect_size; + long dyn_tag; + CORE_ADDR dyn_ptr, dyn_addr; ++ CORE_ADDR reloc_addr = 0; + gdb_byte *bufend, *bufstart, *buf; + Elf32_External_Dyn *x_dynp_32; + Elf64_External_Dyn *x_dynp_64; + struct bfd_section *sect; ++ int ret; + + if (abfd == NULL) + return 0; +@@ -615,19 +620,81 @@ scan_dyntag (int dyntag, bfd *abfd, CORE + if (arch_size == -1) + return 0; + ++ /* The auxv vector based relocatable files reading is limited to the main ++ executable. */ ++ gdb_assert (abfd == exec_bfd || ptr == NULL); ++ ++ if (ptr != NULL) ++ { ++ CORE_ADDR entry_addr; ++ ++ /* Find the address of the entry point of the program from the ++ auxv vector. */ ++ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_addr); ++ ++ if (ret == 0 || ret == -1) ++ { ++ /* No auxv info, maybe an older kernel. Fake our way through. */ ++ entry_addr = bfd_get_start_address (exec_bfd); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: program entry address not found. Using bfd's %s for %s\n", ++ paddress (target_gdbarch, entry_addr), exec_bfd->filename); ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: found program entry address %s for %s\n", ++ paddress (target_gdbarch, entry_addr), exec_bfd->filename); ++ } ++ reloc_addr = entry_addr - bfd_get_start_address (exec_bfd); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: expected relocation offset %s for %s\n", ++ paddress (target_gdbarch, reloc_addr), exec_bfd->filename); ++ } ++ + /* Find the start address of the .dynamic section. */ + sect = bfd_get_section_by_name (abfd, ".dynamic"); + if (sect == NULL) +- return 0; ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic section not found in %s -- return now\n", ++ exec_bfd->filename); ++ return 0; ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic section found in %s\n", ++ exec_bfd->filename); ++ } ++ + dyn_addr = bfd_section_vma (abfd, sect); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic addr %s\n", ++ paddress (target_gdbarch, dyn_addr)); + + /* Read in .dynamic from the BFD. We will get the actual value + from memory later. */ + sect_size = bfd_section_size (abfd, sect); + buf = bufstart = alloca (sect_size); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: read in .dynamic section\n"); + if (!bfd_get_section_contents (abfd, sect, + buf, 0, sect_size)) +- return 0; ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: couldn't read .dynamic section -- return now\n"); ++ return 0; ++ } + + /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */ + step = (arch_size == 32) ? sizeof (Elf32_External_Dyn) +@@ -648,26 +715,105 @@ scan_dyntag (int dyntag, bfd *abfd, CORE + dyn_tag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); + dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr); + } +- if (dyn_tag == DT_NULL) ++ ++ /* Verify RELOC_ADDR makes sense - it does not have to for valgrind which ++ supplies us a specially crafted executable in /proc/PID/fd/X while ++ /proc/PID/auxv corresponds to a different executable (.../memcheck). */ ++ if (reloc_addr) ++ { ++ gdb_byte tag_buf[8]; ++ CORE_ADDR tag_addr; ++ ++ tag_addr = dyn_addr + (buf - bufstart) + reloc_addr; ++ if (target_read_memory (tag_addr, tag_buf, arch_size / 8) == 0) ++ { ++ if (memcmp (tag_buf, buf, arch_size / 8) != 0) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: tag at offset 0x%lx does not match," ++ " dropping relocation offset %s\n", ++ (unsigned long) (buf - bufstart), paddress (target_gdbarch, reloc_addr)); ++ reloc_addr = 0; ++ } ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: tag at offset 0x%lx is not readable," ++ " dropping relocation offset %s\n", ++ (unsigned long) (buf - bufstart), paddress (target_gdbarch, reloc_addr)); ++ reloc_addr = 0; ++ } ++ } ++ ++ if (dyn_tag == DT_NULL) + return 0; +- if (dyn_tag == dyntag) +- { +- /* If requested, try to read the runtime value of this .dynamic +- entry. */ +- if (ptr) +- { +- struct type *ptr_type; +- gdb_byte ptr_buf[8]; +- CORE_ADDR ptr_addr; +- +- ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; +- ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8; +- if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0) +- dyn_ptr = extract_typed_address (ptr_buf, ptr_type); +- *ptr = dyn_ptr; +- } +- return 1; +- } ++ if (dyn_tag == dyntag) ++ { ++ /* If requested, try to read the runtime value of this .dynamic ++ entry. */ ++ if (ptr) ++ { ++ gdb_byte ptr_buf[8]; ++ CORE_ADDR ptr_addr; ++ int got; ++ ++ ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8; ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: unrelocated ptr addr %s\n", ++ paddress (target_gdbarch, ptr_addr)); ++ ptr_addr += reloc_addr; ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: relocated ptr addr %s" ++ " (relocation offset %s) for %s\n", ++ paddress (target_gdbarch, ptr_addr), paddress (target_gdbarch, reloc_addr), ++ exec_bfd->filename); ++ } ++ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8); ++ if (got != 0 && reloc_addr) ++ { ++ ptr_addr -= reloc_addr; ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: unrelocated back to ptr addr %s" ++ " as the memory was unreable for %s\n", ++ paddress (target_gdbarch, ptr_addr), exec_bfd->filename); ++ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8); ++ } ++ ++ if (got == 0) ++ { ++ struct type *ptr_type; ++ ++ ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; ++ dyn_ptr = extract_typed_address (ptr_buf, ptr_type); ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: Tag entry has value %s -- return now\n", ++ paddress (target_gdbarch, dyn_ptr)); ++ } ++ } ++ else ++ { ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: Couldn't read tag entry value -- return now\n"); ++ } ++ } ++ *ptr = dyn_ptr; ++ } ++ return 1; ++ } + } + + return 0; +@@ -1040,6 +1186,11 @@ svr4_current_sos (void) + CORE_ADDR ldsomap = 0; + struct inferior *inf; + struct svr4_info *info; ++ const char *filename = exec_bfd ? exec_bfd->filename : ""; ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: exec_bfd %s\n", filename); + + if (ptid_equal (inferior_ptid, null_ptid)) + return NULL; +@@ -1054,7 +1205,13 @@ svr4_current_sos (void) + /* If we can't find the dynamic linker's base structure, this + must not be a dynamically linked executable. Hmm. */ + if (! info->debug_base) +- return svr4_default_sos (); ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: no DT_DEBUG found in %s -- return now\n", ++ filename); ++ return svr4_default_sos (); ++ } + + /* Walk the inferior's link map list, and build our list of + `struct so_list' nodes. */ +@@ -1074,26 +1231,104 @@ svr4_current_sos (void) + new->lm_info->lm = xzalloc (lmo->link_map_size); + make_cleanup (xfree, new->lm_info->lm); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: read lm at %s\n", paddress (target_gdbarch, lm)); + read_memory (lm, new->lm_info->lm, lmo->link_map_size); + + lm = LM_NEXT (new); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: is first link entry? %d\n", ++ IGNORE_FIRST_LINK_MAP_ENTRY (new)); ++ + /* For SVR4 versions, the first entry in the link map is for the + inferior executable, so we must ignore it. For some versions of + SVR4, it has no name. For others (Solaris 2.3 for example), it + does have a name, so we can no longer use a missing name to + decide when to ignore it. */ +- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) ++ if (exec_bfd != NULL && IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) + { +- info->main_lm_addr = new->lm_info->lm_addr; +- free_so (new); +- } ++ /* It is the first link map entry, i.e. it is the main executable. */ ++ ++ if (bfd_get_start_address (exec_bfd) == entry_point_address ()) ++ { ++ /* Non-pie case, main executable has not been relocated. */ ++ info->main_lm_addr = new->lm_info->lm_addr; ++ free_so (new); ++ } ++ else ++ { ++ /* Pie case, main executable has been relocated. */ ++ struct so_list *gdb_solib; ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: Processing first link map entry\n"); ++ strncpy (new->so_name, exec_bfd->filename, ++ SO_NAME_MAX_PATH_SIZE - 1); ++ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ strcpy (new->so_original_name, new->so_name); ++ /*new->main = 1;*/ ++ new->main_relocated = 0; ++ ++ if (debug_solib) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: Processing nameless DSO\n"); ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: adding name %s\n", ++ new->so_name); ++ } ++ ++ for (gdb_solib = master_so_list (); ++ gdb_solib; ++ gdb_solib = gdb_solib->next) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: compare gdb %s and new %s\n", ++ gdb_solib->so_name, new->so_name); ++ if (strcmp (gdb_solib->so_name, new->so_name) == 0) ++ if (gdb_solib->main_relocated) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: found main relocated\n"); ++ break; ++ } ++ } ++ ++ if ((gdb_solib && !gdb_solib->main_relocated) || (!gdb_solib)) ++ { ++ add_to_target_sections (0 /*from_tty*/, ¤t_target, new); ++ new->main = 1; ++ } ++ ++ /* We need this in the list of shared libs we return because ++ solib_add_stub will loop through it and add the symbol file. */ ++ new->next = 0; ++ *link_ptr = new; ++ link_ptr = &new->next; ++ } ++ } /* End of IGNORE_FIRST_LINK_MAP_ENTRY */ + else + { ++ /* This is not the first link map entry, i.e. is not the main ++ executable. Note however that it could be the DSO supplied on ++ certain systems (i.e. Linux 2.6) containing information about ++ the vsyscall page. We must ignore such entry. This entry is ++ nameless (just like the one for the main executable, sigh). */ ++ + int errcode; + char *buffer; + + /* Extract this shared object's name. */ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: read LM_NAME\n"); ++ + target_read_string (LM_NAME (new), &buffer, + SO_NAME_MAX_PATH_SIZE - 1, &errcode); + if (errcode != 0) +@@ -1101,47 +1336,60 @@ svr4_current_sos (void) + safe_strerror (errcode)); + else + { +- struct build_id *build_id; ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: LM_NAME is <%s>\n", ++ buffer); ++ /* The name could be empty, in which case it is the ++ system supplied DSO. */ ++ if (strcmp (buffer, "") == 0) ++ free_so (new); ++ else ++ { ++ 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); ++ 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; ++ 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); ++ ++ xfree (build_id_filename); ++ xfree (build_id); ++ } + +- /* 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) ++ if (debug_solib) + { +- strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1); +- new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; +- xfree (name); ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: Processing DSO: %s\n", ++ new->so_name); ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: first link entry %d\n", ++ IGNORE_FIRST_LINK_MAP_ENTRY (new)); + } +- else +- debug_print_missing (new->so_name, build_id_filename); + +- xfree (build_id_filename); +- xfree (build_id); ++ new->next = 0; ++ *link_ptr = new; ++ link_ptr = &new->next; + } + } +- xfree (buffer); +- +- /* If this entry has no name, or its name matches the name +- for the main executable, don't include it in the list. */ +- if (! new->so_name[0] +- || match_main (new->so_name)) +- free_so (new); +- else +- { +- new->next = 0; +- *link_ptr = new; +- link_ptr = &new->next; +- } ++ xfree (buffer); + } + + /* On Solaris, the dynamic linker is not in the normal list of +@@ -1157,6 +1405,9 @@ svr4_current_sos (void) + if (head == NULL) + return svr4_default_sos (); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, "svr4_current_sos: ENDS %s\n", filename); ++ + return head; + } + +@@ -1189,7 +1440,7 @@ svr4_fetch_objfile_link_map (struct objf + /* On some systems, the only way to recognize the link map entry for + the main executable file is by looking at its name. Return + non-zero iff SONAME matches one of the known main executable names. */ +- ++#if 0 + static int + match_main (char *soname) + { +@@ -1203,6 +1454,7 @@ match_main (char *soname) + + return (0); + } ++#endif + + /* Return 1 if PC lies in the dynamic symbol resolution code of the + SVR4 run time loader. */ +@@ -1354,15 +1606,29 @@ enable_break (struct svr4_info *info) + /* Find the program interpreter; if not found, warn the user and drop + into the old breakpoint at symbol code. */ + interp_name = find_program_interpreter (); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "enable_break: search for .interp in %s\n", ++ exec_bfd->filename); + if (interp_name) + { + CORE_ADDR load_addr = 0; ++ CORE_ADDR load_addr_mask = -1L; + int load_addr_found = 0; + int loader_found_in_list = 0; + struct so_list *so; + bfd *tmp_bfd = NULL; + struct target_ops *tmp_bfd_target; + volatile struct gdb_exception ex; ++ int arch_size; ++ ++ /* For 32bit inferiors with 64bit GDB we may get LOAD_ADDR at 0xff...... ++ and thus overflowing its addition to the address while CORE_ADDR is ++ 64bit producing 0x1........ address invalid across GDB. */ ++ arch_size = bfd_get_arch_size (exec_bfd); ++ if (arch_size > 0 && arch_size < sizeof (1UL) * 8) ++ load_addr_mask = (1UL << arch_size) - 1; + + sym_addr = 0; + +@@ -1379,6 +1645,9 @@ enable_break (struct svr4_info *info) + { + tmp_bfd = solib_bfd_open (interp_name); + } ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "enable_break: opening %s\n", interp_name); + if (tmp_bfd == NULL) + goto bkpt_at_symbol; + +@@ -1436,16 +1705,16 @@ enable_break (struct svr4_info *info) + interp_sect = bfd_get_section_by_name (tmp_bfd, ".text"); + if (interp_sect) + { +- interp_text_sect_low = +- bfd_section_vma (tmp_bfd, interp_sect) + load_addr; ++ interp_text_sect_low = (bfd_section_vma (tmp_bfd, interp_sect) ++ + load_addr) & load_addr_mask; + interp_text_sect_high = + interp_text_sect_low + bfd_section_size (tmp_bfd, interp_sect); + } + interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt"); + if (interp_sect) + { +- interp_plt_sect_low = +- bfd_section_vma (tmp_bfd, interp_sect) + load_addr; ++ interp_plt_sect_low = (bfd_section_vma (tmp_bfd, interp_sect) ++ + load_addr) & load_addr_mask; + interp_plt_sect_high = + interp_plt_sect_low + bfd_section_size (tmp_bfd, interp_sect); + } +@@ -1480,7 +1749,7 @@ enable_break (struct svr4_info *info) + + if (sym_addr != 0) + { +- create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr); ++ create_solib_event_breakpoint (target_gdbarch, (load_addr + sym_addr) & load_addr_mask); + xfree (interp_name); + return 1; + } +@@ -1753,6 +2022,9 @@ svr4_solib_create_inferior_hook (void) + while (tp->stop_signal != TARGET_SIGNAL_TRAP); + inf->stop_soon = NO_STOP_QUIETLY; + #endif /* defined(_SCO_DS) */ ++ ++ if (bfd_get_start_address (exec_bfd) != entry_point_address ()) ++ disable_breakpoints_before_startup (); + } + + static void +@@ -1929,6 +2201,76 @@ svr4_lp64_fetch_link_map_offsets (void) + + return lmp; + } ++void ++info_linkmap_command (char *cmd, int from_tty) ++{ ++ CORE_ADDR lm; ++ struct svr4_info *info = get_svr4_info (PIDGET (inferior_ptid)); ++ ++ /* Make sure we've looked up the inferior's dynamic linker's base ++ structure. */ ++ if (! info->debug_base) ++ { ++ info->debug_base = locate_base (info); ++ ++ /* If we can't find the dynamic linker's base structure, this ++ must not be a dynamically linked executable. Hmm. */ ++ if (! info->debug_base) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_print_linkmap: no DT_DEBUG found in %s -- return now\n", ++ exec_bfd->filename); ++ return; ++ } ++ } ++ ++ /* Walk the inferior's link map list, and print the info. */ ++ ++ lm = solib_svr4_r_map (info); ++ while (lm) ++ { ++ int errcode; ++ char *buffer; ++ CORE_ADDR load_addr; ++ ++ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); ++ struct so_list *new ++ = (struct so_list *) xmalloc (sizeof (struct so_list)); ++ struct cleanup *old_chain = make_cleanup (xfree, new); ++ ++ memset (new, 0, sizeof (*new)); ++ ++ new->lm_info = xmalloc (sizeof (struct lm_info)); ++ make_cleanup (xfree, new->lm_info); ++ ++ new->lm_info->lm = xmalloc (lmo->link_map_size); ++ make_cleanup (xfree, new->lm_info->lm); ++ memset (new->lm_info->lm, 0, lmo->link_map_size); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_print_linkmap: read lm at %s\n", paddress (target_gdbarch, lm)); ++ read_memory (lm, new->lm_info->lm, lmo->link_map_size); ++ ++ lm = LM_NEXT (new); ++ ++ /* Load address. */ ++ load_addr = LM_ADDR_CHECK (new, NULL); ++ /* Shared object's name. */ ++ target_read_string (LM_NAME (new), &buffer, ++ SO_NAME_MAX_PATH_SIZE - 1, &errcode); ++ make_cleanup (xfree, buffer); ++ if (errcode != 0) ++ { ++ warning ("svr4_print_linkmap: Can't read pathname for load map: %s\n", ++ safe_strerror (errcode)); ++ } ++ fprintf_filtered (gdb_stdout, "%-8s %-30s\n", paddress (target_gdbarch, load_addr), buffer); ++ do_cleanups (old_chain); ++ } ++} ++ + + + struct target_so_ops svr4_so_ops; +@@ -1969,4 +2311,7 @@ _initialize_svr4_solib (void) + svr4_so_ops.same = svr4_same; + + observer_attach_inferior_exit (solib_svr4_inferior_exit); ++ ++ add_info ("linkmap", info_linkmap_command, ++ "Display the inferior's linkmap."); + } +Index: gdb-6.8.91.20090917/gdb/solib.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/solib.c 2009-09-17 12:47:07.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/solib.c 2009-09-17 12:50:07.000000000 +0200 +@@ -82,6 +82,8 @@ set_solib_ops (struct gdbarch *gdbarch, + + /* external data declarations */ + ++int debug_solib; ++ + /* FIXME: gdbarch needs to control this variable, or else every + configuration needs to call set_solib_ops. */ + struct target_so_ops *current_target_so_ops; +@@ -105,6 +107,8 @@ The search path for loading non-absolute + value); + } + ++void add_to_target_sections (int, struct target_ops *, struct so_list *); ++ + /* + + GLOBAL FUNCTION +@@ -449,14 +453,38 @@ symbol_add_stub (struct so_list *so, int + /* Have we already loaded this shared object? */ + ALL_OBJFILES (so->objfile) + { +- if (strcmp (so->objfile->name, so->so_name) == 0) ++ /* Found an already loaded shared library. */ ++ if (strcmp (so->objfile->name, so->so_name) == 0 ++ && !so->main) ++ return; ++ /* Found an already loaded main executable. This could happen in ++ two circumstances. ++ First case: the main file has already been read in ++ as the first thing that gdb does at startup, and the file ++ hasn't been relocated properly yet. Therefor we need to read ++ it in with the proper section info. ++ Second case: it has been read in with the correct relocation, ++ and therefore we need to skip it. */ ++ if (strcmp (so->objfile->name, so->so_name) == 0 ++ && so->main ++ && so->main_relocated) + return; + } + + sap = build_section_addr_info_from_section_table (so->sections, + so->sections_end); + +- so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); ++ if (so->main) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "symbol_add_stub: adding symbols for main\n"); ++ so->objfile = symbol_file_add_from_bfd (so->abfd, (flags & ~SYMFILE_VERBOSE) | SYMFILE_MAINLINE, sap, 0); ++ so->main_relocated = 1; ++ } ++ else ++ so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); ++ + free_section_addr_info (sap); + + return; +@@ -596,6 +624,10 @@ update_solib_list (int from_tty, struct + } + else + { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "update_solib_list: compare gdb:%s and inferior:%s\n", ++ gdb->so_original_name, i->so_original_name); + if (! strcmp (gdb->so_original_name, i->so_original_name)) + break; + } +@@ -650,18 +682,7 @@ update_solib_list (int from_tty, struct + /* Fill in the rest of each of the `struct so_list' nodes. */ + for (i = inferior; i; i = i->next) + { +- i->from_tty = from_tty; +- +- /* Fill in the rest of the `struct so_list' node. */ +- catch_errors (solib_map_sections, i, +- "Error while mapping shared library sections:\n", +- RETURN_MASK_ALL); +- +- /* Add the shared object's sections to the current set of +- file section tables. Do this immediately after mapping +- the object so that later nodes in the list can query this +- object, as is needed in solib-osf.c. */ +- add_target_sections (i->sections, i->sections_end); ++ add_to_target_sections (from_tty, target, i); + + /* Notify any observer that the shared object has been + loaded now that we've added it to GDB's tables. */ +@@ -771,6 +792,32 @@ solib_add (char *pattern, int from_tty, + } + } + ++void ++add_to_target_sections (int from_tty, struct target_ops *target, struct so_list *solib) ++{ ++ /* If this is set, then the sections have been already added to the ++ target list. */ ++ if (solib->main) ++ return; ++ ++ solib->from_tty = from_tty; ++ ++ /* Fill in the rest of the `struct so_list' node. */ ++ catch_errors (solib_map_sections, solib, ++ "Error while mapping shared library sections:\n", ++ RETURN_MASK_ALL); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "add_to_target_sections: add %s to to_sections\n", ++ solib->so_original_name); ++ ++ /* Add the shared object's sections to the current set of ++ file section tables. Do this immediately after mapping ++ the object so that later nodes in the list can query this ++ object, as is needed in solib-osf.c. */ ++ add_target_sections (solib->sections, solib->sections_end); ++} + + /* + +@@ -1189,4 +1236,12 @@ This takes precedence over the environme + reload_shared_libraries, + show_solib_search_path, + &setlist, &showlist); ++ ++ add_setshow_boolean_cmd ("solib", no_class, &debug_solib, ++ _("\ ++Set debugging of GNU/Linux shlib module.\n"), _("\ ++Show debugging status of GNU/Linux shlib module.\n"), _("\ ++Enables printf debugging output of GNU/Linux shlib module.\n"), ++ NULL, NULL, ++ &setdebuglist, &showdebuglist); + } +Index: gdb-6.8.91.20090917/gdb/solist.h +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/solist.h 2009-09-17 12:47:07.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/solist.h 2009-09-17 12:50:07.000000000 +0200 +@@ -61,6 +61,8 @@ struct so_list + bfd *abfd; + char symbols_loaded; /* flag: symbols read in yet? */ + char from_tty; /* flag: print msgs? */ ++ char main; /* flag: is this the main executable? */ ++ char main_relocated; /* flag: has it been relocated yet? */ + struct objfile *objfile; /* objfile for loaded lib */ + struct target_section *sections; + struct target_section *sections_end; +@@ -147,4 +149,10 @@ struct symbol *solib_global_lookup (cons + const char *name, + const domain_enum domain); + ++/* Add the list of sections in so_list to the target to_sections. */ ++extern void add_to_target_sections (int, struct target_ops *, struct so_list *); ++ ++/* Controls the printing of debugging output. */ ++extern int debug_solib; ++ + #endif +Index: gdb-6.8.91.20090917/gdb/symfile-mem.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/symfile-mem.c 2009-09-17 12:48:49.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/symfile-mem.c 2009-09-17 12:50:07.000000000 +0200 +@@ -115,7 +115,7 @@ symbol_file_add_from_memory (struct bfd + ++i; + } + +- objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0, ++ objf = symbol_file_add_from_bfd (nbfd, (from_tty ? SYMFILE_VERBOSE : 0) | SYMFILE_MAINLINE2_BOTH, + sai, OBJF_SHARED); + + /* This might change our ideas about frames already looked at. */ +Index: gdb-6.8.91.20090917/gdb/symfile.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/symfile.c 2009-09-17 12:48:50.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/symfile.c 2009-09-17 12:50:07.000000000 +0200 +@@ -49,6 +49,7 @@ + #include "readline/readline.h" + #include "gdb_assert.h" + #include "block.h" ++#include "varobj.h" + #include "observer.h" + #include "exec.h" + #include "parser-defs.h" +@@ -779,7 +780,7 @@ syms_from_objfile (struct objfile *objfi + + /* Now either addrs or offsets is non-zero. */ + +- if (mainline) ++ if ((add_flags & SYMFILE_MAINLINE) && !(add_flags & SYMFILE_MAINLINE2_ONLY)) + { + /* We will modify the main symbol table, make sure that all its users + will be cleaned up if an error occurs during symbol reading. */ +@@ -807,7 +808,7 @@ syms_from_objfile (struct objfile *objfi + + We no longer warn if the lowest section is not a text segment (as + happens for the PA64 port. */ +- if (!mainline && addrs && addrs->other[0].name) ++ if (/*!mainline &&*/ addrs && addrs->other[0].name) + { + asection *lower_sect; + asection *sect; +@@ -890,7 +891,7 @@ syms_from_objfile (struct objfile *objfi + init_objfile_sect_indices (objfile); + } + +- (*objfile->sf->sym_read) (objfile, mainline); ++ (*objfile->sf->sym_read) (objfile, add_flags & SYMFILE_MAINLINE2_ONLY ? 2 : (add_flags & SYMFILE_MAINLINE ? 1 : 0)); + + /* Discard cleanups as symbol reading was successful. */ + +@@ -909,17 +910,22 @@ new_symfile_objfile (struct objfile *obj + /* If this is the main symbol file we have to clean up all users of the + old main symbol file. Otherwise it is sufficient to fixup all the + breakpoints that may have been redefined by this symbol file. */ +- if (add_flags & SYMFILE_MAINLINE) ++ if (add_flags & SYMFILE_MAINLINE && !(add_flags & SYMFILE_MAINLINE2_ONLY)) + { + /* OK, make it the "real" symbol file. */ + symfile_objfile = objfile; + + clear_symtab_users (); + } +- else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0) ++ else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0 ++ && (add_flags & SYMFILE_MAINLINE2_BOTH) == 0) + { + breakpoint_re_set (); + } ++ else ++ { ++ /* Don't reset breakpoints or it will screw up PIE. */ ++ } + + /* We're done reading the symbol file; finish off complaints. */ + clear_complaints (&symfile_complaints, 0, add_flags & SYMFILE_VERBOSE); +@@ -973,7 +979,7 @@ symbol_file_add_with_addrs_or_offsets (b + /* Give user a chance to burp if we'd be + interactively wiping out any existing symbols. */ + +- if ((add_flags & SYMFILE_MAINLINE) ++ if ((add_flags & SYMFILE_MAINLINE) && !(add_flags & SYMFILE_MAINLINE2_ONLY) + && (have_full_symbols () || have_partial_symbols ()) + && from_tty + && (have_full_symbols () || have_partial_symbols ()) +@@ -1163,6 +1169,9 @@ symbol_file_clear (int from_tty) + symfile_objfile->name) + : !query (_("Discard symbol table? ")))) + error (_("Not confirmed.")); ++#ifdef CLEAR_SOLIB ++ CLEAR_SOLIB (); ++#endif + + free_all_objfiles (); + +@@ -3369,6 +3378,8 @@ reread_symbols (void) + /* Discard cleanups as symbol reading was successful. */ + discard_cleanups (old_cleanups); + ++ init_entry_point_info (objfile); ++ + /* If the mtime has changed between the time we set new_modtime + and now, we *want* this to be out of date, so don't call stat + again now. */ +Index: gdb-6.8.91.20090917/gdb/target.h +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/target.h 2009-09-17 12:48:49.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/target.h 2009-09-17 12:50:07.000000000 +0200 +@@ -545,7 +545,7 @@ struct target_ops + Return -1 if there is insufficient buffer for a whole entry. + Return 1 if an entry was read into *TYPEP and *VALP. */ + int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp); + + /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the + sequence of bytes in PATTERN with length PATTERN_LEN. +Index: gdb-6.8.91.20090917/gdb/symfile.h +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/symfile.h 2009-09-17 12:48:50.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/symfile.h 2009-09-17 12:50:07.000000000 +0200 +@@ -229,7 +229,13 @@ enum symfile_add_flags + SYMFILE_MAINLINE = 1 << 2, + + /* Do not call breakpoint_re_set when adding this symbol file. */ +- SYMFILE_DEFER_BP_RESET = 1 << 3 ++ SYMFILE_DEFER_BP_RESET = 1 << 3, ++ ++ /* Red Hat PIE patch: Like SYMFILE_MAINLINE but for mainline == 2. ++ Former code was checking `if (mainline)' being satisfied both by ++ standard 1 and rare 2, simulate it here. */ ++ SYMFILE_MAINLINE2_ONLY = 1 << 4, ++ SYMFILE_MAINLINE2_BOTH = SYMFILE_MAINLINE2_ONLY | SYMFILE_MAINLINE + }; + + extern void syms_from_objfile (struct objfile *, +Index: gdb-6.8.91.20090917/gdb/infcmd.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/infcmd.c 2009-09-17 12:49:01.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/infcmd.c 2009-09-17 12:50:07.000000000 +0200 +@@ -2308,6 +2308,9 @@ attach_command_post_wait (char *args, in + + post_create_inferior (¤t_target, from_tty); + ++ /* Undo the disable from post_create_inferior. */ ++ enable_breakpoints_after_startup (); ++ + /* Install inferior's terminal modes. */ + target_terminal_inferior (); + +Index: gdb-6.8.91.20090917/gdb/linux-tdep.c +=================================================================== +--- gdb-6.8.91.20090917.orig/gdb/linux-tdep.c 2009-08-04 22:41:13.000000000 +0200 ++++ gdb-6.8.91.20090917/gdb/linux-tdep.c 2009-09-17 12:50:07.000000000 +0200 +@@ -163,5 +163,7 @@ in this session.\n")); + void + _initialize_linux_tdep (void) + { ++#if 0 /* gdb-6.3-pie-20050110.patch */ + observer_attach_executable_changed (check_is_pie_binary); ++#endif + } --- gdb-7.0.1.orig/debian/patches/gdb-pascal-support.patch +++ gdb-7.0.1/debian/patches/gdb-pascal-support.patch @@ -0,0 +1,25 @@ +Originally from: + http://www.math.uni.wroc.pl/~hebisch/gpc/ + +I believe this patch was posted to gdb-patches and never reviewed. +But M2 support added set types just before GDB 6.5, and now there's +not much left of this. + +--- + gdb/dwarf2read.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: gdb-6.8.50.20090628/gdb/dwarf2read.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/dwarf2read.c 2009-07-03 18:26:34.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/dwarf2read.c 2009-07-03 18:45:06.000000000 -0400 +@@ -8309,7 +8309,8 @@ determine_prefix (struct die_info *die, + struct type *parent_type; + + if (cu->language != language_cplus +- && cu->language != language_java) ++ && cu->language != language_java ++ && cu->language != language_pascal) + return ""; + + /* We have to be careful in the presence of DW_AT_specification. --- gdb-7.0.1.orig/debian/patches/arm_dis_thumb2.patch +++ gdb-7.0.1/debian/patches/arm_dis_thumb2.patch @@ -0,0 +1,16 @@ +## DP: Description: [arm] Prevent disassembler from aborting on an invalid Thumb2 instruction. + +diff -a -u -r1.111 arm-dis.c +--- ./opcodes/arm-dis.c 12 Nov 2009 14:49:45 -0000 1.111 ++++ ./opcodes/arm-dis.c 17 Nov 2009 10:20:30 -0000 +@@ -3932,6 +3932,10 @@ + func (stream, "%c", c[(1 << width) - (int) val]); + c += 1 << width; + break; ++ ++ case 'x': ++ func (stream, "0x%lx", val & 0xffffffffUL); ++ break; + + default: + abort (); --- gdb-7.0.1.orig/debian/patches/member-field-symtab.patch +++ gdb-7.0.1/debian/patches/member-field-symtab.patch @@ -0,0 +1,40 @@ +Status: unsubmitted + +This patch was for Debian bug #239535. It needs to be tested, and +submitted. + +--- + gdb/dwarf2read.c | 2 +- + gdb/valops.c | 4 +++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +Index: gdb-6.8.50.20090628/gdb/valops.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/valops.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/valops.c 2009-07-03 18:26:34.000000000 -0400 +@@ -2498,8 +2498,10 @@ check_field (struct type *type, const ch + return 1; + } + ++ /* Check each baseclass. Call check_typedef, which will follow typedefs ++ and do opaque/stub type resolution. */ + for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) +- if (check_field (TYPE_BASECLASS (type, i), name)) ++ if (check_field (check_typedef (TYPE_BASECLASS (type, i)), name)) + return 1; + + return 0; +Index: gdb-6.8.50.20090628/gdb/dwarf2read.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/dwarf2read.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/dwarf2read.c 2009-07-03 18:26:34.000000000 -0400 +@@ -2409,8 +2409,8 @@ guess_structure_name (struct partial_die + strlen (actual_class_name), + &cu->comp_unit_obstack); + xfree (actual_class_name); ++ break; + } +- break; + } + + child_pdi = child_pdi->die_sibling; --- gdb-7.0.1.orig/debian/patches/dwarf2-cfi-warning.patch +++ gdb-7.0.1/debian/patches/dwarf2-cfi-warning.patch @@ -0,0 +1,36 @@ +Status: Unsuitable for upstream (at least, without a lot of arguing). + +GCC does not specify the state of every last register in the CIE. Since +GCC's focus is on correctness of runtime unwinding, any registers which +have to be unwound will be specified; but unmodified registers will not +be explicitly marked. (How about modified, call-clobbered registers? +I'm not sure if they are marked as unavailable.) + +GDB issues a noisy warning about this. The warning is generally not useful, +and we can get it extremely frequently (any time we load a new CIE). + +This patch disables the warning. Alternately we could set the complaints +threshold to zero, or implement a default frame init-register method for +every architecture. But someday the compiler will support using different +calling conventions for internal functions, so that's not much of a stopgap. +ARM has a complex algorithm for handling this, involving scanning all CIEs - +benefit not completely clear outside of the ARM context of flexible register +sets. + +--- + gdb/dwarf2-frame.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: gdb-6.8.50.20090628/gdb/dwarf2-frame.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/dwarf2-frame.c 2009-06-27 20:20:21.000000000 -0400 ++++ gdb-6.8.50.20090628/gdb/dwarf2-frame.c 2009-07-03 18:39:34.000000000 -0400 +@@ -992,7 +992,7 @@ dwarf2_frame_cache (struct frame_info *t + DWARF2 register numbers. */ + if (fs->regs.reg[column].how == DWARF2_FRAME_REG_UNSPECIFIED) + { +- if (cache->reg[regnum].how == DWARF2_FRAME_REG_UNSPECIFIED) ++ if (0 && cache->reg[regnum].how == DWARF2_FRAME_REG_UNSPECIFIED) + complaint (&symfile_complaints, _("\ + incomplete CFI data; unspecified registers (e.g., %s) at 0x%s"), + gdbarch_register_name (gdbarch, regnum), --- gdb-7.0.1.orig/debian/patches/gdb-6.3-test-pie-20050107.patch +++ gdb-7.0.1/debian/patches/gdb-6.3-test-pie-20050107.patch @@ -0,0 +1,2125 @@ +Index: gdb-6.8.50.20090909/gdb/testsuite/configure.ac +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/testsuite/configure.ac 2009-07-31 17:38:16.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/testsuite/configure.ac 2009-09-09 19:06:01.000000000 +0200 +@@ -144,6 +144,6 @@ AC_OUTPUT([Makefile \ + gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \ + gdb.fortran/Makefile gdb.server/Makefile \ + gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \ +- gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \ ++ gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \ + gdb.python/Makefile gdb.reverse/Makefile \ + gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile]) +Index: gdb-6.8.50.20090909/gdb/testsuite/configure +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/testsuite/configure 2009-08-22 18:56:43.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/testsuite/configure 2009-09-09 19:06:27.000000000 +0200 +@@ -3515,7 +3515,7 @@ done + + + +-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/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.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/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 +@@ -4231,6 +4231,7 @@ do + "gdb.objc/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.objc/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.threads/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;; +Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c 2009-09-09 19:06:01.000000000 +0200 +@@ -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-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c 2009-09-09 19:06:01.000000000 +0200 +@@ -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-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c 2009-09-09 19:06:01.000000000 +0200 +@@ -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-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c 2009-09-09 19:06:01.000000000 +0200 +@@ -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-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c 2009-09-09 19:06:01.000000000 +0200 +@@ -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-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp 2009-09-09 19:06:01.000000000 +0200 +@@ -0,0 +1,432 @@ ++# 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. */ ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++if $tracelevel then { ++ strace $tracelevel ++ } ++ ++set prms_id 0 ++set bug_id 0 ++ ++# 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. ++ # ++ send_gdb "continue\n" ++ gdb_expect { ++ -re "Program exited normally.*$gdb_prompt $"\ ++ {pass "after attach2, exit"} ++ -re "$gdb_prompt $" {fail "after attach2, exit"} ++ timeout {fail "(timeout) 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.*libc.*$gdb_prompt $" { ++ 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" ".*Program 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-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp 2009-09-09 19:06:01.000000000 +0200 +@@ -0,0 +1,977 @@ ++# 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 ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++ ++# ++# test running programs ++# ++set prms_id 0 ++set bug_id 0 ++ ++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-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp 2009-09-09 19:06:01.000000000 +0200 +@@ -0,0 +1,243 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Fred Fish. (fnf@cygnus.com) ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++# 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-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in 2009-09-09 19:06:01.000000000 +0200 +@@ -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.* --- gdb-7.0.1.orig/debian/patches/gdb-6.6-buildid-locate.patch +++ gdb-7.0.1/debian/patches/gdb-6.6-buildid-locate.patch @@ -0,0 +1,1012 @@ +Index: gdb-6.8.50.20090909/gdb/corelow.c +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/corelow.c 2009-09-09 19:09:35.000000000 +0200 +@@ -45,6 +45,10 @@ + #include "exceptions.h" + #include "solib.h" + #include "filenames.h" ++#include "auxv.h" ++#include "elf/common.h" ++#include "objfiles.h" ++#include "gdbcmd.h" + + + #ifndef O_LARGEFILE +@@ -273,6 +277,50 @@ 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) ++ 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); ++ } ++ 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 +@@ -371,6 +419,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); ++ + add_inferior_silent (corelow_pid); + + /* Do this before acknowledging the inferior, so if +@@ -878,4 +932,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-6.8.50.20090909/gdb/doc/gdb.texinfo +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/doc/gdb.texinfo 2009-09-09 19:09:31.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/doc/gdb.texinfo 2009-09-09 19:09:35.000000000 +0200 +@@ -13764,6 +13764,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-6.8.50.20090909/gdb/solib-svr4.c +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/solib-svr4.c 2009-09-09 19:05:56.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/solib-svr4.c 2009-09-09 19:09:35.000000000 +0200 +@@ -1101,9 +1101,33 @@ 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); ++ ++ xfree (build_id_filename); ++ xfree (build_id); ++ } + } + xfree (buffer); + +Index: gdb-6.8.50.20090909/gdb/symfile.c +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/symfile.c 2009-09-09 19:09:31.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/symfile.c 2009-09-09 19:09:55.000000000 +0200 +@@ -56,6 +56,7 @@ + #include "elf-bfd.h" + #include "solib.h" + #include "remote.h" ++#include "libbfd.h" + + #include + #include +@@ -1174,16 +1175,65 @@ symbol_file_clear (int from_tty) + printf_unfiltered (_("No symbol file now.\n")); + } + ++/* Locate NT_GNU_BUILD_ID and return its matching debug filename. ++ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ ++ ++#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. */ ++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; + +@@ -1199,6 +1249,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 +@@ -1216,7 +1608,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); +@@ -1235,8 +1627,9 @@ 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, *s, *retval = NULL; + gdb_byte *data = build_id->data; +@@ -1244,7 +1637,9 @@ build_id_to_debug_filename (struct build + + /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ + link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 +- + 2 * size + (sizeof ".debug" - 1) + 1); ++ + 2 * size ++ + (add_debug_suffix ? sizeof ".debug" - 1 : 0) ++ + 1); + s = link + sprintf (link, "%s/.build-id/", debug_file_directory); + if (size > 0) + { +@@ -1255,12 +1650,14 @@ build_id_to_debug_filename (struct build + *s++ = '/'; + while (size-- > 0) + s += sprintf (s, "%02x", (unsigned) *data++); +- strcpy (s, ".debug"); ++ if (add_debug_suffix) ++ strcpy (s, ".debug"); ++ else ++ *s = 0; + + /* lrealpath() is expensive even for the usually non-existent files. */ + if (access (link, F_OK) == 0) + retval = lrealpath (link); +- xfree (link); + + if (retval != NULL && !build_id_verify (retval, build_id)) + { +@@ -1268,9 +1665,150 @@ build_id_to_debug_filename (struct build + retval = NULL; + } + ++ if (link_return != NULL) ++ *link_return = link; ++ else ++ xfree (link); ++ + 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 * + get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out) + { +@@ -1353,32 +1891,36 @@ static char * + find_separate_debug_file (struct objfile *objfile) + { + asection *sect; +- char *basename; +- char *dir; +- char *debugfile; ++ char *basename = NULL; ++ char *dir = NULL; ++ char *debugfile = NULL; + char *name_copy; +- char *canon_name; ++ char *canon_name = NULL; + bfd_size_type debuglink_size; + unsigned long crc32; + int i; + struct build_id *build_id; ++ char *build_id_filename = NULL; + +- build_id = build_id_bfd_get (objfile->obfd); ++ 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, 1); + xfree (build_id); + /* Prevent looping on a stripped .debug file. */ + if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0) + { +- warning (_("\"%s\": separate debug info file has no debug info"), ++ warning (_("\"%s\": The separate debug info file has no debug info"), + build_id_name); + xfree (build_id_name); + } + else if (build_id_name != NULL) +- return build_id_name; ++ { ++ xfree (build_id_filename); ++ return build_id_name; ++ } + } + + basename = get_debug_link_info (objfile, &crc32); +@@ -1386,7 +1928,7 @@ find_separate_debug_file (struct objfile + if (basename == NULL) + /* There's no separate debug info, hence there's no way we could + load it => no warning. */ +- return NULL; ++ goto cleanup_return_debugfile; + + dir = xstrdup (objfile->name); + +@@ -1408,24 +1950,19 @@ find_separate_debug_file (struct objfile + if (canon_name && strlen (canon_name) > i) + i = strlen (canon_name); + +- debugfile = alloca (strlen (debug_file_directory) + 1 +- + i +- + strlen (DEBUG_SUBDIRECTORY) +- + strlen ("/") +- + strlen (basename) +- + 1); ++ debugfile = xmalloc (strlen (debug_file_directory) + 1 ++ + i ++ + strlen (DEBUG_SUBDIRECTORY) ++ + strlen ("/") ++ + strlen (basename) ++ + 1); + + /* First try in the same directory as the original file. */ + strcpy (debugfile, dir); + strcat (debugfile, basename); + + if (separate_debug_file_exists (debugfile, crc32, objfile->name)) +- { +- xfree (basename); +- xfree (dir); +- xfree (canon_name); +- return xstrdup (debugfile); +- } ++ goto cleanup_return_debugfile; + + /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ + strcpy (debugfile, dir); +@@ -1434,12 +1971,7 @@ find_separate_debug_file (struct objfile + strcat (debugfile, basename); + + if (separate_debug_file_exists (debugfile, crc32, objfile->name)) +- { +- xfree (basename); +- xfree (dir); +- xfree (canon_name); +- return xstrdup (debugfile); +- } ++ goto cleanup_return_debugfile; + + /* Then try in the global debugfile directory. */ + strcpy (debugfile, debug_file_directory); +@@ -1448,12 +1980,7 @@ find_separate_debug_file (struct objfile + strcat (debugfile, basename); + + if (separate_debug_file_exists (debugfile, crc32, objfile->name)) +- { +- xfree (basename); +- xfree (dir); +- xfree (canon_name); +- return xstrdup (debugfile); +- } ++ goto cleanup_return_debugfile; + + /* If the file is in the sysroot, try using its base path in the + global debugfile directory. */ +@@ -1467,20 +1994,18 @@ find_separate_debug_file (struct objfile + strcat (debugfile, basename); + + if (separate_debug_file_exists (debugfile, crc32, objfile->name)) +- { +- xfree (canon_name); +- xfree (basename); +- xfree (dir); +- return xstrdup (debugfile); +- } ++ goto cleanup_return_debugfile; + } + +- if (canon_name) +- xfree (canon_name); ++ debugfile = NULL; ++ debug_print_missing (objfile->name, build_id_filename); + ++cleanup_return_debugfile: ++ xfree (build_id_filename); ++ xfree (canon_name); + xfree (basename); + xfree (dir); +- return NULL; ++ return debugfile; + } + + +@@ -4231,4 +4756,16 @@ the global debug-file directory prepende + NULL, + show_debug_file_directory, + &setlist, &showlist); ++ ++ 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-6.8.50.20090909/gdb/symfile.h +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/symfile.h 2009-09-09 19:05:56.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/symfile.h 2009-09-09 19:09:35.000000000 +0200 +@@ -381,6 +381,13 @@ extern int symfile_map_offsets_to_segmen + struct symfile_segment_data *get_symfile_segment_data (bfd *abfd); + void free_symfile_segment_data (struct symfile_segment_data *data); + ++/* 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 */ + + extern int dwarf2_has_info (struct objfile *); +Index: gdb-6.8.50.20090909/gdb/testsuite/lib/gdb.exp +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/testsuite/lib/gdb.exp 2009-09-09 19:05:56.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/testsuite/lib/gdb.exp 2009-09-09 19:09:35.000000000 +0200 +@@ -1248,6 +1248,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-6.8.50.20090909/gdb/testsuite/lib/mi-support.exp +=================================================================== +--- gdb-6.8.50.20090909.orig/gdb/testsuite/lib/mi-support.exp 2009-09-09 19:05:56.000000000 +0200 ++++ gdb-6.8.50.20090909/gdb/testsuite/lib/mi-support.exp 2009-09-09 19:09:35.000000000 +0200 +@@ -221,6 +221,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 + --- gdb-7.0.1.orig/debian/patches/man-page-args.patch +++ gdb-7.0.1/debian/patches/man-page-args.patch @@ -0,0 +1,52 @@ +--- + gdb/gdb.1 | 27 ++++++++++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +Index: gdb-6.6.dfsg/gdb/gdb.1 +=================================================================== +--- gdb-6.6.dfsg.orig/gdb/gdb.1 2007-01-27 20:35:18.000000000 -0500 ++++ gdb-6.6.dfsg/gdb/gdb.1 2007-01-27 20:35:35.000000000 -0500 +@@ -39,10 +39,25 @@ gdb \- The GNU Debugger + .I dir\c + \&\|] + .RB "[\|" \c +-.I prog\c ++.I prog + .RB "[\|" \c + .IR core \||\| procID\c + \&\|]\&\|] ++.TP ++.B gdb ++.RB "[\|" \c ++.I options\c ++.RB "\|]" ++.RB "--args" ++.I prog ++.RB "[\|" \c ++.I arguments\c ++.RB "\|]" ++.TP ++.B gdbtui ++.RB "[\|" \c ++.I options\c ++.RB "\|]" + .ad b + .SH DESCRIPTION + The purpose of a debugger such as GDB is to allow you to see what is +@@ -352,6 +367,16 @@ interface used by GDB for remote debuggi + Run using \c + .I device\c + \& for your program's standard input and output. ++ ++.TP ++.BI "\-\-args"\c ++Pass \c ++.I arguments\c ++\& after the program name to the program when it is run. ++ ++.TP ++.BI "\-tui"\c ++Run GDB using a text (console) user interface. + .PP + + .SH "SEE ALSO" --- gdb-7.0.1.orig/debian/patches/pie-support-tests.patch +++ gdb-7.0.1/debian/patches/pie-support-tests.patch @@ -0,0 +1,2124 @@ +Description: forward-ported PIE tests. + +Index: gdb-6.8.50.20090628/gdb/testsuite/configure +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/testsuite/configure 2009-07-14 13:24:09.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/testsuite/configure 2009-07-14 13:24:22.000000000 -0700 +@@ -3131,7 +3131,7 @@ + + + +- ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/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.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.pie/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/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 + # tests run on this system so they can be shared between configure +@@ -3692,6 +3692,7 @@ + "gdb.dwarf2/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.dwarf2/Makefile" ;; + "gdb.fortran/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.fortran/Makefile" ;; + "gdb.server/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.server/Makefile" ;; ++ "gdb.pie/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;; + "gdb.java/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.java/Makefile" ;; + "gdb.mi/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.mi/Makefile" ;; + "gdb.modula2/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.modula2/Makefile" ;; +Index: gdb-6.8.50.20090628/gdb/testsuite/configure.ac +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/testsuite/configure.ac 2009-07-14 13:24:09.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/testsuite/configure.ac 2009-07-14 13:24:22.000000000 -0700 +@@ -114,7 +114,7 @@ + gdb.ada/Makefile \ + gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \ + gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \ +- gdb.fortran/Makefile gdb.server/Makefile \ ++ gdb.fortran/Makefile gdb.server/Makefile gdb.pie/Makefile \ + gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \ + gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \ + gdb.python/Makefile gdb.reverse/Makefile \ +Index: gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/Makefile.in +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/Makefile.in 2009-07-14 13:24:22.000000000 -0700 +@@ -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.* +Index: gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/attach.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/attach.c 2009-07-14 13:24:22.000000000 -0700 +@@ -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-6.8.50.20090628/gdb/testsuite/gdb.pie/attach.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/attach.exp 2009-07-14 14:12:09.000000000 -0700 +@@ -0,0 +1,432 @@ ++# 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. */ ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++if $tracelevel then { ++ strace $tracelevel ++ } ++ ++set prms_id 0 ++set bug_id 0 ++ ++# 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 "Temporary breakpoint .*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. ++ # ++ send_gdb "continue\n" ++ gdb_expect { ++ -re "Program exited normally.*$gdb_prompt $"\ ++ {pass "after attach2, exit"} ++ -re "$gdb_prompt $" {fail "after attach2, exit"} ++ timeout {fail "(timeout) 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.*libc.*$gdb_prompt $" { ++ 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" ".*Program 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-6.8.50.20090628/gdb/testsuite/gdb.pie/attach2.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/attach2.c 2009-07-14 13:24:22.000000000 -0700 +@@ -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-6.8.50.20090628/gdb/testsuite/gdb.pie/break.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/break.c 2009-07-14 13:24:22.000000000 -0700 +@@ -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-6.8.50.20090628/gdb/testsuite/gdb.pie/break.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/break.exp 2009-07-14 13:24:22.000000000 -0700 +@@ -0,0 +1,973 @@ ++# 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 ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++ ++# ++# test running programs ++# ++set prms_id 0 ++set bug_id 0 ++ ++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] ++ ++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" \ ++ "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" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function" ++ ++# ++# test break at function in file ++# ++ ++gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \ ++ "Temporary breakpoint function in file" ++ ++# ++# test break at line number ++# ++send_gdb "tbreak $bp_location1\n" ++gdb_expect { ++ -re "Breakpoint.*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" "Breakpoint.*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 "Breakpoint.*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" "Breakpoint.*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\nWhen the function .marker2$proto. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$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-6.8.50.20090628/gdb/testsuite/gdb.pie/break1.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/break1.c 2009-07-14 13:24:22.000000000 -0700 +@@ -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-6.8.50.20090628/gdb/testsuite/gdb.pie/corefile.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/corefile.exp 2009-07-14 13:24:22.000000000 -0700 +@@ -0,0 +1,243 @@ ++# 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. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Fred Fish. (fnf@cygnus.com) ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++# 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-6.8.50.20090628/gdb/testsuite/gdb.pie/coremaker.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-6.8.50.20090628/gdb/testsuite/gdb.pie/coremaker.c 2009-07-14 13:24:22.000000000 -0700 +@@ -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; ++} ++ --- gdb-7.0.1.orig/debian/patches/i386-assume-frame.patch +++ gdb-7.0.1/debian/patches/i386-assume-frame.patch @@ -0,0 +1,29 @@ +2009-07-06 Michael Matz + + * i386-tdep.c (i386_frame_cache): Assume anonymous functions use + a frame pointer. + +--- + gdb/i386-tdep.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +Index: gdb-7.0/gdb/i386-tdep.c +=================================================================== +--- gdb-7.0.orig/gdb/i386-tdep.c 2009-09-28 03:20:45.000000000 -0400 ++++ gdb-7.0/gdb/i386-tdep.c 2009-10-11 17:27:01.000000000 -0400 +@@ -1394,12 +1394,14 @@ i386_frame_cache (struct frame_info *thi + /* This will be added back below. */ + cache->saved_regs[I386_EIP_REGNUM] -= cache->base; + } +- else ++ else if (cache->pc) + { + get_frame_register (this_frame, I386_ESP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 4, byte_order) + + cache->sp_offset; + } ++ else ++ cache->saved_regs[I386_EBP_REGNUM] = 0; + } + + /* Now that we have the base address for the stack frame we can --- gdb-7.0.1.orig/debian/patches/gdb-6.5-bz203661-emit-relocs.patch +++ gdb-7.0.1/debian/patches/gdb-6.5-bz203661-emit-relocs.patch @@ -0,0 +1,17 @@ +Index: gdb-6.8.50.20090802/gdb/symfile.c +=================================================================== +--- gdb-6.8.50.20090802.orig/gdb/symfile.c 2009-08-03 12:29:58.000000000 +0200 ++++ gdb-6.8.50.20090802/gdb/symfile.c 2009-08-03 12:40:58.000000000 +0200 +@@ -4012,6 +4012,12 @@ symfile_dummy_outputs (bfd *abfd, asecti + bfd_byte * + symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte *buf) + { ++ /* 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) --- gdb-7.0.1.orig/debian/patches/pie-support.patch +++ gdb-7.0.1/debian/patches/pie-support.patch @@ -0,0 +1,1202 @@ +Description: Updated GDB PIE support for 6.8.50.20090628. Originally + based on the patch from Jan Kratochvil (with contributions from many others): + http://cvs.fedora.redhat.com/viewvc/devel/gdb/gdb-6.3-pie-20050110.patch?revision=HEAD&view=markup + +Index: gdb-6.8.50.20090628/gdb/amd64-tdep.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/amd64-tdep.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/amd64-tdep.c 2009-07-14 14:52:26.000000000 -0700 +@@ -36,6 +36,7 @@ + #include "regcache.h" + #include "regset.h" + #include "symfile.h" ++#include "exceptions.h" + + #include "gdb_assert.h" + +@@ -1586,16 +1587,28 @@ + Any function that doesn't start with this sequence will be assumed + to have no prologue and thus no valid frame pointer in %rbp. */ + +-static CORE_ADDR +-amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, +- struct amd64_frame_cache *cache) ++struct amd64_analyze_prologue_data ++ { ++ CORE_ADDR pc, current_pc; ++ struct amd64_frame_cache *cache; ++ CORE_ADDR retval; ++ }; ++ ++static int ++amd64_analyze_prologue_1 (void *data_pointer) + { ++ struct amd64_analyze_prologue_data *data = data_pointer; ++ CORE_ADDR pc = data->pc, current_pc = data->current_pc; ++ struct amd64_frame_cache *cache = data->cache; + static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */ + gdb_byte buf[3]; + gdb_byte op; + + if (current_pc <= pc) +- return current_pc; ++ { ++ data->retval = current_pc; ++ return 1; ++ } + + pc = amd64_analyze_stack_align (pc, current_pc, cache); + +@@ -1610,18 +1623,57 @@ + + /* If that's all, return now. */ + if (current_pc <= pc + 1) +- return current_pc; ++ { ++ data->retval = current_pc; ++ return 1; ++ } + + /* Check for `movq %rsp, %rbp'. */ + read_memory (pc + 1, buf, 3); + if (memcmp (buf, proto, 3) != 0) +- return pc + 1; ++ { ++ data->retval = pc + 1; ++ return 1; ++ } + + /* OK, we actually have a frame. */ + cache->frameless_p = 0; +- return pc + 4; ++ data->retval = pc + 4; ++ return 1; + } + ++ data->retval = pc; ++ return 1; ++} ++ ++/* Catch memory read errors and return just PC in such case. ++ It occurs very early on enable_break->new_symfile_objfile-> ++ ->breakpoint_re_set->decode_line_1->decode_variable_1-> ++ ->find_function_start_sal */ ++ ++static CORE_ADDR ++amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, ++ struct amd64_frame_cache *cache) ++{ ++ int status; ++ struct amd64_analyze_prologue_data data; ++ struct ui_file *saved_gdb_stderr; ++ ++ /* Suppress error messages. */ ++ saved_gdb_stderr = gdb_stderr; ++ gdb_stderr = ui_file_new (); ++ ++ data.pc = pc; ++ data.current_pc = current_pc; ++ data.cache = cache; ++ status = catch_errors (amd64_analyze_prologue_1, &data, "", RETURN_MASK_ALL); ++ ++ /* Stop suppressing error messages. */ ++ ui_file_delete (gdb_stderr); ++ gdb_stderr = saved_gdb_stderr; ++ ++ if (status) ++ return data.retval; + return pc; + } + +Index: gdb-6.8.50.20090628/gdb/auxv.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/auxv.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/auxv.c 2009-07-14 14:52:26.000000000 -0700 +@@ -78,7 +78,7 @@ + Return 1 if an entry was read into *TYPEP and *VALP. */ + static int + default_auxv_parse (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp) + { + const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch) + / TARGET_CHAR_BIT; +@@ -105,7 +105,7 @@ + Return 1 if an entry was read into *TYPEP and *VALP. */ + int + target_auxv_parse (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp) + { + struct target_ops *t; + for (t = ops; t != NULL; t = t->beneath) +@@ -120,9 +120,10 @@ + an error getting the information. On success, return 1 after + storing the entry's value field in *VALP. */ + int +-target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp) ++target_auxv_search (struct target_ops *ops, ULONGEST match, CORE_ADDR *valp) + { +- CORE_ADDR type, val; ++ CORE_ADDR val; ++ ULONGEST at_type; + gdb_byte *data; + LONGEST n = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, &data); + gdb_byte *ptr = data; +@@ -132,10 +133,10 @@ + return n; + + while (1) +- switch (target_auxv_parse (ops, &ptr, data + n, &type, &val)) ++ switch (target_auxv_parse (ops, &ptr, data + n, &at_type, &val)) + { + case 1: /* Here's an entry, check it. */ +- if (type == match) ++ if (at_type == match) + { + xfree (data); + *valp = val; +@@ -158,7 +159,8 @@ + int + fprint_target_auxv (struct ui_file *file, struct target_ops *ops) + { +- CORE_ADDR type, val; ++ CORE_ADDR val; ++ ULONGEST at_type; + gdb_byte *data; + LONGEST len = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, + &data); +@@ -168,13 +170,13 @@ + if (len <= 0) + return len; + +- while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0) ++ while (target_auxv_parse (ops, &ptr, data + len, &at_type, &val) > 0) + { + const char *name = "???"; + const char *description = ""; + enum { dec, hex, str } flavor = hex; + +- switch (type) ++ switch (at_type) + { + #define TAG(tag, text, kind) \ + case tag: name = #tag; description = text; flavor = kind; break +@@ -230,7 +232,7 @@ + } + + fprintf_filtered (file, "%-4s %-20s %-30s ", +- plongest (type), name, description); ++ plongest (at_type), name, description); + switch (flavor) + { + case dec: +@@ -252,7 +254,7 @@ + break; + } + ++ents; +- if (type == AT_NULL) ++ if (at_type == AT_NULL) + break; + } + +Index: gdb-6.8.50.20090628/gdb/auxv.h +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/auxv.h 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/auxv.h 2009-07-14 14:52:26.000000000 -0700 +@@ -31,14 +31,14 @@ + Return 1 if an entry was read into *TYPEP and *VALP. */ + extern int target_auxv_parse (struct target_ops *ops, + gdb_byte **readptr, gdb_byte *endptr, +- CORE_ADDR *typep, CORE_ADDR *valp); ++ ULONGEST *typep, CORE_ADDR *valp); + + /* Extract the auxiliary vector entry with a_type matching MATCH. + Return zero if no such entry was found, or -1 if there was + an error getting the information. On success, return 1 after + storing the entry's value field in *VALP. */ + extern int target_auxv_search (struct target_ops *ops, +- CORE_ADDR match, CORE_ADDR *valp); ++ ULONGEST match, CORE_ADDR *valp); + + /* Print the contents of the target's AUXV on the specified file. */ + extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); +Index: gdb-6.8.50.20090628/gdb/breakpoint.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/breakpoint.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/breakpoint.c 2009-07-14 15:15:31.000000000 -0700 +@@ -4094,6 +4094,7 @@ + printf_filtered (" (thread %d)", b->thread); + printf_filtered ("%s%s ", + ((b->enable_state == bp_disabled ++ || b->enable_state == bp_startup_disabled + || b->enable_state == bp_call_disabled) + ? " (disabled)" + : b->enable_state == bp_permanent +@@ -4871,6 +4872,62 @@ + return b; + } + ++void ++disable_breakpoints_at_startup (int silent) ++{ ++ struct breakpoint *b; ++ int disabled_startup_breaks = 0; ++ ++ if (bfd_get_start_address (exec_bfd) != entry_point_address ()) ++ { ++ ALL_BREAKPOINTS (b) ++ { ++ if (((b->type == bp_breakpoint) || ++ (b->type == bp_hardware_breakpoint)) && ++ b->enable_state == bp_enabled && ++ b->loc != NULL && !b->loc->duplicate) ++ { ++ b->enable_state = bp_startup_disabled; ++ if (!silent) ++ { ++ if (!disabled_startup_breaks) ++ { ++ target_terminal_ours_for_output (); ++ warning ("Temporarily disabling breakpoints:"); ++ } ++ disabled_startup_breaks = 1; ++ warning ("breakpoint #%d addr 0x%s", b->number, paddr_nz(b->loc->address)); ++ } ++ } ++ } ++ } ++} ++ ++/* Try to reenable any breakpoints after startup. */ ++void ++re_enable_breakpoints_at_startup (void) ++{ ++ struct breakpoint *b; ++ ++ //printf ("re_enable_breakpoints_at_startup, bfd 0x%s ep 0x%s\n", paddr_nz(bfd_get_start_address (exec_bfd)), paddr_nz(entry_point_address ())); ++ if (bfd_get_start_address (exec_bfd) != entry_point_address ()) ++ { ++ ALL_BREAKPOINTS (b) ++ if (b->enable_state == bp_startup_disabled) ++ { ++ char buf[1]; ++ ++ /* Do not reenable the breakpoint if the shared library ++ is still not mapped in. */ ++ if (target_read_memory (b->loc->address, buf, 1) == 0) ++ { ++ //printf ("enabling breakpoint at 0x%s\n", paddr_nz(b->loc->address)); ++ b->enable_state = bp_enabled; ++ } ++ } ++ } ++} ++ + static void + create_fork_vfork_event_catchpoint (int tempflag, char *cond_string, + struct breakpoint_ops *ops) +Index: gdb-6.8.50.20090628/gdb/breakpoint.h +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/breakpoint.h 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/breakpoint.h 2009-07-14 14:52:26.000000000 -0700 +@@ -135,6 +135,7 @@ + automatically enabled and reset when the call + "lands" (either completes, or stops at another + eventpoint). */ ++ bp_startup_disabled, + bp_permanent /* There is a breakpoint instruction hard-wired into + the target's code. Don't try to write another + breakpoint instruction on top of it, or restore +@@ -844,6 +845,10 @@ + + extern void disable_breakpoints_in_shlibs (void); + ++extern void disable_breakpoints_at_startup (int silent); ++ ++extern void re_enable_breakpoints_at_startup (void); ++ + /* This function returns TRUE if ep is a catchpoint. */ + extern int ep_is_catchpoint (struct breakpoint *); + +Index: gdb-6.8.50.20090628/gdb/dwarf2read.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/dwarf2read.c 2009-07-14 14:52:26.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/dwarf2read.c 2009-07-14 14:52:26.000000000 -0700 +@@ -1393,7 +1393,7 @@ + dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame); + dwarf2_read_section (objfile, &dwarf2_per_objfile->frame); + +- if (mainline ++ if ((mainline == 1) + || (objfile->global_psymbols.size == 0 + && objfile->static_psymbols.size == 0)) + { +Index: gdb-6.8.50.20090628/gdb/elfread.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/elfread.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/elfread.c 2009-07-14 14:52:26.000000000 -0700 +@@ -681,7 +681,7 @@ + /* If we are reinitializing, or if we have never loaded syms yet, + set table to empty. MAINLINE is cleared so that *_read_psymtab + functions do not all also re-initialize the psymbol table. */ +- if (mainline) ++ if (mainline == 1) + { + init_psymbol_list (objfile, 0); + mainline = 0; +Index: gdb-6.8.50.20090628/gdb/infrun.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/infrun.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/infrun.c 2009-07-14 14:52:26.000000000 -0700 +@@ -3508,6 +3508,11 @@ + #endif + target_terminal_inferior (); + ++ /* For PIE executables, we dont really know where the ++ breakpoints are going to be until we start up the ++ inferior. */ ++ re_enable_breakpoints_at_startup (); ++ + /* If requested, stop when the dynamic linker notifies + gdb of events. This allows the user to get control + and place breakpoints in initializer routines for +Index: gdb-6.8.50.20090628/gdb/objfiles.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/objfiles.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/objfiles.c 2009-07-14 14:52:26.000000000 -0700 +@@ -51,6 +51,9 @@ + #include "arch-utils.h" + #include "exec.h" + ++#include "auxv.h" ++#include "elf/common.h" ++ + /* Prototypes for local functions */ + + static void objfile_alloc_data (struct objfile *objfile); +@@ -271,7 +274,18 @@ + CORE_ADDR + entry_point_address (void) + { +- return symfile_objfile ? symfile_objfile->ei.entry_point : 0; ++ int ret; ++ CORE_ADDR entry_addr; ++ ++ /* Find the address of the entry point of the program from the ++ auxv vector. */ ++ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_addr); ++ if (ret == 1) ++ return entry_addr; ++ else ++ { ++ return symfile_objfile ? symfile_objfile->ei.entry_point : 0; ++ } + } + + /* Create the terminating entry of OBJFILE's minimal symbol table. +@@ -446,6 +460,9 @@ + if (objfile == rt_common_objfile) + rt_common_objfile = NULL; + ++ if (objfile == symfile_objfile) ++ symfile_objfile = NULL; ++ + /* Before the symbol table code was redone to make it easier to + selectively load and remove information particular to a specific + linkage unit, gdb used to do these things whenever the monolithic +Index: gdb-6.8.50.20090628/gdb/solib-svr4.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/solib-svr4.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/solib-svr4.c 2009-07-14 14:52:26.000000000 -0700 +@@ -47,6 +47,7 @@ + #include "exec.h" + #include "auxv.h" + #include "exceptions.h" ++#include "command.h" + + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); + static int svr4_have_link_map_offsets (void); +@@ -359,7 +360,9 @@ + + /* Local function prototypes */ + ++#if 0 + static int match_main (char *); ++#endif + + static CORE_ADDR bfd_lookup_symbol (bfd *, char *); + +@@ -593,10 +596,12 @@ + int arch_size, step, sect_size; + long dyn_tag; + CORE_ADDR dyn_ptr, dyn_addr; ++ CORE_ADDR reloc_addr = 0; + gdb_byte *bufend, *bufstart, *buf; + Elf32_External_Dyn *x_dynp_32; + Elf64_External_Dyn *x_dynp_64; + struct bfd_section *sect; ++ int ret; + + if (abfd == NULL) + return 0; +@@ -608,19 +613,81 @@ + if (arch_size == -1) + return 0; + ++ /* The auxv vector based relocatable files reading is limited to the main ++ executable. */ ++ gdb_assert (abfd == exec_bfd || ptr == NULL); ++ ++ if (ptr != NULL) ++ { ++ CORE_ADDR entry_addr; ++ ++ /* Find the address of the entry point of the program from the ++ auxv vector. */ ++ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_addr); ++ ++ if (ret == 0 || ret == -1) ++ { ++ /* No auxv info, maybe an older kernel. Fake our way through. */ ++ entry_addr = bfd_get_start_address (exec_bfd); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: program entry address not found. Using bfd's 0x%s for %s\n", ++ paddr_nz (entry_addr), exec_bfd->filename); ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: found program entry address 0x%s for %s\n", ++ paddr_nz (entry_addr), exec_bfd->filename); ++ } ++ reloc_addr = entry_addr - bfd_get_start_address (exec_bfd); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: expected relocation offset 0x%s for %s\n", ++ paddr_nz (reloc_addr), exec_bfd->filename); ++ } ++ + /* Find the start address of the .dynamic section. */ + sect = bfd_get_section_by_name (abfd, ".dynamic"); + if (sect == NULL) +- return 0; ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic section not found in %s -- return now\n", ++ exec_bfd->filename); ++ return 0; ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic section found in %s\n", ++ exec_bfd->filename); ++ } ++ + dyn_addr = bfd_section_vma (abfd, sect); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: .dynamic addr 0x%s\n", ++ paddr_nz (dyn_addr)); + + /* Read in .dynamic from the BFD. We will get the actual value + from memory later. */ + sect_size = bfd_section_size (abfd, sect); + buf = bufstart = alloca (sect_size); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: read in .dynamic section\n"); + if (!bfd_get_section_contents (abfd, sect, + buf, 0, sect_size)) +- return 0; ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: couldn't read .dynamic section -- return now\n"); ++ return 0; ++ } + + /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */ + step = (arch_size == 32) ? sizeof (Elf32_External_Dyn) +@@ -641,26 +708,105 @@ + dyn_tag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); + dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr); + } +- if (dyn_tag == DT_NULL) ++ ++ /* Verify RELOC_ADDR makes sense - it does not have to for valgrind which ++ supplies us a specially crafted executable in /proc/PID/fd/X while ++ /proc/PID/auxv corresponds to a different executable (.../memcheck). */ ++ if (reloc_addr) ++ { ++ gdb_byte tag_buf[8]; ++ CORE_ADDR tag_addr; ++ ++ tag_addr = dyn_addr + (buf - bufstart) + reloc_addr; ++ if (target_read_memory (tag_addr, tag_buf, arch_size / 8) == 0) ++ { ++ if (memcmp (tag_buf, buf, arch_size / 8) != 0) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: tag at offset 0x%lx does not match," ++ " dropping relocation offset %s\n", ++ (unsigned long) (buf - bufstart), paddr_nz (reloc_addr)); ++ reloc_addr = 0; ++ } ++ } ++ else ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: tag at offset 0x%lx is not readable," ++ " dropping relocation offset %s\n", ++ (unsigned long) (buf - bufstart), paddr_nz (reloc_addr)); ++ reloc_addr = 0; ++ } ++ } ++ ++ if (dyn_tag == DT_NULL) + return 0; +- if (dyn_tag == dyntag) +- { +- /* If requested, try to read the runtime value of this .dynamic +- entry. */ +- if (ptr) +- { +- struct type *ptr_type; +- gdb_byte ptr_buf[8]; +- CORE_ADDR ptr_addr; +- +- ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; +- ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8; +- if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0) +- dyn_ptr = extract_typed_address (ptr_buf, ptr_type); +- *ptr = dyn_ptr; +- } +- return 1; +- } ++ if (dyn_tag == dyntag) ++ { ++ /* If requested, try to read the runtime value of this .dynamic ++ entry. */ ++ if (ptr) ++ { ++ gdb_byte ptr_buf[8]; ++ CORE_ADDR ptr_addr; ++ int got; ++ ++ ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8; ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: unrelocated ptr addr 0x%s\n", ++ paddr_nz (ptr_addr)); ++ ptr_addr += reloc_addr; ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: relocated ptr addr 0x%s" ++ " (relocation offset %s) for %s\n", ++ paddr_nz (ptr_addr), paddr_nz (reloc_addr), ++ exec_bfd->filename); ++ } ++ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8); ++ if (got != 0 && reloc_addr) ++ { ++ ptr_addr -= reloc_addr; ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: unrelocated back to ptr addr 0x%s" ++ " as the memory was unreable for %s\n", ++ paddr_nz (ptr_addr), exec_bfd->filename); ++ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8); ++ } ++ ++ if (got == 0) ++ { ++ struct type *ptr_type; ++ ++ ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; ++ dyn_ptr = extract_typed_address (ptr_buf, ptr_type); ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: Tag entry has value 0x%s -- return now\n", ++ paddr_nz (dyn_ptr)); ++ } ++ } ++ else ++ { ++ if (ptr != NULL) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "elf_locate_base: Couldn't read tag entry value -- return now\n"); ++ } ++ } ++ *ptr = dyn_ptr; ++ } ++ return 1; ++ } + } + + return 0; +@@ -846,6 +992,10 @@ + struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); + struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "solib_svr4_r_map: read at 0x%s\n", ++ paddr_nz (info->debug_base + lmo->r_map_offset)); + return read_memory_typed_address (info->debug_base + lmo->r_map_offset, + ptr_type); + } +@@ -1027,10 +1177,15 @@ + CORE_ADDR ldsomap = 0; + struct inferior *inf; + struct svr4_info *info; ++ const char *filename = exec_bfd ? exec_bfd->filename : ""; + + if (ptid_equal (inferior_ptid, null_ptid)) + return NULL; + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: exec_bfd %s\n", filename); ++ + inf = current_inferior (); + info = get_svr4_info (inf->pid); + +@@ -1041,10 +1196,19 @@ + /* If we can't find the dynamic linker's base structure, this + must not be a dynamically linked executable. Hmm. */ + if (! info->debug_base) +- return svr4_default_sos (); ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: no DT_DEBUG found in %s -- return now\n", ++ filename); ++ return svr4_default_sos (); ++ } + + /* Walk the inferior's link map list, and build our list of + `struct so_list' nodes. */ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: walk link map in %s\n", filename); + lm = solib_svr4_r_map (info); + + while (lm) +@@ -1061,26 +1225,104 @@ + new->lm_info->lm = xzalloc (lmo->link_map_size); + make_cleanup (xfree, new->lm_info->lm); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: read lm at 0x%s\n", ++ paddr_nz(lm)); + read_memory (lm, new->lm_info->lm, lmo->link_map_size); + + lm = LM_NEXT (new); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: is first link entry? %d\n", ++ IGNORE_FIRST_LINK_MAP_ENTRY (new)); ++ + /* For SVR4 versions, the first entry in the link map is for the + inferior executable, so we must ignore it. For some versions of + SVR4, it has no name. For others (Solaris 2.3 for example), it + does have a name, so we can no longer use a missing name to + decide when to ignore it. */ +- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) ++ if (exec_bfd != NULL && IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0) + { +- info->main_lm_addr = new->lm_info->lm_addr; +- free_so (new); +- } ++ /* It is the first link map entry, i.e. it is the main executable. */ ++ ++ if (bfd_get_start_address (exec_bfd) == entry_point_address ()) ++ { ++ /* Non-pie case, main executable has not been relocated. */ ++ info->main_lm_addr = new->lm_info->lm_addr; ++ free_so (new); ++ } ++ else ++ { ++ /* Pie case, main executable has been relocated. */ ++ struct so_list *gdb_solib; ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: Processing first link map entry\n"); ++ strncpy (new->so_name, exec_bfd->filename, ++ SO_NAME_MAX_PATH_SIZE - 1); ++ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ strcpy (new->so_original_name, new->so_name); ++ /*new->main = 1;*/ ++ new->main_relocated = 0; ++ ++ if (debug_solib) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: Processing nameless DSO\n"); ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: adding name %s\n", ++ new->so_name); ++ } ++ ++ for (gdb_solib = master_so_list (); ++ gdb_solib; ++ gdb_solib = gdb_solib->next) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: compare gdb %s and new %s\n", ++ gdb_solib->so_name, new->so_name); ++ if (strcmp (gdb_solib->so_name, new->so_name) == 0) ++ if (gdb_solib->main_relocated) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: found main relocated\n"); ++ break; ++ } ++ } ++ ++ if ((gdb_solib && !gdb_solib->main_relocated) || (!gdb_solib)) ++ { ++ if (!new->main) add_target_sections(new->sections, new->sections_end); ++ new->main = 1; ++ } ++ ++ /* We need this in the list of shared libs we return because ++ solib_add_stub will loop through it and add the symbol file. */ ++ new->next = 0; ++ *link_ptr = new; ++ link_ptr = &new->next; ++ } ++ } /* End of IGNORE_FIRST_LINK_MAP_ENTRY */ + else + { ++ /* This is not the first link map entry, i.e. is not the main ++ executable. Note however that it could be the DSO supplied on ++ certain systems (i.e. Linux 2.6) containing information about ++ the vsyscall page. We must ignore such entry. This entry is ++ nameless (just like the one for the main executable, sigh). */ ++ + int errcode; + char *buffer; + + /* Extract this shared object's name. */ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_current_sos: read LM_NAME\n"); + target_read_string (LM_NAME (new), &buffer, + SO_NAME_MAX_PATH_SIZE - 1, &errcode); + if (errcode != 0) +@@ -1096,8 +1338,7 @@ + + /* If this entry has no name, or its name matches the name + for the main executable, don't include it in the list. */ +- if (! new->so_name[0] +- || match_main (new->so_name)) ++ if (! new->so_name[0]) + free_so (new); + else + { +@@ -1120,6 +1361,9 @@ + if (head == NULL) + return svr4_default_sos (); + ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, "svr4_current_sos: ENDS %s\n", filename); ++ + return head; + } + +@@ -1152,7 +1396,7 @@ + /* On some systems, the only way to recognize the link map entry for + the main executable file is by looking at its name. Return + non-zero iff SONAME matches one of the known main executable names. */ +- ++#if 0 + static int + match_main (char *soname) + { +@@ -1166,6 +1410,7 @@ + + return (0); + } ++#endif + + /* Return 1 if PC lies in the dynamic symbol resolution code of the + SVR4 run time loader. */ +@@ -1317,15 +1562,29 @@ + /* Find the program interpreter; if not found, warn the user and drop + into the old breakpoint at symbol code. */ + interp_name = find_program_interpreter (); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "enable_break: search for .interp in %s\n", ++ exec_bfd->filename); + if (interp_name) + { + CORE_ADDR load_addr = 0; ++ CORE_ADDR load_addr_mask = -1L; + int load_addr_found = 0; + int loader_found_in_list = 0; + struct so_list *so; + bfd *tmp_bfd = NULL; + struct target_ops *tmp_bfd_target; + volatile struct gdb_exception ex; ++ int arch_size; ++ ++ /* For 32bit inferiors with 64bit GDB we may get LOAD_ADDR at 0xff...... ++ and thus overflowing its addition to the address while CORE_ADDR is ++ 64bit producing 0x1........ address invalid across GDB. */ ++ arch_size = bfd_get_arch_size (exec_bfd); ++ if (arch_size > 0 && arch_size < sizeof (1UL) * 8) ++ load_addr_mask = (1UL << arch_size) - 1; + + sym_addr = 0; + +@@ -1342,6 +1601,9 @@ + { + tmp_bfd = solib_bfd_open (interp_name); + } ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "enable_break: opening %s\n", interp_name); + if (tmp_bfd == NULL) + goto bkpt_at_symbol; + +@@ -1398,16 +1660,16 @@ + interp_sect = bfd_get_section_by_name (tmp_bfd, ".text"); + if (interp_sect) + { +- interp_text_sect_low = +- bfd_section_vma (tmp_bfd, interp_sect) + load_addr; ++ interp_text_sect_low = (bfd_section_vma (tmp_bfd, interp_sect) ++ + load_addr) & load_addr_mask; + interp_text_sect_high = + interp_text_sect_low + bfd_section_size (tmp_bfd, interp_sect); + } + interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt"); + if (interp_sect) + { +- interp_plt_sect_low = +- bfd_section_vma (tmp_bfd, interp_sect) + load_addr; ++ interp_plt_sect_low = (bfd_section_vma (tmp_bfd, interp_sect) ++ + load_addr) & load_addr_mask; + interp_plt_sect_high = + interp_plt_sect_low + bfd_section_size (tmp_bfd, interp_sect); + } +@@ -1434,7 +1696,11 @@ + + if (sym_addr != 0) + { +- create_solib_event_breakpoint (load_addr + sym_addr); ++ create_solib_event_breakpoint ((load_addr + sym_addr) ++ & load_addr_mask); ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "enable_break: solib bp set\n"); + xfree (interp_name); + return 1; + } +@@ -1704,6 +1970,8 @@ + while (tp->stop_signal != TARGET_SIGNAL_TRAP); + inf->stop_soon = NO_STOP_QUIETLY; + #endif /* defined(_SCO_DS) */ ++ ++ disable_breakpoints_at_startup (1); + } + + static void +@@ -1880,6 +2148,74 @@ + + return lmp; + } ++void ++info_linkmap_command (char *cmd, int from_tty) ++{ ++ CORE_ADDR lm; ++ struct svr4_info *info = get_svr4_info (PIDGET (inferior_ptid)); ++ ++ /* Make sure we've looked up the inferior's dynamic linker's base ++ structure. */ ++ if (! info->debug_base) ++ { ++ /* If we can't find the dynamic linker's base structure, this ++ must not be a dynamically linked executable. Hmm. */ ++ if (! locate_base (info)) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_print_linkmap: no DT_DEBUG found in %s -- return now\n", ++ exec_bfd->filename); ++ return; ++ } ++ } ++ ++ /* Walk the inferior's link map list, and print the info. */ ++ ++ lm = solib_svr4_r_map (info); ++ while (lm) ++ { ++ int errcode; ++ char *buffer; ++ CORE_ADDR load_addr; ++ ++ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); ++ struct so_list *new ++ = (struct so_list *) xmalloc (sizeof (struct so_list)); ++ struct cleanup *old_chain = make_cleanup (xfree, new); ++ ++ memset (new, 0, sizeof (*new)); ++ ++ new->lm_info = xmalloc (sizeof (struct lm_info)); ++ make_cleanup (xfree, new->lm_info); ++ ++ new->lm_info->lm = xmalloc (lmo->link_map_size); ++ make_cleanup (xfree, new->lm_info->lm); ++ memset (new->lm_info->lm, 0, lmo->link_map_size); ++ ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "svr4_print_linkmap: read lm at 0x%s\n", paddr_nz(lm)); ++ read_memory (lm, new->lm_info->lm, lmo->link_map_size); ++ ++ lm = LM_NEXT (new); ++ ++ /* Load address. */ ++ load_addr = LM_ADDR_CHECK (new, NULL); ++ /* Shared object's name. */ ++ target_read_string (LM_NAME (new), &buffer, ++ SO_NAME_MAX_PATH_SIZE - 1, &errcode); ++ make_cleanup (xfree, buffer); ++ if (errcode != 0) ++ { ++ warning ("svr4_print_linkmap: Can't read pathname for load map: %s\n", ++ safe_strerror (errcode)); ++ } ++ fprintf_filtered (gdb_stdout, "%-8s %-30s\n", paddr(load_addr), buffer); ++ do_cleanups (old_chain); ++ } ++} ++ + + + struct target_so_ops svr4_so_ops; +@@ -1920,5 +2256,8 @@ + svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; + svr4_so_ops.same = svr4_same; + ++ add_info ("linkmap", info_linkmap_command, ++ "Display the inferior's linkmap."); ++ + observer_attach_inferior_exit (solib_svr4_inferior_exit); + } +Index: gdb-6.8.50.20090628/gdb/solib.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/solib.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/solib.c 2009-07-14 14:52:26.000000000 -0700 +@@ -81,6 +81,8 @@ + + /* external data declarations */ + ++int debug_solib; ++ + /* FIXME: gdbarch needs to control this variable, or else every + configuration needs to call set_solib_ops. */ + struct target_so_ops *current_target_so_ops; +@@ -426,10 +428,23 @@ + + if (so->abfd) + { +- bfd_filename = bfd_get_filename (so->abfd); +- if (! bfd_close (so->abfd)) +- warning (_("cannot close \"%s\": %s"), +- bfd_filename, bfd_errmsg (bfd_get_error ())); ++ struct objfile *objfile; ++ ++ ALL_OBJFILES (objfile) ++ if (objfile->obfd == so->abfd) ++ { ++ gdb_assert (objfile->flags & OBJF_KEEPBFD); ++ objfile->flags &= ~OBJF_KEEPBFD; ++ break; ++ } ++ ++ if (!objfile) ++ { ++ bfd_filename = bfd_get_filename (so->abfd); ++ if (! bfd_close (so->abfd)) ++ warning (_("cannot close \"%s\": %s"), ++ bfd_filename, bfd_errmsg (bfd_get_error ())); ++ } + } + + if (bfd_filename) +@@ -456,15 +471,40 @@ + /* Have we already loaded this shared object? */ + ALL_OBJFILES (so->objfile) + { +- if (strcmp (so->objfile->name, so->so_name) == 0) ++ /* Found an already loaded shared library. */ ++ if (strcmp (so->objfile->name, so->so_name) == 0 && !so->main) ++ return; ++ /* Found an already loaded main executable. This could happen in ++ two circumstances. ++ First case: the main file has already been read in ++ as the first thing that gdb does at startup, and the file ++ hasn't been relocated properly yet. Therefor we need to read ++ it in with the proper section info. ++ Second case: it has been read in with the correct relocation, ++ and therefore we need to skip it. */ ++ if (strcmp (so->objfile->name, so->so_name) == 0 ++ && so->main ++ && so->main_relocated) + return; + } + + sap = build_section_addr_info_from_section_table (so->sections, + so->sections_end); + +- so->objfile = symbol_file_add_from_bfd (so->abfd, flags, +- sap, OBJF_SHARED | OBJF_KEEPBFD); ++ if (so->main) ++ { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "symbol_add_stub: adding symbols for main\n"); ++ so->objfile = symbol_file_add_from_bfd (so->abfd, ++ flags & ~SYMFILE_VERBOSE, ++ sap, OBJF_KEEPBFD); ++ so->main_relocated = 1; ++ } ++ else ++ so->objfile = symbol_file_add_from_bfd (so->abfd, flags, ++ sap, OBJF_SHARED | OBJF_KEEPBFD); ++ + free_section_addr_info (sap); + + return; +@@ -604,6 +644,10 @@ + } + else + { ++ if (debug_solib) ++ fprintf_unfiltered (gdb_stdlog, ++ "update_solib_list: compare gdb:%s and inferior:%s\n", ++ gdb->so_original_name, i->so_original_name); + if (! strcmp (gdb->so_original_name, i->so_original_name)) + break; + } +@@ -779,7 +823,6 @@ + } + } + +- + /* + + LOCAL FUNCTION +@@ -1133,4 +1176,12 @@ + reload_shared_libraries, + show_solib_search_path, + &setlist, &showlist); ++ ++ add_setshow_boolean_cmd ("solib", no_class, &debug_solib, ++ _("\ ++Set debugging of GNU/Linux shlib module.\n"), _("\ ++Show debugging status of GNU/Linux shlib module.\n"), _("\ ++Enables printf debugging output of GNU/Linux shlib module.\n"), ++ NULL, NULL, ++ &setdebuglist, &showdebuglist); + } +Index: gdb-6.8.50.20090628/gdb/solist.h +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/solist.h 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/solist.h 2009-07-14 14:52:26.000000000 -0700 +@@ -61,6 +61,8 @@ + bfd *abfd; + char symbols_loaded; /* flag: symbols read in yet? */ + char from_tty; /* flag: print msgs? */ ++ char main; /* flag: is this the main executable? */ ++ char main_relocated; /* flag: has it been relocated yet? */ + struct objfile *objfile; /* objfile for loaded lib */ + struct target_section *sections; + struct target_section *sections_end; +@@ -149,4 +151,7 @@ + const char *linkage_name, + const domain_enum domain); + ++/* Controls the printing of debugging output. */ ++extern int debug_solib; ++ + #endif +Index: gdb-6.8.50.20090628/gdb/symfile.c +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/symfile.c 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/symfile.c 2009-07-14 14:52:26.000000000 -0700 +@@ -48,6 +48,7 @@ + #include "readline/readline.h" + #include "gdb_assert.h" + #include "block.h" ++#include "varobj.h" + #include "observer.h" + #include "exec.h" + #include "parser-defs.h" +@@ -780,7 +781,7 @@ + + /* Now either addrs or offsets is non-zero. */ + +- if (mainline) ++ if (mainline == 1) + { + /* We will modify the main symbol table, make sure that all its users + will be cleaned up if an error occurs during symbol reading. */ +@@ -808,7 +809,7 @@ + + We no longer warn if the lowest section is not a text segment (as + happens for the PA64 port. */ +- if (!mainline && addrs && addrs->other[0].name) ++ if (/*!mainline &&*/ addrs && addrs->other[0].name) + { + asection *lower_sect; + asection *sect; +@@ -2436,6 +2437,8 @@ + /* Discard cleanups as symbol reading was successful. */ + discard_cleanups (old_cleanups); + ++ init_entry_point_info (objfile); ++ + /* If the mtime has changed between the time we set new_modtime + and now, we *want* this to be out of date, so don't call stat + again now. */ +Index: gdb-6.8.50.20090628/gdb/target.h +=================================================================== +--- gdb-6.8.50.20090628.orig/gdb/target.h 2009-07-14 14:52:22.000000000 -0700 ++++ gdb-6.8.50.20090628/gdb/target.h 2009-07-14 14:52:26.000000000 -0700 +@@ -522,7 +522,7 @@ + Return -1 if there is insufficient buffer for a whole entry. + Return 1 if an entry was read into *TYPEP and *VALP. */ + int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr, +- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); ++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp); + + /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the + sequence of bytes in PATTERN with length PATTERN_LEN. --- gdb-7.0.1.orig/debian/patches/gdb-strings.patch +++ gdb-7.0.1/debian/patches/gdb-strings.patch @@ -0,0 +1,12 @@ +diff -Nur gdb-6.4.90.dfsg.orig/gdb/remote.c gdb-6.4.90.dfsg/gdb/remote.c +--- gdb-6.4.90.dfsg.orig/gdb/remote.c 2006-05-05 21:08:45.000000000 +0100 ++++ gdb-6.4.90.dfsg/gdb/remote.c 2006-09-30 16:43:32.000000000 +0100 +@@ -4795,7 +4795,7 @@ + do_cleanups (old_chain); + } + if (mismatched > 0) +- warning (_("One or more sections of the remote executable does not match\n\ ++ warning (_("One or more sections of the remote executable do not match\n\ + the loaded file\n")); + if (args && !matched) + printf_filtered (_("No loaded section named '%s'.\n"), args);