Subject: port-evbppc/34778: gdb6 doesn't work on OpenBlockS266
To: None <port-evbppc-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <fukaumi@soum.co.jp>
List: netbsd-bugs
Date: 10/11/2006 03:10:00
>Number:         34778
>Category:       port-evbppc
>Synopsis:       gdb6 doesn't work on OpenBlockS266
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-evbppc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 11 03:10:00 +0000 2006
>Originator:     FUKAUMI Naoki
>Release:        NetBSD 4.99.3 as of Oct 10 2006
>Organization:
	SOUM Corporation
>Environment:
System: NetBSD 4.99.3 NetBSD 4.99.3 (OPENBLOCKS266) #0: Tue Oct 10 19:33:41 JST 2006 fukaumi@XXX.soum.co.jp:/home/fukaumi/evbppc/o/sys/arch/evbppc/compile/OPENBLOCKS266 evbppc
Architecture: powerpc
Machine: evbppc

# gcc --version
gcc (GCC) 4.1.2 20060628 prerelease (NetBSD nb2 20060711)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# gdb --version
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc--netbsd".
>Description:
	gdb 6.5 does not work on OpenBlockS266.

	if target program is dynamic linked binary, program never reachs
	main() function.

	if target program is static linked binary, program does not stop
	at break point.
>How-To-Repeat:
- test program

# cat test.c
#include <stdio.h>

int
main() {
        printf("hello, world\n");
        return 0;
}
# cc -g -o test test.c
# cc -g -static -o test-static test.c

- dynamic linked binary

# file test
test: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for NetBSD 4.99.3, dynamically linked (uses shared libs), for NetBSD 4.99.3, not stripped

# gdb ./test
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc--netbsd"...
(gdb) b main
Breakpoint 1 at 0x18007c8: file test.c, line 5.
(gdb) run
Starting program: /tmp/test 
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
debug reg is 80000000 srr2 2000 srr3 0
  :
(repeat forever)
  :
^C
Program received signal SIGINT, Interrupt.
0x41813d30 in _rtld_debug_state () from /usr/libexec/ld.elf_so

- static linked binary

# file test-static
test-static: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for NetBSD 4.99.3, statically linked, for NetBSD 4.99.3, not stripped

# gdb ./test-static
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc--netbsd"...
(gdb) b main
Breakpoint 1 at 0x1800460: file test.c, line 5.
(gdb) run
Starting program: /tmp/test-static 
hello, world

Program exited normally.
>Fix: