10000 Merge pull request #69 from brandonros/trace-to-file · sha0coder/libscemu@af7253a · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit af7253a

Browse files
authored
Merge pull request #69 from brandonros/trace-to-file
trace to file
2 parents d3f3a91 + de1f04c commit af7253a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2459
-2315
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ scan_fmt = "0.2.6"
2323
atty = "0.2.14"
2424
csv = "1.3.0"
2525
chrono = { version = "0.4", features = ["serde"] }
26+
log = "0.4.22"

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ while emu.step() {
6161
}
6262

6363
// check result
64-
println!("return value: 0x{:x}", emu.regs.get_eax());
64+
log::info!("return value: 0x{:x}", emu.regs.get_eax());
6565
emu.maps.dump(param2_out_buff);
6666
```
6767

@@ -77,28 +77,28 @@ use iced_x86::{Instruction};
7777

7878
fn trace_memory_read(emu:&mut libscemu::emu::Emu, ip_addr:u64,
7979
mem_addr:u64, sz:u8) {
80-
println!("0x{:x}: reading {} at 0x{:x}", ip_addr, sz, mem_addr);
80+
log::info!("0x{:x}: reading {} at 0x{:x}", ip_addr, sz, mem_addr);
8181
if mem_addr == 0x22dff0 {
8282
emu.stop();
8383
}
8484
}
8585

8686
fn trace_memory_write(emu:&mut libscemu::emu::Emu, ip_addr:u64,
8787
mem_addr:u64, sz:u8, value:u128) -> u128 {
88-
println!("0x{:x}: writing {} '0x{:x}' at 0x{:x}", ip_addr, sz,
88+
log::info!("0x{:x}: writing {} '0x{:x}' at 0x{:x}", ip_addr, sz,
8989
value, mem_addr);
9090
value // I could change the value to write
9191
}
9292

9393
fn trace_interrupt(emu:&mut libscemu::emu::Emu, ip_addr:u64,
9494
interrupt:u64) -> bool {
95-
println!("interrupt {} triggered at eip: 0x{:x}", interrupt,
95+
log::info!("interrupt {} triggered at eip: 0x{:x}", interrupt,
9696
ip_addr);
9797
true // do handle interrupts
9898
}
9999

100100
fn trace_exceptions(emu:&mut libscemu::emu::Emu, ip_addr:u64) -> B41A bool {
101-
println!("0x{:x} triggered an exception", ip_addr);
101+
log::info!("0x{:x} triggered an exception", ip_addr);
102102
true // do handle exceptions
103103
}
104104

@@ -128,6 +128,6 @@ fn main() {
128128
emu.hook.on_post_instruction(trace_post_instruction);
129129
emu.hook.on_winapi_call(trace_winapi_call);
130130
emu.run(None).unwrap();
131-
println!("end!");
131+
log::info!("end!");
132132
}
133133
```

src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#[derive(Clone)]
21
pub struct Config {
32
pub filename: String, // filename with full path included
43
pub trace_mem: bool, // show memory operations in every step.
@@ -26,6 +25,7 @@ pub struct Config {
2625
pub console_enabled: bool,
2726
pub skip_unimplemented: bool,
2827
pub stack_addr: u64,
28+
pub trace_file: Option<std::fs::File>,
2929
}
3030

3131
impl Config {
@@ -57,6 +57,7 @@ impl Config {
5757
console_enabled: true,
5858
skip_unimplemented: false,
5959
stack_addr: 0,
60+
trace_file: None,
6061
}
6162
}
6263
}

0 commit comments

Comments
 (0)
0