From 643eb8510a832690d4cea98e8479e7a0cd7367ed Mon Sep 17 00:00:00 2001 From: "Cliff L. Biffle" Date: Mon, 29 Jun 2020 11:41:32 -0700 Subject: [PATCH 1/3] itm: mark stimulus port of any output. --- src/main.rs | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7348b2031..01b91d45e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) => ({ @@ -917,6 +917,8 @@ 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(); @@ -924,21 +926,49 @@ fn itmcmd_ingest_attached( } 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(()) }) } From 41c99aeb5a2a536f33bb356aeb4799df180a4aee Mon Sep 17 00:00:00 2001 From: "Cliff L. Biffle" Date: Mon, 29 Jun 2020 11:42:40 -0700 Subject: [PATCH 2/3] itm: enable the stim ports used by hubris tests --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 01b91d45e..9fe842cd9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1050,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); } From fb6a9f87e226543ca7bdca45cfea3aff25e9b9a1 Mon Sep 17 00:00:00 2001 From: "Cliff L. Biffle" Date: Mon, 29 Jun 2020 11:43:51 -0700 Subject: [PATCH 3/3] Add .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..64537affa --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +.sw? +.*.sw?