Conversation
04d416d to
64a4332
Compare
|
This does not yet handle displaying printed lines. So far it only makes them available programmatically (example). Marking it as ready for review because I would like to:
|
|
Thanks for this! @mooori
For this, as discussed we should be using In general, the Also, please rebase on to the latest |
Probably...to avoid it I've changed
The PR is based on latest next, maybe the changes you mean are in
Added a comment regarding DAP and REPL in #55 |
7c99d55 to
3389c9e
Compare
bitwalker
left a comment
There was a problem hiding this comment.
Nice work! I have a few changes I'd like to make before we merge this, some of which we talked about on Monday, but overall LGTM! 👍
| host.register_assert_failed_tracer(move |clk, event| { | ||
| assertion_events.borrow_mut().insert(clk, event); | ||
| }); | ||
| let printed_lines: Rc<RefCell<BTreeMap<RowIndex, String>>> = Rc::new(Default::default()); |
There was a problem hiding this comment.
Rather than capturing printed strings this way, I would simply log them in the trace handler, like so:
log::log!(target: "stdout", Level::Info, "{content}");We could potentially also emit log metadata that attaches the current procedure name (if known) to each logged print statement, but that's probably not needed for the time being.
This will get picked up by the TUI debug log window, and also get output when trace logs are enabled in our test suite.
For testing this functionality, you can install the DebugLogger as the log handler, run a program that emits some trace lines, and then do:
let entries = DebugLogger::get().take_captured();
let prints = entries.iter().filter_map(|entry| if entry.target == "println" { Some(&entry.message) } else { None }).collect::<Vec<_>>();Then assert whatever you want about the printed messages.
There was a problem hiding this comment.
I've been getting more familiar with the TUI and I noticed that DebugPane shows everything that was logged. Probably that's on purpose and I can see how that's helpful when working on the debugger itself.
For someone using the debugger to inspect their program, I would imagine that they only want to see what they passed into println. Seeing internal state updates and other internal logs might be confusing for them.
So I've been wondering: Should we add another pane that only shows messages logged via println? If yes, the println messages could be obtained by:
- filtering the content of
DebugLogger - storing
printed_lines; as currently done or in some other way
Another way of filtering would be setting a log level, e.g. running the debugger with RUST_LOG=info. Though that's another step to take for the end user.
Seems like even with RUST_LOG=info the DebugPane contains messages with lower prio such as debug. I have to double check and will open an issue if that's the case.
There was a problem hiding this comment.
We use MIDENC_TRACE, not RUST_LOG - but in any case, I do think it could be worthwhile to have another debug-like window that shows just log entries whose target is stdout.
Or perhaps, it would be better still to have the default display of the debug window already be filtering for the stdout target, and provide keys to toggle the filtering - that way we can largely re-use the existing functionality, but make it more useful. I'd kinda prefer to avoid adding a bunch of panes and windows if existing ones can be extended to provide the same functionality in an ergonomic way.
|
I've addressed the review comments and opened #60 for The Tests have been ported to work with The tests in the compiler will need to be reworked too, as now they no longer have direct access to Previously |
|
Just saw that there's a minor conflict with |
bitwalker
left a comment
There was a problem hiding this comment.
Just about there! I think we can simplify things a bit by using integration tests instead of unit tests, so as to avoid the complexities around concurrent testing with a global resource like the logger.
|
I've addressed the review comments. Making the
|
println-style output via a newTRACE_PRINT_LNtrace event, with decoding of[address, length]from the VM stack and reading the corresponding UTF-8 bytes from memory.ProcessorStateinstead of just the cycle, which lets the host capture trace events and read string-bytes from memory.ExecutionTrace, exposing it asprinted_lines()keyed by cycle.Companion PR in the compiler: 1077