where to get sh-elf-gdb

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

where to get sh-elf-gdb

Post by ThePerfectK »

I already have a pre built binary for sh-elf-gdb so I don't really need the program for myself, I'm just more wondering whats the best way for someone who doesn't have the binary to get it? There doesn't appear to be any packages in the package managers for the distros I use for sh-elf-gdb and when you google around for binaries, you typically find really small, 5mb binaries that don't work. My copy of sh-elf-gdb is about 30 mb big!

So where is someone supposed to go to actually get sh-elf-gdb? Is there a source it should be built from? Is there an official repository? Is there some provider of prebuilt binaries that I just don't know about?

EDIT: Looking around the internet on some old compiler page, it seems you can build SH-ELF-GDB from the gdb source itself? I found the following commands:

Code: Select all

   /home/linus> cd build/gdb
   /home/linus/build/gdb> ../../gdb-6.6/configure --target=sh-elf --prefix=/home/linus/sh1
   /home/linus/build/gdb> make
   /home/linus/build/gdb> make install
I assume you grab this GDB source here: https://www.gnu.org/software/gdb/download/

then build with the appropriate --target=sh-elf flag?

Anyone done this before? Is this generally correct?
Still Thinking!~~
mrneo240
DCEmu Freak
DCEmu Freak
Posts: 86
Joined: Wed Mar 14, 2018 12:22 am
Has thanked: 16 times
Been thanked: 19 times

Re: where to get sh-elf-gdb

Post by mrneo240 »

My docker images include it haydenkow/nu_dckos
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: where to get sh-elf-gdb

Post by ThePerfectK »

mrneo240 wrote: Tue Aug 27, 2019 11:58 am My docker images include it haydenkow/nu_dckos
Im pretty sure thats how i got my copy too, or something similar, but im more interested in figuring out how to generate sh-elf-gdb myself, or pull from an official gdb source, i.e. not part of a larger package. Being on the whim of a docker image is a bit too unreliable, itd be better to document how to generate sh-elf-gdb in case that image ever vanishes online.
Still Thinking!~~
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 404
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has thanked: 27 times
Been thanked: 19 times
Contact:

Re: where to get sh-elf-gdb

Post by SiZiOUS »

ThePerfectK wrote: Tue Aug 27, 2019 10:07 am EDIT: Looking around the internet on some old compiler page, it seems you can build SH-ELF-GDB from the gdb source itself?
Yes!
ThePerfectK wrote: Tue Aug 27, 2019 10:07 amI found the following commands:

Code: Select all

   /home/linus> cd build/gdb
   /home/linus/build/gdb> ../../gdb-6.6/configure --target=sh-elf --prefix=/home/linus/sh1
   /home/linus/build/gdb> make
   /home/linus/build/gdb> make install
I assume you grab this GDB source here: https://www.gnu.org/software/gdb/download/

then build with the appropriate --target=sh-elf flag?

Anyone done this before? Is this generally correct?
Yes it is. The simplest option is to read the dc-chain Makefile, which is part of KOS:

Code: Select all

# GDB building

gdb_url := ftp://ftp.gnu.org/gnu/gdb/gdb-$(gdb_ver).tar.gz

# Under MinGW/MSYS, a little fix is needed to compile gdb, at least with 7.12.1.
ifdef MINGW
    gdb_patches := $(wildcard $(patches)/$(host_triplet)/gdb-$(gdb_ver)*.diff)	
endif

gdb-$(gdb_ver).tar.gz:
	@echo "+++ Downloading GDB..."
ifndef USE_CURL
	wget -c $(gdb_url)
else
	curl -O -J $(gdb_url)
endif

unpack_gdb: gdb-$(gdb_ver).tar.gz unpack_gdb_stamp patch_gdb_stamp

unpack_gdb_stamp:
	@echo "+++ Unpacking GDB..."
	rm -f $@
	rm -rf gdb-$(gdb_ver)
	tar xf gdb-$(gdb_ver).tar.gz
	touch $@

patch_gdb_stamp:
	rm -f $@
ifdef MINGW
	patch -N -d gdb-$(gdb_ver) -p1 < $(gdb_patches)
endif
	touch $@

build_gdb: log = $(logdir)/gdb-$(gdb_ver).log
build_gdb: logdir
build_gdb: unpack_gdb build_gdb_stamp

build_gdb_stamp:
	@echo "+++ Building GDB..."
	rm -f $@
	> $(log)
	rm -rf build-gdb-$(gdb_ver)
	mkdir build-gdb-$(gdb_ver)
	cd build-gdb-$(gdb_ver); ../gdb-$(gdb_ver)/configure \
	    --disable-werror \
	    --prefix=$(sh_prefix) \
	    --target=$(sh_target) \
	    $(static_flag) \
	    $(to_log)
	$(MAKE) $(makejobs) -C build-gdb-$(gdb_ver) $(to_log)
	touch $@

install_gdb: log = $(logdir)/gdb-$(gdb_ver).log
install_gdb: logdir
install_gdb: build_gdb install_gdb_stamp

install_gdb_stamp:
	@echo "+++ Installing GDB..."
	rm -f $@
	$(MAKE) -C build-gdb-$(gdb_ver) install DESTDIR=$(DESTDIR) $(to_log)
	touch $@

gdb: install_gdb
The important part is:

Code: Select all

cd build-gdb-$(gdb_ver); ../gdb-$(gdb_ver)/configure \
	    --disable-werror \
	    --prefix=$(sh_prefix) \
	    --target=$(sh_target) \
	    $(static_flag) \
	    $(to_log)
$(MAKE) $(makejobs) -C build-gdb-$(gdb_ver) $(to_log)
So in the dc-chain directory, typing...

Code: Select all

make gdb
... will do all the necessary to get the sh-elf-gdb binary for your platform. I'm not aware for any binary package for sh-elf-gdb in repositories like apt (speaking for Debian/Ubuntu).
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: where to get sh-elf-gdb

Post by ThePerfectK »

Thanks so much for the input Siz! I never noticed that make command in DC-chain makefile! Doh!!

EDIT: Just tested it out on a recent install of KOS and worked perfectly, thanks so much!!
Still Thinking!~~
Post Reply