rtic-scope / cargo-rtic-scope

Non-intrusive ITM tracing/replay toolset for RTIC programs with nanosecond timestamp accuracy.
16 stars 4 forks source link

run_loop: sync select next packet and halt condition #68

Closed tmplt closed 2 years ago

tmplt commented 2 years ago

This commit fixes #64 at the cost of consuming a CPU for the select (if no packet is immediately available, we'll spin on halt). I'll allow this for now; some more performant implementation should be possible, but bug fixing takes precedence over performance improvements.

Less appropriate is a regression: the sources::Source is now converted to a futures::Stream. Because of this we lose access to Source::{avail_buffer, describe}. avail_buffer is only of concern if a TTY is used (and I'm unsure if the implementation is even correct) [0]. describe is only used for error information, but since error reporting is a bit wonky for the moment anyway I'll let it fly.

[0] Remaining avail_buffer impls are trivial except for ProbeSource which is a stub, but probe_rs does not offer the required functions to check the embedded trace buffer on the target yet.

To fix the regression, we either need to convert back and forth between a sources::Source and a futures::Stream --- his would fly if it results in zero additional allocations, but the futures API offers no such function --- or refactor the sources::Source to derive from futures::Stream instead of Iterator. This is a non-trivial refactor: some Pin/Unpin issue with Box yields a lot of type errors I have yet to decode.

Summary: one issue fixed, two more created. These will most likely not fit into the v0.3.0 release window. This commit has only been tested with ProbeSource and FileSource. The former is the most complex, and the remaining sources are FileSource look-alikes. I'm sure the rest work. v0.3.0 only requires that these two work in any case.