Skip to main content
Glama

sample_pc

Profile STM32 firmware while the core runs by sampling the program counter over SWD with DWT; get a symbolized hot-spot histogram to find time-heavy functions or stuck loops.

Instructions

Statistical PC profiler: enables DWT and samples the program counter while the core RUNS (non-intrusive, over SWD — no SWO pin or firmware change). Returns a symbolized hot-spot histogram (top functions by %), not raw hex — the fast way to find where firmware spends time or what loop it is stuck in. A high 'unsampleable' count means the core is halted/asleep; a high 'zero_samples' count means nothing was profiled at all. Leave enable=true: GDB cannot write the enable bit while the core runs, so this halts briefly to set it and resumes, and only when it is not already set. Note some links cannot serve memory reads while the core runs at all (measured: OpenOCD + ST-Link + STM32L1) — there PC sampling is unavailable and the result says so rather than inventing a hot spot.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of samples (default 128; more = better statistics, slower).
enableNoEnable DWT trace before sampling (default true). With false, a target whose trace unit is off yields nothing.
sessionNoOptional debug-session name. Omit for the default target.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.15.1

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare the safety flags; the description adds the behaviors that matter: brief halt to set the DWT enable bit, non-intrusive SWD sampling with no SWO pin or firmware change, interpretation of 'unsampleable' vs 'zero_samples' results, and a documented link limitation where it reports unavailability instead of fabricating samples.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense and front-loaded: purpose, return format, and diagnostic interpretation come first, then the enable guidance and edge-case caveat. It is long for a 3-param tool, but each sentence carries distinct operational information rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description carries the return-value burden and does so: it names the symbolized hot-spot histogram, explains the diagnostic counters, and describes the failure mode. For a complex sampling tool with unusual failure states, nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning for 'enable' — that GDB cannot write the enable bit while the core runs, so it halts briefly and only when the bit is not already set. That is semantics beyond the schema text, though 'count' and 'session' add nothing new.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Statistical PC profiler … samples the program counter while the core RUNS') and immediately names its distinguishing output ('symbolized hot-spot histogram … not raw hex'). An agent can tell this apart from halt-based siblings like read_call_stack or halt_execution without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear context for when to reach for it ('the fast way to find where firmware spends time or what loop it is stuck in') and conditions that make it unusable (links that cannot serve memory reads while running). It stops short of explicitly naming the alternative profiling/halt tools it replaces, so it is clear but not fully routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.