mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Merge pull request #32 from achilleasa/improve-debugging
Use latest Go in Vagrantfile and improve debugging
This commit is contained in:
commit
c9ca6e31eb
14
Makefile
14
Makefile
@ -20,6 +20,7 @@ GOOS := linux
|
|||||||
GOARCH := amd64
|
GOARCH := amd64
|
||||||
GOROOT := $(shell $(GO) env GOROOT)
|
GOROOT := $(shell $(GO) env GOROOT)
|
||||||
|
|
||||||
|
GC_FLAGS ?=
|
||||||
LD_FLAGS := -n -T $(BUILD_DIR)/linker.ld -static --no-ld-generated-unwind-info
|
LD_FLAGS := -n -T $(BUILD_DIR)/linker.ld -static --no-ld-generated-unwind-info
|
||||||
AS_FLAGS := -g -f elf64 -F dwarf -I arch/$(ARCH)/asm/ -dNUM_REDIRECTS=$(shell $(GO) run tools/redirects/redirects.go count)
|
AS_FLAGS := -g -f elf64 -F dwarf -I arch/$(ARCH)/asm/ -dNUM_REDIRECTS=$(shell $(GO) run tools/redirects/redirects.go count)
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ go.o:
|
|||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
@echo "[go] compiling go sources into a standalone .o file"
|
@echo "[go] compiling go sources into a standalone .o file"
|
||||||
@GOARCH=$(GOARCH) GOOS=$(GOOS) $(GO) build -n 2>&1 | sed \
|
@GOARCH=$(GOARCH) GOOS=$(GOOS) $(GO) build -gcflags '$(GC_FLAGS)' -n 2>&1 | sed \
|
||||||
-e "1s|^|set -e\n|" \
|
-e "1s|^|set -e\n|" \
|
||||||
-e "1s|^|export GOOS=$(GOOS)\n|" \
|
-e "1s|^|export GOOS=$(GOOS)\n|" \
|
||||||
-e "1s|^|export GOARCH=$(GOARCH)\n|" \
|
-e "1s|^|export GOARCH=$(GOARCH)\n|" \
|
||||||
@ -107,27 +108,30 @@ VAGRANT_SRC_FOLDER = /home/vagrant/workspace/src/github.com/achilleasa/gopher-os
|
|||||||
.PHONY: kernel iso vagrant-up vagrant-down vagrant-ssh run gdb clean
|
.PHONY: kernel iso vagrant-up vagrant-down vagrant-ssh run gdb clean
|
||||||
|
|
||||||
kernel:
|
kernel:
|
||||||
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make kernel'
|
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make GC_FLAGS="$(GC_FLAGS)" kernel'
|
||||||
|
|
||||||
iso:
|
iso:
|
||||||
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make iso'
|
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make GC_FLAGS="$(GC_FLAGS)" iso'
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
run: iso
|
run: iso
|
||||||
qemu-system-$(ARCH) -cdrom $(iso_target) -d int,cpu_reset -no-reboot
|
qemu-system-$(ARCH) -cdrom $(iso_target) -d int,cpu_reset -no-reboot
|
||||||
|
|
||||||
|
# When building gdb target disable optimizations (-N) and inlining (l) of Go code
|
||||||
|
gdb: GC_FLAGS += -N -l
|
||||||
gdb: iso
|
gdb: iso
|
||||||
qemu-system-$(ARCH) -M accel=tcg -s -S -cdrom $(iso_target) &
|
qemu-system-$(ARCH) -M accel=tcg -s -S -cdrom $(iso_target) &
|
||||||
sleep 1
|
sleep 1
|
||||||
gdb \
|
gdb \
|
||||||
-ex 'add-auto-load-safe-path $(pwd)' \
|
-ex 'add-auto-load-safe-path $(pwd)' \
|
||||||
-ex 'set disassembly-flavor intel' \
|
-ex 'set disassembly-flavor intel' \
|
||||||
-ex 'layout asm' \
|
-ex 'layout split' \
|
||||||
-ex 'set arch i386:intel' \
|
-ex 'set arch i386:intel' \
|
||||||
-ex 'file $(kernel_target)' \
|
-ex 'file $(kernel_target)' \
|
||||||
-ex 'target remote localhost:1234' \
|
-ex 'target remote localhost:1234' \
|
||||||
-ex 'set arch i386:x86-64:intel'
|
-ex 'set arch i386:x86-64:intel' \
|
||||||
|
-ex 'source $(GOROOT)/src/runtime/runtime-gdb.py'
|
||||||
@killall qemu-system-$(ARCH) || true
|
@killall qemu-system-$(ARCH) || true
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
4
Vagrantfile
vendored
4
Vagrantfile
vendored
@ -17,8 +17,8 @@ Vagrant.configure("2") do |config|
|
|||||||
|
|
||||||
config.vm.provision "shell", inline: <<-SHELL
|
config.vm.provision "shell", inline: <<-SHELL
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y nasm gccgo xorriso
|
apt-get install -y nasm make xorriso
|
||||||
[ ! -d "/usr/local/go" ] && wget -qO- https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz | tar xz -C /usr/local
|
[ ! -d "/usr/local/go" ] && wget -qO- https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar xz -C /usr/local
|
||||||
echo "export GOROOT=/usr/local/go" > /etc/profile.d/go.sh
|
echo "export GOROOT=/usr/local/go" > /etc/profile.d/go.sh
|
||||||
echo "export GOBIN=/usr/local/go/bin" >> /etc/profile.d/go.sh
|
echo "export GOBIN=/usr/local/go/bin" >> /etc/profile.d/go.sh
|
||||||
echo "export GOPATH=/home/vagrant/workspace" >> /etc/profile.d/go.sh
|
echo "export GOPATH=/home/vagrant/workspace" >> /etc/profile.d/go.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user