trace
Trace Go program execution to monitor function calls and performance using regex patterns, package filters, and optional stack depth analysis.
Instructions
Trace program execution
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regexp | Yes | Regular expression to match functions to trace | |
| pkg | No | Package to trace (defaults to .) | |
| ebpf | No | Use eBPF for tracing (experimental) | |
| stack | No | Show stack trace with given depth | |
| pid | No | Pid to attach to |
Implementation Reference
- src/server.ts:319-348 (schema)Defines the input schema for the 'trace' tool, specifying parameters such as regexp (required), pkg, ebpf, stack, and pid.{ name: "trace", description: "Trace program execution", inputSchema: { type: "object", properties: { regexp: { type: "string", description: "Regular expression to match functions to trace" }, pkg: { type: "string", description: "Package to trace (defaults to .)" }, ebpf: { type: "boolean", description: "Use eBPF for tracing (experimental)" }, stack: { type: "number", description: "Show stack trace with given depth" }, pid: { type: "number", description: "Pid to attach to" } }, required: ["regexp"] } },
- src/server.ts:406-407 (registration)Registers the 'trace' tool by routing CallTool requests for 'trace' to the handleDebugCommands function in debug.ts.if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args);
- src/types.ts:18-18 (helper)Type definition for DebugSession includes 'trace' as a valid session type.type: string; // 'debug' | 'attach' | 'exec' | 'test' | 'core' | 'replay' | 'trace' | 'dap'