diff --git a/14-checkpoint/Makefile b/14-checkpoint/Makefile index 61497ea..2756535 100644 --- a/14-checkpoint/Makefile +++ b/14-checkpoint/Makefile @@ -12,9 +12,13 @@ CFLAGS = -g os-image.bin: boot/bootsect.bin kernel.bin cat $^ > os-image.bin -kernel.bin: kernel.elf +kernel.bin: boot/kernel_entry.o ${OBJ} i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary +# Used for debugging purposes +kernel.elf: boot/kernel_entry.o ${OBJ} + i386-elf-ld -o $@ -Ttext 0x1000 $^ + run: os-image.bin qemu-system-i386 -fda os-image.bin @@ -22,10 +26,6 @@ debug: os-image.bin kernel.elf qemu-system-i386 -s -fda os-image.bin & ${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf" -# To build the kernel: make all objects first -kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ - # To make an object, always compile from its .c %.o: %.c ${HEADERS} ${CC} ${CFLAGS} -ffreestanding -c $< -o $@ diff --git a/14-checkpoint/README.md b/14-checkpoint/README.md index cf31211..56c608f 100644 --- a/14-checkpoint/README.md +++ b/14-checkpoint/README.md @@ -31,8 +31,12 @@ make make install ``` -Check out the Makefile target `make debug`. We can take -advantage of this cool qemu feature. Type `make debug` and, on the gdb shell: +Check out the Makefile target `make debug`. This target uses builds `kernel.elf`, which +is an object file (not binary) with all the symbols we generated on the kernel, thanks to +the `-g` flag on gcc. Please examine it with `xxd` and you'll see some strings. Actually, +the correct way to examine the strings in an object file is by `strings kernel.elf` + +We can take advantage of this cool qemu feature. Type `make debug` and, on the gdb shell: - Set up a breakpoint in `kernel.c:main()`: `b main` - Run the OS: `continue` @@ -44,7 +48,8 @@ advantage of this cool qemu feature. Type `make debug` and, on the gdb shell: - `next` to put there our 'X' - Let's make sure: `print *video_memory` and look at the qemu screen. It's definitely there. -Now is a good time to read some tutorial on `gdb`! +Now is a good time to read some tutorial on `gdb` and learn super useful things like `info registers` +which will save us a lot of time in the future! Strategy diff --git a/14-checkpoint/boot/bootsect.bin b/14-checkpoint/boot/bootsect.bin new file mode 100644 index 0000000..e8d27fb Binary files /dev/null and b/14-checkpoint/boot/bootsect.bin differ diff --git a/14-checkpoint/kernel/kernel.o b/14-checkpoint/kernel/kernel.o new file mode 100644 index 0000000..c7cfa2e Binary files /dev/null and b/14-checkpoint/kernel/kernel.o differ