diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..599bdde --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,67 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "make", + "type": "shell", + "command": "${workspaceRoot}/make", + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "emu", + "type": "shell", + "command": "${workspaceRoot}/emu", + "group": "none", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [] + }, + { + "label": "dbg", + "type": "shell", + "command": "sleep 1;${workspaceRoot}/dbg", + "group": "none", + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": false + } + }, + { + "label": "test", + "group": { + "kind": "test", + "isDefault": true + }, + "dependsOn": [ + "emu", + "dbg" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": false + } + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index b062184..45dd8b3 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,13 @@ KERNELMAKE := TARGET=${TARGET} $(MAKE) -C src/kernel DIST := $(BUILDROOT)/mittos.iso SYSROOT := $(BUILDROOT)/sysroot +SYS_ITEMS := $(SYSROOT)/kernel -$(DIST): $(SYSROOT)/kernel +all: $(SYSROOT)/kernel + +dist: $(DIST) + +$(DIST): $(SYS_ITEMS) $(BUILDROOT)/toolchain/setup-grub.sh grub-mkrescue -o $@ $(SYSROOT) @@ -17,7 +22,7 @@ ifeq ($(shell make -sqC src/kernel || echo 1), 1) $(KERNELMAKE) install endif -.PHONY: FORCE +.PHONY: all dist sysroot FORCE clean: rm -rf $(DIST) diff --git a/toolchain/gdbinit b/toolchain/gdbinit index 3dfdf83..51631c2 100644 --- a/toolchain/gdbinit +++ b/toolchain/gdbinit @@ -21,10 +21,9 @@ import os gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel') end +# Inspect registers with `reg RAX` or just `reg` python - import re - class Reg(gdb.Command): def __init__(self): @@ -52,6 +51,27 @@ class Reg(gdb.Command): print(matches[0]) else: print(f"Register {arg.upper()} unknown") - Reg() end + +# Break on any label called panic_breakpoint_X which is defined by the PANIC() macro +python +import re +syms = gdb.execute('maintenance print msymbols', False, True) +for l in syms.splitlines(): + matches = re.findall("panic_breakpoint_.*\\b", l) + if matches: + name = matches[0].split()[0] + gdb.execute(f"break {name}", to_string=True) + +end + +define restore_env +set $name = $arg0 +python +regs = ['rax', 'rbx', 'rcx', 'rdx', 'rsi', 'rdi', 'rbp', 'rsp', 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15', 'rip'] +stored = {r: gdb.parse_and_eval('$name->'+r) for r in regs} +for r in regs: + gdb.parse_and_eval(f"${r}={stored[r]}") +gdb.execute("frame 0") +end \ No newline at end of file