search_bodies
Find code patterns inside function bodies (e.g., .attach, callback) to locate implementation logic, filtering out vendor code for app-only results.
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): function call patterns (.attach(,.rise(,.fall(,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 — code your team wrote.
Vendor SDK — 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.
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 callback attachments, timer registrations, 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 and return only
application code. 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. | |
| image | No | Sysbuild image name within the variant (multi-project). Omit for all images of the variant. | |
| limit | No | Maximum results (default 20, max 100). | |
| query | Yes | FTS5 search terms for function bodies. 1-3 words. E.g. 'attach', 'callback', 'rise'. | |
| variant | No | Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants. | |
| project_only | No | Exclude vendor SDK code. When True, only application code. Default False. | |
| project_root | No | Project root. Auto-detected if omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |