Subject: Re: Cross-debugging using GDB, building retargetted GDB
To: Rafal Boni <email@example.com>
From: Wayne Knowles <wdk@NetBSD.ORG>
Date: 04/23/2001 22:47:45
On Thu, 19 Apr 2001, Rafal Boni wrote:
> Having found the nice cross-compilation tools Tim Rightnour and Bill
> Sommerfeld did, I've now got a whole sgimips NetBSD tree cross-building
> on my x86 box, including the tools needed to build said tree.
> However, I was hoping I'd also be able to build cross-gdb, that is an
> x86-compiled executable but targetted at MIPSEB/ELF target. Our in-tree
> GDB seems to from the start subvert any attempts to do this since it
> always assumes HOST == TARGET. I'd rather beat the in-tree GDB and its'
> Makefiles into doing the Right Thing than starting over with the original
> GDB sources, as that would allow me to build all this in one fell swoop.
> Anyone out there done this, tried and failed and have advice, ...?
Several people have experienced problems building the toolchain from the
netbsd sources. The bugs are slowly being fixed. For me I had more
success building GDB from the gnu distribution for a MIPSEB target:
GNU gdb 5.0
Copyright 2000 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
This GDB was configured as "--host=i386-unknown-freebsdelf5.0 --target=mips-netbsd-elf".
You should be able to configure GDB using
configure --target=mips-netbsd-elf --disable-sim
It took me a while to work out the correct target to use that is
consistant across all of the GNU tools!!!
> Also, if I have a GDB for x86 targetted at MIPSEB/ELF, should I be able
> to do kernel-debugging using my x86 as the debug end and the SGI as the
> debugee? If that doesn't work, I have much less incentive to try and
> get the cross-GDB building.
Yes and no......
Out of all the MIPS based ports only the mipsco port has KGDB kernel
debugging... and even then there are a few limitations.
I have at least 2 uncommited change(s) that need to be made to the
kernel sources for it to work for the mips processor (R3000 in my
case). There still remains a problem when single stepping thru a
branch intruction as the branch delay slot is not taken into
consideration. You can also have problems if you breakpoint on any
instruction that has the target address in a register (such as a 'j ra'
sequence used to return from a subroutine).
When I get time I hope to fix theese problems and get the complete set of
patches reviewed and commited.
As for the sgimips port - most of KGDB is already there since it uses the
MI serial port routines. What the sgimips port lacks is the call to
kgdb_attach() at system startup, and the necessary options in the config
file. Both of these should be trivial to fix.