Skip to content

Commit

Permalink
Support custom printf events
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Aug 6, 2024
1 parent 7153a97 commit 616da0c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
21 changes: 15 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "modality-trace-recorder-plugin"
version = "0.29.0"
version = "0.30.0"
edition = "2021"
authors = ["Jon Lamb <[email protected]>"]
description = "A Modality reflector plugin suite and ingest adapter library for Percepio's TraceRecorder data"
Expand Down Expand Up @@ -49,14 +49,15 @@ itm = "0.9.0-rc.1"
probe-rs = { git = "https://github.com/auxoncorp/probe-rs.git", branch = "s32k344_0.23.0" }
goblin = "0.8"
clap = { version = "4.5", features = ["derive", "env", "color"] }
clap-num = "1.1"
ctrlc = { version = "3.4", features=["termination"] }
exitcode = "1"
ratelimit = "0.9"
bytes = "1"
human_bytes = "0.4"
simple_moving_average = "1.0"
auxon-sdk = { version = "1.3", features = ["modality"] }
trace-recorder-parser = "0.17.0"
trace-recorder-parser = "0.19.0"

[dev-dependencies]
tempfile = "3.10"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ These sections are the same for each of the plugins.
- `disable-task-interactions` — Don't synthesize interactions between tasks and ISRs when a context switch occurs.
- `use-timeline-id-channel` — Detect task/ISR timeline IDs from the device by reading events on the `modality_timeline_id` channel (format is `name=<obj-name>,id=<timeline-id>`).
- `deviant-event-id-base` — Parse Deviant custom events using the provided base event ID.
- `custom-printf-event-id` — Parse custom printf events using the provided event ID. See the [reference implementation](https://github.com/auxoncorp/trace-recorder-parser/blob/master/test_resources/src/streaming/v14/custom_printf_event.c) for the event layout.
- `include-unknown-events` — Include unknown events instead of ignoring them.
- `ignored-object-classes` — Array of object classes to ignore processing during ingest (e.g. `[queue, semaphore]`)
- `user-event-channel` — Instead of `USER_EVENT @ <task-name>`, use the user event channel as the event name (`<channel> @ <task-name>`).
Expand Down
1 change: 1 addition & 0 deletions src/bin/rtt_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct Opts {
/// Use the provided RTT control block address instead of scanning the target memory for it.
#[clap(
long,
value_parser=clap_num::maybe_hex::<u32>,
name = "control-block-address",
help_heading = "STREAMING PORT CONFIGURATION"
)]
Expand Down
11 changes: 11 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct PluginConfig {
pub disable_task_interactions: bool,
pub use_timeline_id_channel: bool,
pub deviant_event_id_base: Option<u16>,
pub custom_printf_event_id: Option<u16>,
pub include_unknown_events: bool,
pub ignored_object_classes: IgnoredObjectClasses,
pub user_event_channel: bool,
Expand Down Expand Up @@ -283,6 +284,9 @@ impl TraceRecorderConfig {
deviant_event_id_base: tr_opts
.deviant_event_id_base
.or(cfg_plugin.deviant_event_id_base),
custom_printf_event_id: tr_opts
.custom_printf_event_id
.or(cfg_plugin.custom_printf_event_id),
ignored_object_classes: if !tr_opts.ignore_object_class.is_empty() {
tr_opts.ignore_object_class.clone().into_iter().collect()
} else {
Expand Down Expand Up @@ -395,6 +399,7 @@ mod internal {
pub use_timeline_id_channel: bool,
pub include_unknown_events: bool,
pub deviant_event_id_base: Option<u16>,
pub custom_printf_event_id: Option<u16>,
pub ignored_object_classes: IgnoredObjectClasses,
pub user_event_channel: bool,
pub user_event_format_string: bool,
Expand All @@ -420,6 +425,7 @@ mod internal {
use_timeline_id_channel: c.use_timeline_id_channel,
include_unknown_events: c.include_unknown_events,
deviant_event_id_base: c.deviant_event_id_base,
custom_printf_event_id: c.custom_printf_event_id,
ignored_object_classes: c.ignored_object_classes,
user_event_channel: c.user_event_channel,
user_event_format_string: c.user_event_format_string,
Expand Down Expand Up @@ -735,6 +741,7 @@ metrics = true
elf-file = 'fw.elf'
thumb = true
breakpoint = "main"
custom-printf-event-id = 0x0FA0
[[metadata.user-event-fmt-arg-attr-keys]]
channel = 'stats'
Expand Down Expand Up @@ -813,6 +820,7 @@ breakpoint = "main"
disable_task_interactions: true,
use_timeline_id_channel: false,
deviant_event_id_base: None,
custom_printf_event_id: None,
include_unknown_events: true,
ignored_object_classes: Default::default(),
user_event_channel: true,
Expand Down Expand Up @@ -913,6 +921,7 @@ breakpoint = "main"
disable_task_interactions: true,
use_timeline_id_channel: false,
deviant_event_id_base: None,
custom_printf_event_id: None,
include_unknown_events: true,
ignored_object_classes: Default::default(),
user_event_channel: true,
Expand Down Expand Up @@ -1010,6 +1019,7 @@ breakpoint = "main"
disable_task_interactions: true,
use_timeline_id_channel: true,
deviant_event_id_base: None,
custom_printf_event_id: None,
include_unknown_events: true,
ignored_object_classes: vec![ObjectClass::Queue, ObjectClass::Semaphore]
.into_iter()
Expand Down Expand Up @@ -1120,6 +1130,7 @@ breakpoint = "main"
disable_task_interactions: true,
use_timeline_id_channel: true,
deviant_event_id_base: None,
custom_printf_event_id: Some(0x0FA0),
include_unknown_events: true,
ignored_object_classes: vec![ObjectClass::Queue, ObjectClass::Semaphore]
.into_iter()
Expand Down
10 changes: 10 additions & 0 deletions src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,20 @@ pub struct TraceRecorderOpts {
#[clap(
long,
verbatim_doc_comment,
value_parser=clap_num::maybe_hex::<u16>,
help_heading = "TRACE RECORDER CONFIGURATION"
)]
pub deviant_event_id_base: Option<u16>,

/// Parse custom printf events using the provided event ID.
#[clap(
long,
value_parser=clap_num::maybe_hex::<u16>,
verbatim_doc_comment,
help_heading = "TRACE RECORDER CONFIGURATION"
)]
pub custom_printf_event_id: Option<u16>,

/// Use the provided initial startup task name instead of the default ('(startup)')
#[clap(
long,
Expand Down
6 changes: 6 additions & 0 deletions src/trc_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ pub async fn run<R: Read + Send>(
intr: Interruptor,
) -> Result<(), Error> {
let mut trd = RecorderData::find(&mut r)?;

if let Some(custom_printf_event_id) = cfg.plugin.custom_printf_event_id {
debug!(custom_printf_event_id, "Setting custom printf event ID");
trd.set_custom_printf_event_id(custom_printf_event_id.into());
}

let frequency = trd.timestamp_info.timer_frequency;

if trd.header.kernel_port != KernelPortIdentity::FreeRtos {
Expand Down

0 comments on commit 616da0c

Please sign in to comment.