Skip to content

Commit

Permalink
add: debugger for vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrgoblings committed Dec 26, 2024
1 parent 032eab7 commit 02726b6
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
target/
AnasOS/boot/kernel
.vscode/
.vscode/settings.json

*.bin
*.out
Expand Down
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// FROM https://github.com/chuckb/riscv-helloworld-c/blob/NbZDowmXzZs/.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug AnasOS",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/AnasOS/boot/kernel",
"cwd": "${workspaceFolder}",
"preLaunchTask": "Run QEMU"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// FROM https://github.com/chuckb/riscv-helloworld-c/blob/NbZDowmXzZs/.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "make",
"args": ["bootloader-no-run"],
// "args": ["kernel-no-run"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "Run QEMU",
"type": "shell",
"command": "echo 'QEMU started'; qemu-system-x86_64 ${workspaceFolder}/AnasOS.iso -s -S",
"dependsOn": ["Build"],
"isBackground": true,
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "QEMU started",
}
}
]
}
]
}
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
.PHONY: run clean

all: clean kernel-rust image run
kernel: clean kernel-rust image run

kernel-no-run: clean kernel-rust image

vnc: clean kernel-rust image run-vnc

no-run: clean kernel-rust image
bootloader: clean bootloader-asm image run

bootloader-no-run: clean bootloader-asm image

test: no-run
echo "Compiled the OS successfully"

kernel-rust:
@cd ./anasos-kernel && \
cargo build --release
@cp ./anasos-kernel/target/x86_64-unknown-none/release/anasos-kernel AnasOS/boot/kernel

bootloader-asm:
@cd ./anasos-kernel/bootloader && \
nasm -f elf64 header.asm -o header.o && \
nasm -f elf64 boot-64.asm -o boot-64.o && \
nasm -f elf64 boot.asm -o boot.o && \
nasm -f elf64 e820.asm -o e820.o && \
ld -m elf_x86_64 -T ../linker.ld -o ../../AnasOS/boot/kernel boot.o boot-64.o header.o #e820.o \

image:
@cp ./anasos-kernel/target/x86_64-unknown-none/release/anasos-kernel AnasOS/boot/kernel
grub-mkrescue -o AnasOS.iso AnasOS/

run:
Expand Down
12 changes: 10 additions & 2 deletions anasos-kernel/bootloader/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
all:
compile:
nasm -f elf64 header.asm -o header.o
nasm -f elf64 boot-64.asm -o boot-64.o
nasm -f elf64 boot.asm -o boot.o
nasm -f elf64 e820.asm -o e820.o

ld -m elf_x86_64 -T ../linker.ld -o ../../AnasOS/boot/kernel boot.o boot-64.o header.o #e820.o
grub-mkrescue -o AnasOS.iso ../../AnasOS/
qemu-system-x86_64 AnasOS.iso

run: compile
qemu-system-x86_64 AnasOS.iso

debug: compile
qemu-system-x86_64 AnasOS.iso -s -S

debug-gdb:
gdb ../../AnasOS/boot/kernel -q -ex "target remote localhost:1234"

0 comments on commit 02726b6

Please sign in to comment.