Skip to main content
Glama

find_call_path

Trace how one C/C++ function reaches another via BFS on libclang's call graph, including function-pointer and dispatch edges. Returns up to five shortest paths.

Instructions

Find call paths between two C/C++ functions via BFS in the libclang call graph, including function-pointer edges, ISR vector registrations, implicit constructors, and synthetic dispatch edges (event loops, thread starts). libclang-powered: follows function-pointer edges and ISR vector registrations that text-based search cannot resolve.

Use to answer "how does A reach B?" — e.g. tracing how a high-level event handler eventually calls a low-level driver. Returns up to 5 shortest paths, each with depth (edge count) and chain (e.g. "main → app_run → modem_init").

Edge types traversed: The BFS includes call, indirect (function pointers / ISRs), implicit_construct (global/static object constructors), and dispatch (synthetic edges through event loops like EventQueue::dispatch_forever and thread starts like Thread::start).

Limitations:

  • Caveat 1 — Callback/event-loop dispatch: Callbacks registered via dispatch-registration APIs (EventQueue::call_every, k_work_submit, xTimerStart) are bridged to their dispatch entry point (e.g. dispatch_forever, z_work_q_main) via a built-in mapping for mbed-os, Zephyr, and FreeRTOS. Custom or uncommon RTOS dispatch patterns can be added via [call_graph.dispatch_bridges] in .fw-context/config.toml. Bridges whose entry point symbol does not exist in the index are silently skipped — the map can list all supported platforms without causing errors.

  • Caveat 2 — Ambiguous name resolution in fallback paths: When libclang cannot resolve a call (e.g. template-obscured _timeout.attach(...)), a source-line regex fallback attempts to match the method name. If multiple methods share the same unqualified name AND neither the receiver field type nor the caller's class provide disambiguation, the edge is not created (conservative — avoids false paths).

  • Caveat 3 — Global constructor bridging: File-scope implicit_construct edges are reachable through a synthetic <global ctors> node injected between main and all global constructors. Works for any call-path query that can reach main — not limited to queries starting from main.

When find_call_path returns empty and you believe a path should exist:

  1. Check for async dispatch — use search_bodies("call_every") or search_bodies("attach") to find callback registrations.

  2. Manually trace through callbacks with find_callers on intermediate symbols.

  3. Raise max_depth (default 10, max 50) if the call chain is long.

  4. Use find_indirect_call_sites / find_indirect_targets to verify function-pointer wiring.

For one-sided exploration use find_all_callers_recursive (who reaches this?) or find_callees_recursive (what does this reach?). For exact call-graph verification use find_callers or find_references.

Read-only. No side effects. Requires both symbols to be in the index and refs enabled (fw-context index — refs on by default).

Args: from_name: Starting symbol for path search. to_name: Target symbol to find path to. project_root: Project root. Auto-detected if omitted. max_depth: Maximum BFS depth for path search (default 10, max 50).

Returns: list of dicts, each with: depth (edge count, int), chain (str — e.g. "main → app_run → modem_init"). Empty list when no path exists within the depth limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageNoSysbuild image name within the variant (multi-project). Omit for all images of the variant.
to_nameYesTarget symbol to find path to.
variantNoBuild variant name (multi-project). Omit to use default_variant or fail-closed. Use '*' for all variants.
from_nameYesStarting symbol for path search.
max_depthNoMaximum BFS depth for path search (default 10).
project_rootNoProject root. Auto-detected if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure, and it excels. It explicitly states 'Read-only. No side effects.' and details requirements (both symbols must be in the index, refs enabled). It discloses limitations in depth: silent skipping of missing dispatch bridge entry points, conservative edge creation to avoid false paths in ambiguous name resolution, and the synthetic <global ctors> node. The return behavior (empty list when no path) is also described. No contradictions with annotations exist since none are provided.

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

Conciseness5/5

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

Although lengthy, the description is exceptionally well-structured with clear sections: purpose, usage, edge types, numbered caveats, troubleshooting steps, alternatives, read-only guarantee, arguments, and returns. Every sentence adds substantive information; there is no fluff or repetition. The use of bullet points and formatting makes it easy to scan despite its length. This is an appropriate size for the tool's complexity.

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?

Given the tool's complexity (BFS, multiple edge types, caveats) and the absence of annotations, the description is remarkably complete. It covers return value structure (depth, chain), failure behavior (empty list), prerequisites, limitations, and troubleshooting. The output schema exists and the description complements it by explaining the path chain format and edge cases. No significant gaps remain; an agent has enough context to decide when and how to use this tool correctly.

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 the baseline is 3. The description adds extra meaning by specifying max_depth has a max of 50 (schema only says default 10) and clarifying the return semantics ('depth (edge count)' and 'chain' string examples). It also gives context for how from_name/to_name are used in path search. However, it does not describe image or variant parameters, but those are already clearly described in the schema. Overall, the description adds value beyond the schema without fully compensating for every parameter detail.

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?

The description clearly states the tool's purpose: 'Find call paths between two C/C++ functions via BFS in the libclang call graph'. It specifies the resource (call graph), the algorithm (BFS), and the kinds of edges traversed (function-pointer, ISR, implicit constructors, dispatch). It also distinguishes itself from sibling tools by explicitly directing users to alternatives like find_all_callers_recursive for one-sided exploration and find_callers/find_references for exact verification.

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?

The description provides explicit usage guidance: 'Use to answer "how does A reach B?"' and gives concrete examples (tracing a high-level event handler to a low-level driver). It also states when to use alternative tools ('For one-sided exploration use find_all_callers_recursive...', 'For exact call-graph verification use find_callers or find_references') and includes a troubleshooting section for empty results with step-by-step suggestions. This fully satisfies the when/when-not/alternatives criterion.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/turbyho/fw-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server