Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 124978 - GDB: -data-disassemble wrong answer due to relative paths patch
Summary: GDB: -data-disassemble wrong answer due to relative paths patch
Status: RESOLVED DUPLICATE of bug 122050
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: AMD64 Linux
: High normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-04 10:14 UTC by Carlos Eduardo Rodrigues de Almeida
Modified: 2006-03-05 10:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Eduardo Rodrigues de Almeida 2006-03-04 10:14:27 UTC
emerge --info:

AMD3800X2Linux eduardo # emerge --info
Portage 2.0.54 (default-linux/amd64/2005.1, gcc-3.4.4, glibc-2.3.5-r2, 2.6.15-gentoo-r4 x86_64)
=================================================================
System uname: 2.6.15-gentoo-r4 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
Gentoo Base System version 1.6.14
dev-lang/python:     2.3.5, 2.4.2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.20
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -pipe -O2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib64/mozilla/defaults/pref /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=k8 -pipe -O2"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://www.las.ic.unicamp.br/pub/gentoo/"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.samerica.gentoo.org/gentoo-portage"
USE="amd64 X alsa audiofile avi berkdb bitmap-fonts bzip2 crypt cups dts eds emboss encode esd exif expat fam ffmpeg flac foomaticdb fortran gdbm gif glut gnome gpm gstreamer gtk gtk2 gtkhtml hal howl imlib ipv6 java jpeg lcms lirc lzw lzw-tiff mad matroska mng mozilla mp3 mpeg ncurses nls nvidia ogg opengl pam pdflib perl png python quicktime readline sdl spell ssl tcpd tiff truetype truetype-fonts type1-fonts udev usb userlocales vorbis xml2 xmms xpm xv zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS


GDB was installed with 'emerge gdb'

This problem happens with the GDB installed with the emerge:

[eduardo@~]$gdb -i=mi2
~"GNU gdb 6.4\n"
~"Copyright 2005 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB. Type \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-pc-linux-gnu\"."
~"\n"
(gdb)
file ~/lab3/Debug/lab3
&"file ~/lab3/Debug/lab3\n"
~"Reading symbols from /home/eduardo/lab3/Debug/lab3..."
~"done.\n"
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
^done
(gdb)
-data-disassemble -f /home/eduardo/libgip/src/gip_app.cpp -l 68 -- 1
&"mi_cmd_disassemble: Invalid line number\n"
^error,msg="mi_cmd_disassemble: Invalid line number"
(gdb)

The filename is correct and the line number too(as can be seen below) but the answer from -data-disasseble is "Invalid line number"

Downloading the current version from GDB web site(http://ftp.gnu.org/gnu/gdb/gdb-6.4.tar.bz2) and compiled with
./configure
make -j3

This is the answer:
[eduardo@~/Downloads/gdb-6.4/gdb]$./gdb -i=mi2
~"GNU gdb 6.4\n"
~"Copyright 2005 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB. Type \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-unknown-linux-gnu\"."
~"\n"
(gdb)
file ~/lab3/Debug/lab3
&"file ~/lab3/Debug/lab3\n"
~"Reading symbols from /home/eduardo/lab3/Debug/lab3..."
~"done.\n"
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
^done
(gdb)
-data-disassemble -f /home/eduardo/libgip/src/gip_app.cpp -l 68 -- 1
^done,asm_insns=[src_and_asm_line={line="66",file="./src/gip_app.cpp",line_asm_insn=[{address="0x000000000040d7e0",func-name="_Z12gip_app_initPc",offset="0",inst="mov %rbx,0xfffffffffffffff0(%rsp)"},{address="0x000000000040d7e5",func-name="_Z12gip_app_initPc",offset="5",inst="mov %rbp,0xfffffffffffffff8(%rsp)"},{address="0x000000000040d7ea",func-name="_Z12gip_app_initPc",offset="10",inst="sub $0x18,%rsp"},{address="0x000000000040d7ee",func-name="_Z12gip_app_initPc",offset="14",inst="mov %rdi,%rbp"}]},src_and_asm_line={line="67",file="./src/gip_app.cpp",line_asm_insn=[]},src_and_asm_line={line="68",file="./src/gip_app.cpp",line_asm_insn=[{address="0x000000000040d7f1",func-name="_Z12gip_app_initPc",offset="17",inst="mov $0x98,%edi"},{address="0x000000000040d7f6",func-name="_Z12gip_app_initPc",offset="22",inst="callq 0x4096a8 <_Znwm@plt>"},{address="0x000000000040d7fb",func-name="_Z12gip_app_initPc",offset="27",inst="mov $0x4,%esi"},{address="0x000000000040d800",func-name="_Z12gip_app_initPc",offset="32",inst="mov %rax,%rbx"},{address="0x000000000040d803",func-name="_Z12gip_app_initPc",offset="35",inst="mov %rax,%rdi"},{address="0x000000000040d806",func-name="_Z12gip_app_initPc",offset="38",inst="callq 0x409a88 <_ZN10wxBoxSizerC1Ei@plt>"},{address="0x000000000040d810",func-name="_Z12gip_app_initPc",offset="48",inst="mov %rbx,1158881(%rip) # 0x5286f8 <sizerRow2>"}]},src_and_asm_line={line="69",file="./src/gip_app.cpp",line_asm_insn=[{address="0x000000000040d80b",func-name="_Z12gip_app_initPc",offset="43",inst="mov $0x98,%edi"},{address="0x000000000040d817",func-name="_Z12gip_app_initPc",offset="55",inst="callq 0x4096a8 <_Znwm@plt>"},{address="0x000000000040d81c",func-name="_Z12gip_app_initPc",offset="60",inst="mov $0x4,%esi"},{address="0x000000000040d821",func-name="_Z12gip_app_initPc",offset="65",inst="mov %rax,%rbx"},{address="0x000000000040d824",func-name="_Z12gip_app_initPc",offset="68",inst="mov %rax,%rdi"},{address="0x000000000040d827",func-name="_Z12gip_app_initPc",offset="71",inst="callq 0x409a88 <_ZN10wxBoxSizerC1Ei@plt>"},{address="0x000000000040d82c",func-name="_Z12gip_app_initPc",offset="76",inst="mov %rbp,%rsi"},{address="0x000000000040d82f",func-name="_Z12gip_app_initPc",offset="79",inst="mov $0x5286c8,%edi"},{address="0x000000000040d834",func-name="_Z12gip_app_initPc",offset="84",inst="mov %rbx,1158805(%rip) # 0x5286d0 <sizerCanvas>"},{address="0x000000000040d83b",func-name="_Z12gip_app_initPc",offset="91",inst="callq 0x409d28 <_ZN12wxStringBaseaSEPKc@plt>"}]},src_and_asm_line={line="70",file="./src/gip_app.cpp",line_asm_insn=[]},src_and_asm_line={line="71",file="./src/gip_app.cpp",line_asm_insn=[]},src_and_asm_line={line="72",file="./src/gip_app.cpp",line_asm_insn=[{address="0x000000000040d840",func-name="_Z12gip_app_initPc",offset="96",inst="xor %esi,%esi"},{address="0x000000000040d842",func-name="_Z12gip_app_initPc",offset="98",inst="xor %edi,%edi"},{address="0x000000000040d844",func-name="_Z12gip_app_initPc",offset="100",inst="callq 0x40a3b8 <_Z12wxInitializeiPPc@plt>"}]},src_and_asm_line={line="73",file="./src/gip_app.cpp",line_asm_insn=[{address="0x000000000040d849",func-name="_Z12gip_app_initPc",offset="105",inst="mov $0x320,%edi"},{address="0x000000000040d84e",func-name="_Z12gip_app_initPc",offset="110",inst="callq 0x4096a8 <_Znwm@plt>"},{address="0x000000000040d853",func-name="_Z12gip_app_initPc",offset="115",inst="mov %rax,%rbx"},{address="0x000000000040d856",func-name="_Z12gip_app_initPc",offset="118",inst="mov %rax,%rdi"},{address="0x000000000040d859",func-name="_Z12gip_app_initPc",offset="121",inst="callq 0x40d6d0 <GipFrame>"},{address="0x000000000040d85e",func-name="_Z12gip_app_initPc",offset="126",inst="mov %rbx,1158883(%rip) # 0x528748 <frame>"},{address="0x000000000040d865",func-name="_Z12gip_app_initPc",offset="133",inst="mov 0x10(%rsp),%rbp"},{address="0x000000000040d86a",func-name="_Z12gip_app_initPc",offset="138",inst="mov 0x8(%rsp),%rbx"},{address="0x000000000040d86f",func-name="_Z12gip_app_initPc",offset="143",inst="add $0x18,%rsp"},{address="0x000000000040d873",func-name="_Z12gip_app_initPc",offset="147",inst="retq "},{address="0x000000000040d874",func-name="_Z12gip_app_initPc",offset="148",inst="mov %rax,%rbp"},{address="0x000000000040d877",func-name="_Z12gip_app_initPc",offset="151",inst="mov %rbx,%rdi"},{address="0x000000000040d87a",func-name="_Z12gip_app_initPc",offset="154",inst="callq 0x40a498 <_ZdlPv@plt>"},{address="0x000000000040d87f",func-name="_Z12gip_app_initPc",offset="159",inst="mov %rbp,%rdi"},{address="0x000000000040d882",func-name="_Z12gip_app_initPc",offset="162",inst="callq 0x40a348 <_Unwind_Resume@plt>"},{address="0x000000000040d887",func-name="_Z12gip_app_initPc",offset="167",inst="jmp 0x40d874 <_Z12gip_app_initPc+148>"},{address="0x000000000040d889",func-name="_Z12gip_app_initPc",offset="169",inst="nop "},{address="0x000000000040d88a",func-name="_Z12gip_app_initPc",offset="170",inst="data16"},{address="0x000000000040d88b",func-name="_Z12gip_app_initPc",offset="171",inst="data16"},{address="0x000000000040d88c",func-name="_Z12gip_app_initPc",offset="172",inst="nop "},{address="0x000000000040d88d",func-name="_Z12gip_app_initPc",offset="173",inst="data16"},{address="0x000000000040d88e",func-name="_Z12gip_app_initPc",offset="174",inst="data16"},{address="0x000000000040d88f",func-name="_Z12gip_app_initPc",offset="175",inst="nop "}]}]
(gdb)

The same commands but now it disasseble the files correctly.


Another strange thing is this:

With the system GDB:

[eduardo@~/lab3/Debug]$gdb -i=mi2
~"GNU gdb 6.4\n"
~"Copyright 2005 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and
you are\n"
~"welcome to change it and/or distribute copies of it under certain
conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for
details.\n"
~"This GDB was configured as \"x86_64-pc-linux-gnu\"."
~"\n"
(gdb)
-file-exec-and-symbols lab3
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
^done
(gdb)
-data-disassemble -f /home/eduardo/libgip/src/gip_app.cpp -l 68 -n 1 -- 1
&"mi_cmd_disassemble: Invalid line number\n"
^error,msg="mi_cmd_disassemble: Invalid line number"
(gdb)
-data-disassemble -f gip_app.cpp -l 68 -n 1 -- 1
^done,asm_insns=[{address="0x000000000040d7e0",func-name="_Z12gip_app_initPc",offset="0",inst="mov
  %rbx,0xfffffffffffffff0(%rsp)"}]
(gdb)

With just the filename(gip_app.cpp) the answer is almost right. It should give me mixed source code and disassembly(-- 1 in the end) but it gives me only disassembled 

I copied the gdb-6.4.ebuild to an overlay and removed the "gdb-6.4-relative-paths.patch" and reemerged GDB. Without this patch it works.

Here is the ebuild that does not work:
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-devel/gdb/gdb-6.4.ebuild,v 1.4 2006/02/19 23:15:31 kumba Exp $

inherit flag-o-matic eutils

export CTARGET=${CTARGET:-${CHOST}}
if [[ ${CTARGET} == ${CHOST} ]] ; then
	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
		export CTARGET=${CATEGORY/cross-}
	fi
fi

#DEB_VER=6
DESCRIPTION="GNU debugger"
HOMEPAGE="http://sources.redhat.com/gdb/"
SRC_URI="http://ftp.gnu.org/gnu/gdb/${P}.tar.bz2
	ftp://sources.redhat.com/pub/gdb/releases/${P}.tar.bz2
	mirror://gentoo/gdb_init.txt.bz2"

LICENSE="GPL-2 LGPL-2"
[[ ${CTARGET} != ${CHOST} ]] \
	&& SLOT="${CTARGET}" \
	|| SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 mips ppc ppc64 s390 sparc x86"
IUSE="nls test vanilla"

RDEPEND=">=sys-libs/ncurses-5.2-r2"
DEPEND="${RDEPEND}
	test? ( dev-util/dejagnu )
	nls? ( sys-devel/gettext )"

src_unpack() {
	unpack ${A}
	cd "${S}"
	mv "${WORKDIR}"/gdb_init.txt . || die

	if ! use vanilla ; then
		if [[ -n ${DEB_VER} ]] ; then
			epatch "${WORKDIR}"/gdb_${PV}-${DEB_VER}.diff
			for f in $(<debian/patches/series) ; do
				EPATCH_SINGLE_MSG="Applying Debian's ${f}" \
				epatch debian/patches/${f}
			done
		fi
		epatch "${FILESDIR}"/gdb-6.4-uclibc.patch
		epatch "${FILESDIR}"/gdb-6.4-relative-paths.patch
		#epatch "${FILESDIR}"/gdb-6.x-crash.patch
		epatch "${FILESDIR}"/gdb-6.2.1-pass-libdir.patch
		epatch "${FILESDIR}"/gdb-6.4-scanmem.patch
		epatch "${FILESDIR}"/gdb-6.3-gdbinit-stat.patch
		epatch "${FILESDIR}"/bfd-malloc-wrap.patch #91398

		epatch "${FILESDIR}"/gdb-6.2.1-200-uclibc-readline-conf.patch
		epatch "${FILESDIR}"/gdb-6.2.1-400-mips-coredump.patch
		epatch "${FILESDIR}"/gdb-6.2.1-libiberty-pic.patch
	fi

	strip-linguas -u bfd/po opcodes/po
}

src_compile() {
	replace-flags -O? -O2
	econf \
		--disable-werror \
		$(use_enable nls) \
		|| die
	emake -j1 || die
}

src_test() {
	make check || ewarn "tests failed"
}

src_install() {
	make \
		prefix="${D}"/usr \
		mandir="${D}"/usr/share/man \
		infodir="${D}"/usr/share/info \
		libdir="${D}"/nukeme includedir="${D}"/nukeme \
		install || die "install"
	# The includes and libs are in binutils already
	rm -r "${D}"/nukeme

	# Don't install docs when building a cross-gdb
	if [[ ${CTARGET} != ${CHOST} ]] ; then
		rm -r "${D}"/usr/share
		return 0
	fi

	dodoc README
	docinto gdb
	dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
		gdb/NEWS gdb/ChangeLog* gdb/TODO
	docinto sim
	dodoc sim/ChangeLog sim/MAINTAINERS sim/README-HACKING
	docinto mmalloc
	dodoc mmalloc/MAINTAINERS mmalloc/ChangeLog mmalloc/TODO

	if use x86 ; then
		dodir /etc/skel/
		cp "${S}"/gdb_init.txt "${D}"/etc/skel/.gdbinit \
			|| die "install ${D}/etc/skel/.gdbinit"
	fi

	if ! has noinfo ${FEATURES} ; then
		make \
			infodir="${D}"/usr/share/info \
			install-info \
			|| die "install doc info"
		# Remove shared info pages
		rm -f "${D}"/usr/share/info/{annotate,bfd,configure,standards}.info*
	fi
}


This is the ebuild that works:

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-devel/gdb/gdb-6.4.ebuild,v 1.4 2006/02/19 23:15:31 kumba Exp $

inherit flag-o-matic eutils

export CTARGET=${CTARGET:-${CHOST}}
if [[ ${CTARGET} == ${CHOST} ]] ; then
	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
		export CTARGET=${CATEGORY/cross-}
	fi
fi

#DEB_VER=6
DESCRIPTION="GNU debugger"
HOMEPAGE="http://sources.redhat.com/gdb/"
SRC_URI="http://ftp.gnu.org/gnu/gdb/${P}.tar.bz2
	ftp://sources.redhat.com/pub/gdb/releases/${P}.tar.bz2
	mirror://gentoo/gdb_init.txt.bz2"

LICENSE="GPL-2 LGPL-2"
[[ ${CTARGET} != ${CHOST} ]] \
	&& SLOT="${CTARGET}" \
	|| SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 mips ppc ppc64 s390 sparc x86"
IUSE="nls test vanilla"

RDEPEND=">=sys-libs/ncurses-5.2-r2"
DEPEND="${RDEPEND}
	test? ( dev-util/dejagnu )
	nls? ( sys-devel/gettext )"

src_unpack() {
	unpack ${A}
	cd "${S}"
	mv "${WORKDIR}"/gdb_init.txt . || die

	if ! use vanilla ; then
		if [[ -n ${DEB_VER} ]] ; then
			epatch "${WORKDIR}"/gdb_${PV}-${DEB_VER}.diff
			for f in $(<debian/patches/series) ; do
				EPATCH_SINGLE_MSG="Applying Debian's ${f}" \
				epatch debian/patches/${f}
			done
		fi
		epatch "${FILESDIR}"/gdb-6.4-uclibc.patch
		#epatch "${FILESDIR}"/gdb-6.4-relative-paths.patch
		#epatch "${FILESDIR}"/gdb-6.x-crash.patch
		epatch "${FILESDIR}"/gdb-6.2.1-pass-libdir.patch
		epatch "${FILESDIR}"/gdb-6.4-scanmem.patch
		epatch "${FILESDIR}"/gdb-6.3-gdbinit-stat.patch
		epatch "${FILESDIR}"/bfd-malloc-wrap.patch #91398

		epatch "${FILESDIR}"/gdb-6.2.1-200-uclibc-readline-conf.patch
		epatch "${FILESDIR}"/gdb-6.2.1-400-mips-coredump.patch
		epatch "${FILESDIR}"/gdb-6.2.1-libiberty-pic.patch
	fi

	strip-linguas -u bfd/po opcodes/po
}

src_compile() {
	replace-flags -O? -O2
	econf \
		--disable-werror \
		$(use_enable nls) \
		|| die
	emake -j1 || die
}

src_test() {
	make check || ewarn "tests failed"
}

src_install() {
	make \
		prefix="${D}"/usr \
		mandir="${D}"/usr/share/man \
		infodir="${D}"/usr/share/info \
		libdir="${D}"/nukeme includedir="${D}"/nukeme \
		install || die "install"
	# The includes and libs are in binutils already
	rm -r "${D}"/nukeme

	# Don't install docs when building a cross-gdb
	if [[ ${CTARGET} != ${CHOST} ]] ; then
		rm -r "${D}"/usr/share
		return 0
	fi

	dodoc README
	docinto gdb
	dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
		gdb/NEWS gdb/ChangeLog* gdb/TODO
	docinto sim
	dodoc sim/ChangeLog sim/MAINTAINERS sim/README-HACKING
	docinto mmalloc
	dodoc mmalloc/MAINTAINERS mmalloc/ChangeLog mmalloc/TODO

	if use x86 ; then
		dodir /etc/skel/
		cp "${S}"/gdb_init.txt "${D}"/etc/skel/.gdbinit \
			|| die "install ${D}/etc/skel/.gdbinit"
	fi

	if ! has noinfo ${FEATURES} ; then
		make \
			infodir="${D}"/usr/share/info \
			install-info \
			|| die "install doc info"
		# Remove shared info pages
		rm -f "${D}"/usr/share/info/{annotate,bfd,configure,standards}.info*
	fi
}


The only difference is the comment at line 47(	#epatch "${FILESDIR}"/gdb-6.4-relative-paths.patch)
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-03-04 10:26:22 UTC
Uh, this is a mess. Please, next time just *attach* the patch and/or plaintext diff of the ebuild. Don't paste such stuff inline.
Comment 2 Carlos Eduardo Rodrigues de Almeida 2006-03-04 10:30:13 UTC
(In reply to comment #1)
> Uh, this is a mess. Please, next time just *attach* the patch and/or plaintext
> diff of the ebuild. Don't paste such stuff inline.
> 

Sorry... I just tried to supply all the information I had
Comment 3 SpanKY gentoo-dev 2006-03-05 10:06:59 UTC

*** This bug has been marked as a duplicate of 122050 ***