find_indirect_targets
Traces C/C++ function pointer data flow to show which functions a field or variable can hold and where their addresses are stored, or where a function's address is stored and which indirect calls reach it.
Instructions
Find the functions that a C/C++ function pointer field or variable can hold, and where the code stores each of them; or, for a function, where the code stores its address and which indirect calls reach it.
The answer comes from the data flow of the build, not from names: a
function reaches a field when the code stores it there, or stores it
in a slot whose value flows there (an argument of set_cb(h) into
the parameter, the parameter into the field), in any file of the
build.
For the calls through the pointer, use find_indirect_call_sites.
Read-only. No side effects. 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; a name of several symbols answers for each of them. 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:
For a field or a variable, one dict per function: function, kind,
file and line (the definition), origin ("slot"), stored_file
and stored_line (the first place that stores it), stored_places
(the places of every way to the slot), and stored_in (a list) when
the code stored it in another slot whose value flows here
(["parameter 0 of set_cb"]). A stored place in the build
artifact (zephyr/zephyr_pre0.elf of the build tree, line 0) is
an interrupt registration that a Zephyr build recorded in
.intList; for a function, its context is
"<interrupt registration of the build>". stored_places_capped (True)
marks a count that the walk back cut. A warning dict comes
first when code out of view can write the
slot: a call through it also reaches each function of its type
(find_indirect_call_sites lists them, origin "type_only").
It comes also when no code of the build stores a function into
the slot (a library out of the build fills it), with an info
dict instead of the rows.
For a function, rows with ``relation``: ``"stored"`` (file, line,
col, slot that receives the address, "" when none is known, and
context, the code that stores it) and ``"called"`` (file, line,
col, caller, caller_kind, origin: an indirect call that reaches
it; ``"sdk"`` is a function of an SDK that runs it, and ``entry``
tells what starts it).
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_targets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | A function pointer field or variable (the functions it can hold), or a function (where the code stores its address, and the indirect calls that reach it). 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. 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 |