Skip to main content
Glama

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

NameRequiredDescriptionDefault
nameYesA 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'.
imageNoImage 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.
limitNoMaximum results (default 50, max 200).
offsetNoSkip this many results. Reads the next page of a long answer.
projectNoProject 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.
variantNoVariant 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_rootNoProject 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

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.36.0
    • changedInput schema / properties / name / description
      Previous value: -"Name of the function pointer field, variable, or parameter. E.g. 'onData' — returns functions assigned to Driver::onData."New value: +"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'."
  2. Changed3 schema fields changedv0.32.1
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."New value: +"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."
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Skip this many results. Reads the next page of a long answer.",
      +  "minimum": 0,
      +  "title": "Offset",
      +  "type": "integer"
      +}
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."New value: +"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."
  3. Changed4 schema fields changedv0.32.0
    • changedInput schema / properties / image / description
      Previous value: -"Sysbuild image name within the variant (multi-project). Omit for all images of the variant."New value: +"Sysbuild image within the variant. Required when the variant holds several: each image is a separate program."
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • addedInput schema / properties / name / minLength
      Added value: +1
    • changedInput schema / properties / variant / description
      Previous value: -"Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants."New value: +"Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build."
  4. Changed3 schema fields changedv0.30.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / project
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "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.",
      +  "title": "Project"
      +}
    • changedInput schema / properties / project_root / description
      Previous value: -"Project root. Auto-detected if omitted."New value: +"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."
  5. Changed2 schema fields changedv0.25.3
    • addedInput schema / properties / image
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Sysbuild image name within the variant (multi-project). Omit for all images of the variant.",
      +  "title": "Image"
      +}
    • addedInput schema / properties / variant
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Build variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.",
      +  "title": "Variant"
      +}
  6. Addedv0.8.4

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: declares read-only/no side effects, the index prerequisite, that one query answers for exactly ONE build and that fw-context will refuse rather than pick one, that results are never empty and may be replaced by error/info dicts, and that warnings appear when out-of-view code can write the slot. These are behavioral facts an agent cannot infer from the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded and organized into Purpose/Args/Returns, but the Args block duplicates a schema that is already 100% described, and the very long Returns block restates a return shape that is already covered by an output schema. Roughly half the text is redundant with structured fields.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex data-flow query tool it covers what an agent needs to call it correctly: resolution rules, build selection, pagination, empty/error shapes, and warning semantics. Nothing material about invocation is left unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds genuine semantics beyond it: name is resolved like every other symbol tool and multiple matches answer for each symbol, offset is tied to the page notice's hint, and variant/image are framed as one-build-per-query selectors. The Args block otherwise largely restates the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource and covers both modes explicitly: what functions a function-pointer field/variable can hold and where the code stores them, or for a function where its address is stored and which indirect calls reach it. It also explicitly separates itself from find_indirect_call_sites, so an agent can choose between them without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit routing ('For the calls through the pointer, use find_indirect_call_sites'), names list_projects as the way to obtain a project identifier, and states the project vs project_root exclusivity. It also states a real precondition (reference index required, refs on by default) and tells the agent how to disambiguate multi-build projects via variant/image.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.