find_indirect_call_sites
Locate indirect calls made through a C/C++ function pointer field, variable, or callable object, and see which functions each call reaches. Read-only query for tracing function pointer invocations.
Instructions
Find the indirect calls through a C/C++ function pointer field or variable, or the indirect calls that a function makes, with the functions that each call reaches.
An indirect call goes through a slot: a field, a variable, a
parameter or the return value of a function that holds a function
(driver.onData(buf, len), g_cb(42), handlers[i](x)), or the
operator() of a std::function or another callable object.
For a field or a variable, the answer holds each call through it, also
through a copy of its value (cb_t f = dev->on_rx; f(1);).
Read-only. No side effects. Use this to answer "where is this function
pointer invoked, and what does it call?" as opposed to
find_callers which answers "who calls this function?" (an indirect
call that reaches it is a "call" row there, origin "slot" or
"type_only"). For the functions that a pointer can hold, and
where the code stores them, use find_indirect_targets.
Requires the reference index (fw-context index — refs on by default).
Args: name: A function pointer field or variable, or a function, method or lambda. Resolved as every symbol tool resolves a name (qualified name, bare name, suffix); a name of several symbols answers for each of them. A parameter is no symbol: ask with its function. 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 (default 50, max 200). offset: Skip this many results. Reads the next page; 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:
list of dicts, one per call site, each with: file, line, col,
caller, caller_kind, kind ("pointer": through a function
pointer; "object": the operator() of a callable object;
"address": a call of an address that is a number, such as a
bootloader that starts the application), slot (the field,
variable, parameter N of f or return of f that the call
goes through; "" when the call names none), type, targets_total
and targets (at most 10: {name, origin}, origin "slot" or
"type_only"). An "address" row has address (the text
of the address) and no target: no code of the build is there.
no_slot says why a call names no slot; slot_escapes marks a
slot that code out of view can write. Both reach the functions of
their type: origin "type_only", a superset.
When *name* matches several symbols, a ``warning`` dict names them
and each row carries ``target_qualified_name``.
The page notice ``{total, offset, shown, more, hint}`` comes
before the rows of the answer. ``total`` counts every row of the whole answer. When
``more`` is true, the ``hint`` names the call that reads the next
page. A page after the last row gives one ``info`` dict that
names the total.
Never empty: one dict with ``error`` (cannot resolve) or ``info``
(no results) replaces the results. 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_indirect_call_sites"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | A function pointer field or variable (the calls through it), or a function (the indirect calls it makes). E.g. 'onData'. | |
| 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 (default 50, max 200). | |
| offset | No | Skip this many results. Reads the next page of a long answer. | |
| 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 directory. 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 |