adding instruction log

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-22 22:10:24 +01:00
parent 5b123be9ea
commit 47d727855d
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
5 changed files with 16 additions and 7 deletions

6
Cargo.lock generated
View file

@ -213,12 +213,12 @@ dependencies = [
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
[[package]]
name = "hblang"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
dependencies = [
"hashbrown",
"hbbytecode",
@ -229,7 +229,7 @@ dependencies = [
[[package]]
name = "hbvm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
dependencies = [
"hbbytecode",
]

View file

@ -9,7 +9,7 @@ ktest = []
[dependencies]
# embedded-graphics = "0.8"
hbvm = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [
"nightly",
"nightly", "alloc", "disasm"
] }
ktest_macro = { path = "ktest_macro" }
log = "0.4"

View file

@ -15,8 +15,10 @@ fn calc_start_of_page(ptr: u64) -> u64 {
panic!("unaligned");
}
#[derive(Default)]
pub struct Memory {
// TODO: map page aligned segments of memory into a table or some sort here
logger: hbvm::mem::InstrLogger,
}
impl Memory {
@ -56,4 +58,11 @@ impl hbvm::mem::Memory for Memory {
unsafe fn prog_read<T: Copy>(&mut self, addr: Address) -> T {
(addr.get() as *const T).read()
}
#[inline(always)]
fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) {
//log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
// self.logger.display_instr(at, regs)
//});
}
}

View file

@ -36,7 +36,7 @@ impl ExecThread {
pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self {
let mut vm = Vm::new(
mem::Memory {},
mem::Memory::default(),
Address::new(program.as_ptr() as u64 + entrypoint.get()),
);

View file

@ -3,7 +3,7 @@
test := fn(): uint {
target := "abcdefghijklmnop"
strings := .["abcdefshijklmnop", "abcdefghijklnnop", "abcdefshijklmnop", "abcdefghijklmnop", "abcdefghijflmnop", "dbcdefghijklmnop", "abcdefghijklmnop"]
len := @sizeof(@TypeOf(strings)) / @sizeof(^u8)
len := @sizeof(@TypeOf(strings)) / @sizeof([]u8)
// hasher := hashers.foldhash.FoldHasher.new(1)
hasher := hashers.foldhash.FoldHasher.default()
@ -23,4 +23,4 @@ test := fn(): uint {
}
log.print("done", .{})
return 0
}
}