Skip to main content
Glama
sbergeron42

gdb-multiarch-mcp

by sbergeron42

gdb_set_breakpoint

Set breakpoints in Nintendo Switch executables for debugging on Yuzu or hardware via GDB. Specify function names, file locations, or memory addresses to pause execution during analysis.

Instructions

Set a breakpoint at a function, file:line, or *address. For offset-from-main breakpoints, use switch_break_at instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesBreakpoint location (function, file:line, or *address)
conditionNoConditional expression
temporaryNoWhether breakpoint is temporary

Implementation Reference

  • The `set_breakpoint` method in `GDBSession` class defines the implementation for setting GDB breakpoints using the `-break-insert` command.
    def set_breakpoint(
        self, location: str, condition: Optional[str] = None, temporary: bool = False
    ) -> dict[str, Any]:
        """
        Set a breakpoint at the specified location.
    
        Args:
            location: Location (function name, file:line, *address)
            condition: Optional condition expression
            temporary: Whether this is a temporary breakpoint
    
        Returns:
            Dict with breakpoint information
        """
        cmd_parts = ["-break-insert"]
    
        if temporary:
            cmd_parts.append("-t")
    
        if condition:
            # Escape backslashes and quotes in the condition
            escaped_condition = condition.replace("\\", "\\\\").replace('"', '\\"')
            cmd_parts.extend(["-c", f'"{escaped_condition}"'])
    
        cmd_parts.append(location)
    
        result = self.execute_command(" ".join(cmd_parts))
    
        if result["status"] == "error":
            return result
    
        # The MI result payload is in result["result"]["result"]
        # This contains the actual GDB/MI command result
        mi_result = self._extract_mi_result(result)
    
        # Debug logging
        logger.debug(f"Breakpoint MI result: {mi_result}")
    
        if mi_result is None:
            logger.warning(f"No MI result for breakpoint at {location}")
            return {
                "status": "error",
                "message": f"Failed to set breakpoint at {location}: no result from GDB",
                "raw_result": result,
            }
    
        # The breakpoint data should be in the "bkpt" field
        bp_info = mi_result if isinstance(mi_result, dict) else {}
        breakpoint = bp_info.get("bkpt", bp_info)  # Sometimes it's directly in the result
    
        if not breakpoint:
            logger.warning(f"Empty breakpoint result for {location}: {mi_result}")
            return {
                "status": "error",
                "message": f"Breakpoint set but no info returned for {location}",
                "raw_result": result,
            }
    
        return {"status": "success", "breakpoint": breakpoint}
  • The `call_tool` handler in `server.py` delegates the `gdb_set_breakpoint` tool call to `session.set_breakpoint`.
    elif name == "gdb_set_breakpoint":
        a = SetBreakpointArgs(**arguments)
        result = session.set_breakpoint(
            location=a.location, condition=a.condition, temporary=a.temporary
        )

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/sbergeron42/gdb-multiarch-mcp'

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