search_bodies
Search function bodies in C/C++ source to find implementation patterns like .attach() or NVIC_SetVector(). Returns highlighted excerpts showing each match.
Instructions
Find patterns in C/C++ function BODIES — the implementation code inside { }.
Searches ONLY the text between { and } of function/method
definitions. Does NOT search file-scope constructs (see Limitations
below).
When to use search_bodies vs search_code:
search_bodies— patterns in function BODIES (what the code DOES):.attach(,NVIC_SetVector(,.rise(,.fall(,SerialBase::RxIrq,callback(&, ISR registration code.search_code— find symbols by NAME (what the code IS):modem init,interrupt handler,uart send.
Limitations — what search_bodies CANNOT find:
Only function/method definition bodies are indexed (is_definition=1
symbols with source text). The following are at FILE SCOPE and are
NEVER in the source column:
extern "C"— linkage specifier at file scopeType declarations in headers —
InterruptIn _pin;in class bodies#include,#define,#ifdef— preprocessor directivesGlobal/static variable definitions outside functions
Namespace declarations
Any code outside
{ }of a function definition
LIMITATION — search_bodies ONLY searches function bodies ({ }):
If your pattern might be at file scope (class member declarations like
InterruptIn _pin, function declarations, #define, extern "C",
global variables), use search_content instead. search_bodies returns
empty for any pattern outside function bodies.
For these patterns, use search_content which indexes full file
content (not limited to function bodies).
When to set project_only=True:
Your project contains two kinds of code:
Application code:
src/,lib/— code your team wrote.Vendor SDK:
mbed-os/,.pio/,zephyr/,build/— framework/OS code shipped by a vendor, NOT written by your team.
Set project_only=True when the question is about YOUR code
("where do we register interrupt handlers?",
"which functions call .attach()?"). Leave it False (default)
when the vendor code is also relevant ("how does mbed's Ticker::attach work?").
Results include _match_snippet — a highlighted excerpt showing
each match in context (e.g. _timeout.<b>attach</b>(callback(...))).
Project code sorts before vendor code in the output.
Read-only. No side effects. Requires the FTS5 index.
Args:
query: FTS5 search terms. 1-3 words. Bare multi-word queries are
OR-joined (each term prefixed with *). Prefer single-word
queries for broad matching: 'attach' finds .attach(...)
patterns including Ticker::attach, Timeout::attach, etc.
For exact phrases wrap in double quotes: '"attach callback"'.
project_root: Project root. Auto-detected if omitted.
kind: Optional filter to return only symbols of this kind.
limit: Maximum results (default 20, max 100).
project_only: When True, exclude vendor SDK directories
(mbed-os/, .pio/, zephyr/, build/) and return only
application code (src/, lib/). Default False.
Returns: list of dicts, each with: name, qualified_name, kind, file, line, is_definition, signature, _match_snippet (excerpt around match), source (function body, truncated at 2000 chars).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Optional kind filter: function, method, class, etc. | |
| limit | No | Maximum results (default 20, max 100). | |
| query | Yes | FTS5 search terms for function bodies. 1-3 words. E.g. 'attach', 'NVIC_SetVector', 'rise'. | |
| project_only | No | Exclude vendor SDK code (mbed-os/, .pio/, zephyr/, build/). When True, only your application code (src/, lib/). Default False. | |
| project_root | No | Project root. Auto-detected if omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |