Some build help
This commit is contained in:
		
							parent
							
								
									d69a047172
								
							
						
					
					
						commit
						e97f614cac
					
				
							
								
								
									
										67
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -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 | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     ] | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								Makefile
									
									
									
									
									
								
							| @ -7,8 +7,13 @@ KERNELMAKE := TARGET=${TARGET} $(MAKE) -C src/kernel | |||||||
| 
 | 
 | ||||||
| DIST := $(BUILDROOT)/mittos.iso | DIST := $(BUILDROOT)/mittos.iso | ||||||
| SYSROOT := $(BUILDROOT)/sysroot | SYSROOT := $(BUILDROOT)/sysroot | ||||||
|  | SYS_ITEMS := $(SYSROOT)/kernel | ||||||
| 
 | 
 | ||||||
| $(DIST): $(SYSROOT)/kernel | all: $(SYSROOT)/kernel | ||||||
|  | 
 | ||||||
|  | dist: $(DIST) | ||||||
|  | 
 | ||||||
|  | $(DIST): $(SYS_ITEMS) | ||||||
| 	$(BUILDROOT)/toolchain/setup-grub.sh | 	$(BUILDROOT)/toolchain/setup-grub.sh | ||||||
| 	grub-mkrescue -o $@ $(SYSROOT) | 	grub-mkrescue -o $@ $(SYSROOT) | ||||||
| 
 | 
 | ||||||
| @ -17,7 +22,7 @@ ifeq ($(shell make -sqC src/kernel || echo 1), 1) | |||||||
| 	$(KERNELMAKE) install | 	$(KERNELMAKE) install | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| .PHONY: FORCE | .PHONY: all dist sysroot FORCE | ||||||
| 
 | 
 | ||||||
| clean: | clean: | ||||||
| 	rm -rf $(DIST) | 	rm -rf $(DIST) | ||||||
|  | |||||||
| @ -21,10 +21,9 @@ import os | |||||||
| gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel') | gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel') | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | # Inspect registers with `reg RAX` or just `reg` | ||||||
| python | python | ||||||
| 
 |  | ||||||
| import re | import re | ||||||
| 
 |  | ||||||
| class Reg(gdb.Command): | class Reg(gdb.Command): | ||||||
| 
 | 
 | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
| @ -52,6 +51,27 @@ class Reg(gdb.Command): | |||||||
|                 print(matches[0]) |                 print(matches[0]) | ||||||
|             else: |             else: | ||||||
|                 print(f"Register {arg.upper()} unknown") |                 print(f"Register {arg.upper()} unknown") | ||||||
| 
 |  | ||||||
| Reg() | Reg() | ||||||
| end | 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 | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user