Add a primitive debug tracing facility.

When the CRETONNE_DBG environment variable is set, send debug messages
to a file named cretonne.dbg.*.

The trace facility is only enabled when debug assertions are on.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-15 11:04:38 -07:00
parent d86854b286
commit 210530da9c
6 changed files with 111 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
#[macro_use(dbg)]
extern crate cretonne;
extern crate cton_reader;
extern crate docopt;

View File

@@ -137,6 +137,10 @@ fn worker_thread(thread_num: usize,
}
});
if let &Err(ref msg) = &result {
dbg!("FAIL: {}", msg);
}
replies.send(Reply::Done {
jobid: jobid,
result: result,

View File

@@ -17,6 +17,7 @@ use filetest::subtest::{SubTest, Context, Result};
///
/// If running this test causes a panic, it will propagate as normal.
pub fn run(path: &Path) -> TestResult {
dbg!("---\nFile: {}", path.to_string_lossy());
let started = time::Instant::now();
let buffer = read_to_string(path).map_err(|e| e.to_string())?;
let testfile = parse_test(&buffer).map_err(|e| e.to_string())?;
@@ -108,6 +109,7 @@ fn run_one_test<'a>(tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
-> Result<()> {
let (test, flags, isa) = tuple;
let name = format!("{}({})", test.name(), func.name);
dbg!("Test: {} {}", name, isa.map(TargetIsa::name).unwrap_or("-"));
context.flags = flags;
context.isa = isa;