gdb_get_backtrace
Retrieve stack backtraces for debugging Nintendo Switch executables using GDB to analyze program flow and identify issues during execution.
Instructions
Get the stack backtrace (standard GDB backtrace).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thread_id | No | Thread ID (None for current thread) | |
| max_frames | No | Maximum number of frames to retrieve |
Implementation Reference
- The `get_backtrace` method in `GDBSession` class. This method switches to the specified thread (if any) and then retrieves the backtrace using the GDB/MI `-stack-list-frames` command.
def get_backtrace( self, thread_id: Optional[int] = None, max_frames: int = DEFAULT_MAX_BACKTRACE_FRAMES ) -> dict[str, Any]: """ Get the stack backtrace for a specific thread or the current thread. Args: thread_id: Thread ID to get backtrace for (None for current thread) max_frames: Maximum number of frames to retrieve Returns: Dict with backtrace information """ # Switch to thread if specified if thread_id is not None: switch_result = self.execute_command(f"-thread-select {thread_id}") if switch_result["status"] == "error": return switch_result # Get stack trace result = self.execute_command(f"-stack-list-frames 0 {max_frames}") if result["status"] == "error": return result stack_data = self._extract_mi_result(result) or {} frames = stack_data.get("stack", []) return {"status": "success", "thread_id": thread_id, "frames": frames, "count": len(frames)}