Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

add support for all ITM packet types and replace Decoder with Stream parser #24

Merged
merged 1 commit into from
Aug 10, 2019

Conversation

japaric
Copy link
Member

@japaric japaric commented Jan 20, 2019

as this is a breaking change and requires a minor version bump, this commit
also:

  • sets MSRV to 1.31.0
  • changes the crate edition to 2018
  • removes itmdump (more info below)

The rationale for dropping the existing Decoder API is that it doesn't handle
well streams of data that contain errors, like missing bytes (occurs in ~0.2% of
packets according to my unscientific measurements). Namely, Decoder can't
backtrack the stream because it has no internal buffer; meaning that once a byte
is lost it will continue to parse packets with an offset of one (i.e. the first
byte of the payload will be treated as the packet header) leading to a cascade
of errors.

The Stream API has an internal buffer so when it encounters a packet error due
to a missing byte it can backtrack the stream and retry parsing from the most
likely place. Also, thanks to the internal buffer Stream greatly reduces the
number of read syscalls -- the Decoder API was doing 1-byte read syscalls in
some places.

(For historic purposes, I have pushed the branch where I was adding full
parsing support to the Decoder API)

With this new API and support for all the different ITM packets I have created a
set of tools (itm-tools) for analyzing ITM traces. One of the tools,
port-demux, is a more general version of itmdump and should be preferred
over it. The other reason for removing itmdump and not providing tools in this
crate is that it makes version management easier: breaking changes in the
library don't necessarily mean breaking changes in the tool CLI.

r? @rust-embedded/tools
cc @rust-embedded/cortex-m

…parser

as this is a breaking change and requires a minor version bump, this commit
also:

- sets MSRV to 1.31.0
- changes the crate edition to 2018
- removes `itmdump`
@korken89
Copy link

korken89 commented Feb 5, 2019

Sorry for the late reply!

Overall I like this update, I have had strange things happen with ITM before but never looked into it. With this change we should be getting closer to production ready tools in this area, great job!

@japaric
Copy link
Member Author

japaric commented Feb 8, 2019

@rust-embedded/tools any thoughts about this PR?

@Disasm Disasm added T-tools S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Feb 26, 2019
@therealprof
Copy link
Contributor

therealprof commented Mar 6, 2019

I don't have time to test ATM but it looks good.

@korken89
Copy link

@rust-embedded/tools time to move this forward?

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Aug 10, 2019
24: add support for all ITM packet types and replace Decoder with Stream parser r=therealprof a=japaric

as this is a breaking change and requires a minor version bump, this commit
also:

- sets MSRV to 1.31.0
- changes the crate edition to 2018
- removes `itmdump` (more info below)

---

The rationale for dropping the existing `Decoder` API is that it doesn't handle
well streams of data that contain errors, like missing bytes (occurs in ~0.2% of
packets according to my unscientific measurements). Namely, `Decoder` can't
backtrack the stream because it has no internal buffer; meaning that once a byte
is lost it will continue to parse packets with an offset of one (i.e. the first
byte of the payload will be treated as the packet header) leading to a cascade
of errors.

The `Stream` API has an internal buffer so when it encounters a packet error due
to a missing byte it can backtrack the stream and retry parsing from the most
likely place. Also, thanks to the internal buffer `Stream` greatly reduces the
number of read syscalls -- the `Decoder` API was doing 1-byte read syscalls in
some places.

(For historic purposes, I have pushed [the branch] where I was adding full
parsing support to the `Decoder` API)

[the branch]: https://github.com/rust-embedded/itm/tree/decoder

With this new API and support for all the different ITM packets I have created a
set of tools ([`itm-tools`]) for analyzing ITM traces. One of the tools,
`port-demux`, is a more general version of `itmdump` and should be preferred
over it. The other reason for removing `itmdump` and not providing tools in this
crate is that it makes version management easier: breaking changes in the
library don't necessarily mean breaking changes in the tool CLI.

[`itm-tools`]: https://github.com/japaric/itm-tools

r? @rust-embedded/tools
cc @rust-embedded/cortex-m

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
@bors
Copy link
Contributor

bors bot commented Aug 10, 2019

Build succeeded

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants