Merge pull request 'adding disasembly in case something goes wrong' (#1) from mlokis/ableos-framebuffer:disasm into master

Reviewed-on: https://git.ablecorp.us/koniifer/ableos-framebuffer/pulls/1
This commit is contained in:
koniifer 2024-09-04 17:32:19 +00:00
commit 63e2f546c5
4 changed files with 19 additions and 7 deletions

6
Cargo.lock generated
View file

@ -444,7 +444,7 @@ dependencies = [
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
[[package]]
name = "hbbytecode"
@ -454,7 +454,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#894f73ca35199f524dff616
[[package]]
name = "hblang"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
dependencies = [
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
]
@ -462,7 +462,7 @@ dependencies = [
[[package]]
name = "hbvm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#894f73ca35199f524dff6160c57c0916169fbaf6"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d9aab2191b57d4c9fa5a57e70c38039e605ad741"
dependencies = [
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
]

View file

@ -74,7 +74,7 @@ pub fn handler(vm: &mut Vm) {
match buffer_id {
0 => match sds_msg_handler(vm, mem_addr, length) {
Ok(()) => {}
Err(err) => log::error!("Improper sds format"),
Err(err) => log::error!("Improper sds format: {err:?}"),
},
1 => match log_msg_handler(vm, mem_addr, length) {
Ok(()) => {}
@ -285,6 +285,7 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE
#[derive(Debug)]
pub enum LogError {
NoMessages,
InvalidLogFormat,
}
use {alloc::vec, log::Record};

View file

@ -23,6 +23,9 @@ pub static SERVICES: Lazy<Mutex<Services>> = Lazy::new(|| {
pub fn sds_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
let mut msg_vec = block_read(mem_addr, length);
if msg_vec.is_empty() {
return Err(LogError::NoMessages);
}
let sds_event_type: ServiceEventType = msg_vec[0].into();
msg_vec.remove(0);

View file

@ -85,9 +85,17 @@ impl Package {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!("{}", e),
}
let path = format!("target/programs/{}.hbf", self.name);
let mut file = File::create(path).unwrap();
file.write_all(&bytes).unwrap();
std::fs::write(format!("target/programs/{}.hbf", self.name), &bytes).unwrap();
bytes.clear();
let _ = hblang::run_compiler(
&path,
Options {
dump_asm: true,
..Default::default()
},
&mut bytes,
);
std::fs::write(format!("target/programs/{}.hba", self.name), &bytes).unwrap();
}
}
}