Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
.sw?
.*.sw?
47 changes: 39 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use std::convert::TryInto;
use std::time::Instant;
use std::time::SystemTime;
use std::collections::HashMap;
use std::io::Read;
use std::io::{Read, Write};

macro_rules! fatal {
($fmt:expr) => ({
Expand Down Expand Up @@ -917,28 +917,58 @@ fn itmcmd_ingest_attached(

let start = Instant::now();

let mut last_port = None;

itm_ingest(traceid, || {
while ndx == bytes.len() {
bytes = core.read_swv().unwrap();
ndx = 0;
}
ndx += 1;
Ok(Some((bytes[ndx - 1], start.elapsed().as_secs_f64())))
}, |packet| {
}, move |packet| {
match &packet.payload {
ITMPayload::Instrumentation { payload, port } => {
if *port > 1 {
println!("{:x?}", payload);
if *port > 16 {
if last_port.is_some() {
// Terminate any labeled output
println!("\\");
last_port = None;
}
println!("{:02x}|{:x?}", port, payload);
return Ok(());
}

for p in payload {
print!("{}", *p as char);
if let Some(lp) = last_port {
// We've been producing output for a particular port.
if &lp == port {
// And that doesn't need to change.
} else {
// And we need to call it off.
println!("\\");
print!("{:02x}|", port);
last_port = Some(*port);
}
}

for &p in payload {
if last_port.is_none() {
print!("{:02x}|", port);
last_port = Some(*port);
}
print!("{}", p as char);
if p == b'\n' {
last_port = None;
}
}
}
_ => {}
}

// Ensure that we get output even if it stops before the newline.
// Tolerate failure.
std::io::stdout().flush().ok();

Ok(())
})
}
Expand Down Expand Up @@ -1020,9 +1050,10 @@ fn itmcmd(
}

/*
* By default, we enable all logging (ports 0-7).
* By default, we enable all logging (ports 0-7) and test-related output
* (ports 8-11).
*/
let stim = 0x0000_000f;
let stim = 0x0000_0f0f;
rval = itmcmd_enable(core.as_mut(), subargs.clockscaler, traceid, stim);
}

Expand Down