Skip to content

Conversation

@jreineckearm
Copy link
Collaborator

@jreineckearm jreineckearm commented Aug 13, 2025

Fixes

Changes

Note: Automated tests are still TODO.

  • Functionality
    • Enables CPU time features if launch/attach config contains cmsis setting(s). And if an enabled DWT CYCCNT is found for the session (connected CPU).
    • Adds status bar item showing CPU execution time/states.
      • Shows active pname for multi-core sessions.
      • Shows time if frequency can be read from program variable SystemCoreClock, otherwise states/cycles.
image image
  • Click on status bar item opens quickpick with commands for current CPU context.
    • CPU Time : Print the current time + diffs to up to 5 previous stops.
    • Reset CPU Time : Reset the current time to 0 and clear the history.
image image image
  • Both commands are also available through command palette in category Run and Debug.
image

Known Limitations

  • Execution time starts capturing from first CPU pause in IDE. Which by default is at main.
  • Triggers for reading SystemCoreClock needs another review. Currently happening twice on some occasions to keep status bar item updates going without source code. This can sometimes cause some flickering.
  • Frequency values not stored with history which can lead to differing time values if clock value in SystemCoreClock changes.
  • Time display does not separate magnitudes of a thousand by , and does not go beyond milliseconds.

Most limitations are addressable. Probably in further commits to this PR.

Implementation Details

  • Adds the following subfolders
    • debug-session: Modules around tracking debug sessions and communicating with session resources.
      • gdb-target-tracker: Moved from debug-configuration folder, debug tracker dispatching events and requests/responses of interest through event emitter.
      • gdbtarget-debug-session: Session wrapper with cached *.cbuild-run.yml content, some convenience functions to read memory and evaluate global variables.
    • features/cpu-states: Modules to manage DWT CYCCNT reads for different sessions, and to derive current CPU execution states/time and diff history between stops. Reads through Debug Adapter Protocol memory requests.
      • cpu-states: Manages reads and updates.
      • cpu-states-history: Manages history for a single session.
      • cpu-states-statusbar-item: GUI element to show CPU Time/States in status bar, and that shows command QuickPick on click. Adjust to active session.
      • cpu-states-commands: Commands registered to command palette and to QuickPick. Adjust to active session.
  • Extends utils.ts with rudimentary time calculation function
  • Adds package @vscode/debugprotocol v1.68.0 as dev dependency

Screenshots

Without frequency

image

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

@qltysh
Copy link

qltysh bot commented Aug 13, 2025

All good ✅

@qltysh
Copy link

qltysh bot commented Aug 13, 2025

Diff Coverage: The code coverage on the diff in this pull request is 93.0%.

Total Coverage: This PR will increase coverage by 0.01%.

File Coverage Changes
Path File Coverage Δ Indirect
src/debug-configuration/debug-configuration.factory.ts 2.7
src/debug-configuration/gdbtarget-debug-tracker.ts -85.7
src/debug-session/constants.ts 100.0
src/debug-session/gdbtarget-debug-session.ts 97.6
src/debug-session/gdbtarget-debug-tracker.ts 92.4
src/debug-session/index.ts 100.0
src/features/cpu-states/cpu-states-commands.ts 87.5
src/features/cpu-states/cpu-states-history.ts 95.5
src/features/cpu-states/cpu-states-statusbar-item.ts 96.8
src/features/cpu-states/cpu-states.ts 89.6
src/utils.ts -2.6
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
@jreineckearm jreineckearm changed the title [WiP] Show CPU states Show CPU Time and History Aug 19, 2025
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
Signed-off-by: Jens Reinecke <[email protected]>
@jreineckearm jreineckearm marked this pull request as ready for review August 28, 2025 13:18
Copy link
Collaborator

@edriouk edriouk left a comment

Choose a reason for hiding this comment

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

LGTM

@jreineckearm jreineckearm merged commit b2298c7 into main Aug 28, 2025
15 checks passed
@jreineckearm jreineckearm deleted the 442-states branch August 28, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants