Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug.inc to check code buffer #74

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DEV_DOCKER_FILE ?= dev.Dockerfile
DEV_IMAGE ?= blue-dev

IN_DEV_CONTAINER ?= docker exec $(DEV_CONTAINER)
DISASM ?= $(IN_DEV_CONTAINER) objdump $(ARGS) -D -M intel -m i386:x86-64
DISASM ?= $(IN_DEV_CONTAINER) objdump -D -M intel -m i386:x86-64 $(ARGS)

FASM ?= fasm

Expand All @@ -36,9 +36,17 @@ run:
dis:
$(DISASM) $(WHAT)

disb: ARGS=-b binary
disb: dis
@true

discb: WHAT=code_buffer_dump.out
discb: disb
@true

clean:
rm -f $(BLUE) *.out

.PHONY:
dev-env dev-start dev-stop \
compile run dis clean
compile run dis disb discb clean
3 changes: 3 additions & 0 deletions blue.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include "flow.inc"
include "parser.inc"
include "to_number.inc"
include "kernel.inc"
include "debug.inc"

entry $
call kernel_init
Expand All @@ -28,6 +29,8 @@ entry $

cmp eax, SUCCESS
jne .exit

call dump_code_buffer

;
; write the output to ./a.out
Expand Down
1 change: 1 addition & 0 deletions blue_test.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include "dictionary.inc"
include "flow.inc"
include "kernel.inc"
include "elf.inc"
include "debug.inc"

macro t what {
inc [test_num]
Expand Down
23 changes: 0 additions & 23 deletions code_buffer_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,3 @@ check_code_buffer:
call dump_code_buffer
jmp failure

dump_code_buffer:
mov rdi, _code_buffer_dump_file
mov esi, 0x01 or 0x40 or 0x200
mov edx, 0x1ed
mov eax, SYS_OPEN
syscall

mov rdi, rax
mov rsi, [_code_buffer.base]
mov rdx, [_code_buffer.here]
sub rdx, rsi
mov eax, SYS_WRITE
syscall

mov eax, SYS_CLOSE
syscall

ret

_code_buffer_dump_file:
db "code_buffer_dump.out"
db 0x00

23 changes: 23 additions & 0 deletions debug.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

dump_code_buffer:
mov rdi, _code_buffer_dump_file
mov esi, 0x01 or 0x40 or 0x200
mov edx, 0x1ed
mov eax, SYS_OPEN
syscall

mov rdi, rax
mov rsi, [_code_buffer.base]
mov rdx, [_code_buffer.here]
sub rdx, rsi
mov eax, SYS_WRITE
syscall

mov eax, SYS_CLOSE
syscall

ret

_code_buffer_dump_file:
db "code_buffer_dump.out"
db 0x00
18 changes: 16 additions & 2 deletions kernel_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ kernel_test:

call kernel_deinit

tc1 user_one_byte

tc1 one_byte
tc1 two_bytes
tc1 one_byte_base16
tc1 clean_exit
tc1 user_one_byte
tc1 user_empty_words

tc2 bogus

Expand Down Expand Up @@ -211,3 +210,18 @@ entry_18:
.expected:
dd 0x12

user_empty_words:
.blue:
db '16 base '
db '90 b, 90 b, 90 b, '
db ': x ; '
db ': y ; '
db ': z ; '
db 'x y z '
.blue_length = $ - .blue

.expected:
db 0x90, 0x90, 0x90
db 0xc3, 0xc3, 0xc3
.expected_length = $ - .expected

Loading