Skip to content

Commit

Permalink
lib: improve trace
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 18, 2024
1 parent 9cb2bdf commit 3d78611
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/isa/instr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pub enum CmpOp {
St(MergeFlag, RegA, Reg8),

/// Inverses value in `st0` register
#[display("inv st0")]
#[display("inv st0")]
StInv,
}

Expand Down
10 changes: 6 additions & 4 deletions src/library/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl Lib {
let mut reader = Cursor::with(&self.code, &self.data, &self.libs);
while !reader.is_eof() {
let pos = reader.offset().0 as usize;
write!(writer, "offset_0x{pos:04X}: ")?;
write!(writer, "@x{pos:06X}: ")?;

Check warning on line 327 in src/library/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/library/lib.rs#L327

Added line #L327 was not covered by tests
match Instr::<Isa>::decode(&mut reader) {
Ok(instr) => writeln!(writer, "{instr}")?,
Err(_) => writeln!(writer, "\n{}", ByteStr::with(&self.code.as_ref()[pos..]))?,
Expand Down Expand Up @@ -384,7 +384,9 @@ impl Lib {
);

let mut cursor = Cursor::with(&self.code, &self.data, &self.libs);
let lib_hash = self.id();
let lib_id = self.id();
#[cfg(feature = "log")]
let lib_mnemonic = lib_id.to_baid64_mnemonic().split_off(5);
if cursor.seek(entrypoint).is_err() {
registers.st0 = false;
#[cfg(feature = "log")]
Expand All @@ -402,14 +404,14 @@ impl Lib {

#[cfg(feature = "log")]
{
eprint!("{m}@{pos:06}:{z} {: <32}; ", instr.to_string());
eprint!("{m}{}@x{pos:06X}:{z} {: <32}; ", lib_mnemonic, instr.to_string());
for reg in instr.src_regs() {
let val = registers.get(reg);
eprint!("{d}{reg}={z}{w}{val}{z} ");
}
}

let next = instr.exec(registers, LibSite::with(pos, lib_hash), context);
let next = instr.exec(registers, LibSite::with(pos, lib_id), context);

#[cfg(feature = "log")]
{
Expand Down

0 comments on commit 3d78611

Please sign in to comment.