find_callers
Find direct and indirect callers of a C/C++ function, including calls via function pointers, callbacks, and struct or array init lists that text search misses.
Instructions
Find who calls a C/C++ function — direct calls AND indirect via
function pointers, callbacks, and struct/array init lists (such as a
vector table that the build generates in C). libclang-powered: detects
function-pointer assignments that text-based search cannot see.
A slot of an assembly vector table (ref_kind "vector") and an
NVIC_SetVector install ("runtime_vector") are not callers: use
find_references or get_vector_table for those. The SDK model
gives the handler of an NVIC_SetVector install a "call" row
from NVIC_SetVector too (origin "sdk", entry "an interrupt").
Falls back to macro lookup when the symbol is not found as a function/method: returns the macro definition (kind="macro") and files that use it (ref_kind="macro_use").
Use when you need a quick, flat list of immediate callers. For the full
transitive call tree (who calls this indirectly through other functions),
use find_all_callers_recursive. For all references including reads
and member accesses, use find_references. For a path between two
specific symbols, use find_call_path.
Read-only. No side effects. Requires the reference index
(fw-context index — refs are on by default). Only direct call
sites are returned; callers more than one hop away are not included.
Indirect edges (ref_kind: "indirect") are detected when a function
pointer references a function through:
Call arguments:
callback(&Class::method, this),EventQueue::call_every(ms, obj, &handler)Assignments:
driver.onData = &handleData,global_cb = &handlerVariable initializers:
static void (*fp)(int) = &handlerStruct/array init lists:
{.on_data = &handler},{&fn_a, &fn_b}
Args:
name: Symbol name to find callers of. Uses the same three-tier
resolution as find_references (exact name, exact qualified,
suffix LIKE).
project_root: Project root directory. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
limit: Maximum results of one page (default 50, max 200).
offset: Skip this many results. Reads the next page of a symbol
with many call sites; the page notice names the offset to use.
variant: Variant of the build (a board, or a PlatformIO
environment). On a project of more than one build, give the
arguments of one build as the refusal lists them: the
variant, the image, or the two. fw-context does not select a
build. One query answers for ONE build.
image: Image of the build: a separate program, such as the
application or the bootloader. Give it when the build has an
image name.
Returns:
The page notice first — total, offset, shown, more
— then a dict per call site with: file, line, col (the column of the
site, 0 when the index has none; two calls on one line are two rows),
ref_kind ("call", "indirect", "implicit_construct", or
"macro_use"), origins (list — the analyses that found the site: "direct", the AST
of the compiler names the target; "asm", the
assembly reader (a call, a jump or a fall into another routine, of a
routine that the flow of control of the file gives); "sdk", a
rule of the SDK model: a function of an SDK runs the function that a
registration put into its slot, and no C code of the build does (a
task that the scheduler starts, a callback of a library without
source); the row stands at the declaration of that function;
"instantiation", the body of a template instance, stored on the
template; "slot", an indirect call reaches a function that the
code puts into the slot it calls through; "type_only", an
indirect call whose slot does not tell its targets reaches each
function of its type whose address the build takes, a superset),
caller (enclosing function name), caller_kind ("function",
"method", …), and entry when a rule of the SDK model gives
the edge: what starts the function ("the FreeRTOS scheduler (vTaskStartScheduler)", "an interrupt"). Macro fallback puts a dict with kind="macro",
signature (#define free: NAME or NAME(a, b)),
is_function_like, value (the replacement text ALONE) and
expanded_value or expanded_values (see lookup_symbol)
between the notice and the rows;
that answer pages too, and its total counts the uses in active
code only — a use inside a comment is not one.
When *name* matches more than one symbol, such as two classes with
a method of the same name, the answer holds the call sites of all
of them. A ``warning`` dict then comes first and names the
symbols, and each result carries ``target_qualified_name``. Give
the full qualified name to ask about one symbol only.
A virtual method with no call site of its own answers with the
call sites of its base method and of the other overrides of that
base. A ``warning`` dict leads such an answer, and each row
carries ``recorded_against`` (the symbol the index records the
call against) and ``reaches_this_symbol`` (true for a call on the
base method, which reaches this override at run time; false for a
call on a sibling override, which does not). Read both before you
report a caller count.
Never empty: one dict with ``error`` (symbol not resolved) or
``info`` (no references of this kind). Check both keys first.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>"
},
"name": "find_callers"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Symbol name to find callers of. Returns direct call sites and indirect calls via function pointers. | |
| image | No | Image of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it. | |
| limit | No | Maximum results of one page (default 50, max 200). | |
| offset | No | Skip this many results. Reads the next page of a symbol with many call sites. | |
| project | No | Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. | |
| variant | No | Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build for you. One query answers for ONE build. | |
| project_root | No | Project root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |