Subject: kgdb in virtex port
To: None <port-powerpc@netbsd.org>
From: Jean-Francois Boudreault <jfboudre@gel.ulaval.ca>
List: port-powerpc
Date: 01/31/2007 14:47:50
This is a multi-part message in MIME format.
--------------080100070708090205090901
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi there,  

I've been playing with Jachym's virtex port for a while. I added support 
for KGDB in your port but can't get it working right.


Here's my boot message on the target:

+4000000,
00025000-04000000 -­> 00740000-04000000 = 38c0000
kgdb waiting...trap type 0x700 at 0x2375b0


And the log of the gdb running on remote system (gdb built from build.sh 
using variable MKCROSSGDB)::

# cd /usr/obj/tooldir.NetBSD-3.0-i386/
# cd bin
# ./powerpc--netbsd-gdb 
/usr/src/sys/arch/evbppc/compile/obj/LRTS/netbsd.gdb
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 "--host=i386-unknown-netbsdelf3.0 
--target=powerpc--netbsd"...
(gdb) set solib-absolute-prefix /usr/obj/destdir.evbppc
(gdb) set solib-search-path 
/usr/obj/destdir.evbppc/lib:/usr/obj/destdir.evbppc/usr/lib
(gdb) set remotebaud 38400
(gdb) set remotebreak 1
(gdb) set remotetimeout 3
(gdb) target remote /dev/tty00
Remote debugging using /dev/tty00
kgdb_connect (verbose=<value optimized out>)
   at /usr/src/sys/arch/powerpc/powerpc/kgdb_machdep.c:268
268             if (verbose && kgdb_active) {
warning: no shared library support for this OS / ABI
(gdb) bt
#0  kgdb_connect (verbose=<value optimized out>)
   at /usr/src/sys/arch/powerpc/powerpc/kgdb_machdep.c:268
Cannot access memory at address 0x73fee0
(gdb) n
Cannot access memory at address 0x73fee0
(gdb) b 270
Breakpoint 1 at 0x2375b8: file 
/usr/src/sys/arch/powerpc/powerpc/kgdb_machdep.c, line 270.
(gdb) n
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x2375b8: Input/output error.

(gdb)


Looks like memory address problems. Anyone have a hint what could be the 
problem?

I included the diff of the modifs from the cvs current to add kgdb 
support in virtex port.

Thanks for the help!

Jeff.


--------------080100070708090205090901
Content-Type: text/plain;
 name="kgdb_in_virtex.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kgdb_in_virtex.diff"

Index: evbppc/virtex/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/virtex/machdep.c,v
retrieving revision 1.1
diff -r1.1 machdep.c
42a43
> #include "opt_kgdb.h"
83a85,87
> #if defined(KGDB)
> #include <sys/kgdb.h>
> #endif
260a265,270
> #ifdef KGDB
> 	/*
> 	 * Now trap to KGDB
> 	 */
> 	kgdb_connect(1);
> #endif /* KGDB */
426a437,441
> #ifdef KGDB
> 		printf("dropping to kgdb\n");
> 		while(1)
> 			kgdb_connect(1);
> #endif
457a473,476
> #endif
> #ifdef KGDB
> 	while(1)
> 		kgdb_connect(1);
Index: evbppc/virtex/dev/xlcom.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/virtex/dev/xlcom.c,v
retrieving revision 1.1
diff -r1.1 xlcom.c
36a37,38
> #include "opt_kgdb.h"
> 
144a148,167
> #ifdef KGDB
> #include <sys/kgdb.h>
> 
> #ifndef KGDB_DEVNAME
> #define KGDB_DEVNAME "xlcom"
> #endif
> 
> #ifndef KGDB_DEVRATE
> #define KGDB_DEVRATE 38400
> #endif
> 
> #ifndef KGDB_DEVMODE
> #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)
> #endif
> 
> int 	xlcom_kgdb_getc(void *);
> void	xlcom_kgdb_putc(void *, int);
> #endif /* KGDB */
> 
> 
633a667,671
> 
> #ifdef KGDB
> 	kgdb_attach(xlcom_kgdb_getc, xlcom_kgdb_putc, NULL);
> 	kgdb_dev = 123;
> #endif /* KGDB */
655a694,707
> 
> #ifdef KGDB
> int
> xlcom_kgdb_getc(void *arg)
> {
> 	return (xlcom_cngetc(NODEV));
> }
> 
> void
> xlcom_kgdb_putc(void *arg, int c)
> {
> 	xlcom_cnputc(NODEV, c);
> }
> #endif /* KGDB */
Index: powerpc/ibm4xx/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/trap.c,v
retrieving revision 1.37
diff -r1.37 trap.c
73a74
> #include "opt_kgdb.h"
103a105,108
> #ifdef KGDB
> #include <sys/kgdb.h>
> #endif
> 
370a376,379
> #ifdef KGDB
> 		if (kdb_trap(T_BREAKPOINT, frame))
> 			goto done;
> #endif 
Index: powerpc/powerpc/db_interface.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/db_interface.c,v
retrieving revision 1.36
diff -r1.36 db_interface.c
38a39
> #define db_printf printf
49a51
> #ifdef DDB
60a63
> #endif /* DDB */
193a197
> #ifdef DDB
487a492,493
> #endif /* DDB */
> 
Index: powerpc/powerpc/kgdb_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/kgdb_machdep.c,v
retrieving revision 1.16
diff -r1.16 kgdb_machdep.c
69d68
< 	u_int batu, batl;
77a77
> 	u_int batu, batl;

--------------080100070708090205090901--