Better debugging support
Now builds 64b with debugging support, and on x86, it retains the original 64b
object. Once we objcopy, we lose the ability to use some debugging tools, such
as addr2line.
This retains the 64bit original version of the kernel, which will be large if
you use a big KFS. But no one should be doing that anymore. If you do, you
can comment out the cp in k/a/x/Makefile (but don't commit it).
With this change, you can do things such as:
$ x86_64-ros-addr2line -e obj/kern/akaros-kernel-64b
ffffffffc0321cef
/usr/local/google/home/brho/akaros/ros-kernel/kern/src/process.c:551
^C
$ gdb obj/kern/akaros-kernel-64b
Reading symbols
from akaros-kernel-64b...done.
(gdb) list *0xffffffffc200d030
0xffffffffc200d030 is in abort_all_sysc (kern/src/kthread.c:739).
734/* This will abort any abortabls at the time the call was started. New
735 * abortables could be registered concurrently. The main caller I see for this
736 * is proc_destroy(), so DYING will be set, and new abortables will quickly
737 * abort and dereg when they see their proc is DYING. */
738void abort_all_sysc(struct proc *p)
739{
740 struct cv_lookup_elm *cle;
741 int8_t irq_state = 0;
742 struct cv_lookup_tailq abortall_list;
743 struct proc *old_proc = switch_to(p);
(gdb)
Note that you need to call this on the akaros-kernel-64b version (for amd64).
diff --git a/Makefile b/Makefile
index a8528b9..9473ac7 100644
--- a/Makefile
+++ b/Makefile
@@ -317,7 +317,7 @@
CFLAGS_KERNEL += -DROS_KERNEL
CFLAGS_KERNEL += -include include/generated/autoconf.h -include include/common.h
ifeq ($(CONFIG_64BIT),y)
-CFLAGS_KERNEL += -m64
+CFLAGS_KERNEL += -m64 -g
else
CFLAGS_KERNEL += -m32 -gstabs
endif
diff --git a/kern/arch/x86/Makefile b/kern/arch/x86/Makefile
index f13738a..fededcd 100644
--- a/kern/arch/x86/Makefile
+++ b/kern/arch/x86/Makefile
@@ -7,7 +7,7 @@
CFLAGS_KERNEL += -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
LDFLAGS_KERNEL += -z max-page-size=0x1000
# Need to change the format to 32 bit, to trick multiboot/grub1 into loading
-ARCH_POST_LINK_CMD = $(OBJCOPY) -I elf64-x86-64 -O elf32-i386 $@
+ARCH_POST_LINK_CMD = cp $@ $@-64b; $(OBJCOPY) -I elf64-x86-64 -O elf32-i386 $@
else
CROSS_COMPILE := i686-ros-
BITS := 32