find_callers
Identify all direct and indirect callers of a C/C++ function, including function-pointer assignments, callbacks, and struct or array initializers, to trace usage 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.
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, ref_kind ("call",
"indirect", "implicit_construct", or "macro_use"),
caller (enclosing function name), caller_kind ("function",
"method", …). 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 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.
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 |