From 95ac0286749b3f12df9ca4c3e3b3ae4bdc722534 Mon Sep 17 00:00:00 2001
From: Per <Per Lindgren>
Date: Fri, 17 Nov 2017 00:23:44 +0100
Subject: [PATCH] condintonal breakpoints
---
.vscode/launch.json | 17 +++++++++++++++++
.vscode/tasks.json | 24 ++++++++++++++++++++++++
Cargo.toml | 4 ++++
examples/nested.rs | 9 ++++++++-
src/lib.rs | 6 +++++-
5 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/.vscode/launch.json b/.vscode/launch.json
index f74e5c1..9b0e947 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -38,6 +38,23 @@
],
"cwd": "${workspaceRoot}"
},
+ {
+ "type": "gdb",
+ "request": "attach",
+ "name": "Release nested",
+ "gdbpath": "/usr/bin/arm-none-eabi-gdb",
+ "executable": "./target/thumbv7em-none-eabihf/release/examples/nested",
+ "target": ":3333",
+ "remote": true,
+ "autorun": [
+ "monitor reset init",
+ "monitor arm semihosting enable",
+ "monitor tpiu config internal /tmp/itm.log uart off 16000000",
+ "monitor itm port 0 on",
+ "load"
+ ],
+ "cwd": "${workspaceRoot}"
+ },
{
"type": "gdb",
"request": "attach",
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 846c88a..4250bdd 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -27,6 +27,30 @@
"$rustc"
]
},
+ {
+ "label": "xargo build --example nested --features wcet_bkpt",
+ "type": "shell",
+ "command": "xargo build --features \"wcet_bkpt\" --example nested ",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "problemMatcher": [
+ "$rustc"
+ ]
+ },
+ {
+ "label": "xargo build --release --example nested --features wcet_bkpt",
+ "type": "shell",
+ "command": "xargo build --release --features \"wcet_bkpt\" --example nested",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "problemMatcher": [
+ "$rustc"
+ ]
+ },
{
"label": "xargo build --example preemption",
"type": "shell",
diff --git a/Cargo.toml b/Cargo.toml
index b71aaa6..0184c0e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,5 +30,9 @@ git = "https://gitlab.henriktjader.com/pln/STM32F40x"
features = ["rt"]
version = "0.1.0"
+[features]
+wcet_bkpt = []
+
[profile.release]
lto = true
+debug = true
diff --git a/examples/nested.rs b/examples/nested.rs
index 8603496..6aa9ba8 100644
--- a/examples/nested.rs
+++ b/examples/nested.rs
@@ -43,6 +43,7 @@ app! {
fn init(_p: init::Peripherals, _r: init::Resources) {}
+#[inline(never)]
fn idle() -> ! {
// A
rtfm::bkpt();
@@ -59,6 +60,7 @@ fn idle() -> ! {
}
#[allow(non_snake_case)]
+#[inline(never)]
fn exti0(
t: &mut Threshold,
EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resources,
@@ -116,13 +118,18 @@ fn exti0(
// Once again the preemption threshold drops but this time to 1. Now the
// pending `exti1` task can preempt this task
// ~> exti1
+
+ // K
+ rtfm::bkpt();
}
+#[inline(never)]
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {
- // C, I
+ // C, J
rtfm::bkpt();
}
+#[inline(never)]
fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) {
// E, H
rtfm::bkpt();
diff --git a/src/lib.rs b/src/lib.rs
index 4ab8ec5..b62bac3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -85,7 +85,7 @@ extern crate untagged_option;
use core::u8;
pub use rtfm_core::{Resource, Static, Threshold};
-pub use cortex_m::asm::{bkpt, wfi};
+pub use cortex_m::asm::{bkpt, nop, wfi};
pub use cortex_m_rtfm_macros::app;
#[doc(hidden)]
pub use untagged_option::UntaggedOption;
@@ -140,7 +140,11 @@ where
let old = basepri::read();
let hw = (max_priority - ceiling) << (8 - _nvic_prio_bits);
basepri::write(hw);
+ if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
+
+
let ret = f(data, &mut Threshold::new(ceiling));
+ if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();}
basepri::write(old);
ret
}
--
GitLab