Documentation
¶
Overview ¶
Package debugger implements the local GDB/MI controller and byte-transparent RSP relay. It owns no terminal Channel, Session lease, or MCP endpoint.
Index ¶
- Variables
- func DialBridge(ctx context.Context, info BridgeConnection) (net.Conn, error)
- func DialBridgeKeepAlive(ctx context.Context, info BridgeConnection) (net.Conn, error)
- func IsCommandError(e error) bool
- func Quote(s string) string
- func Relay(ctx context.Context, conn net.Conn, stream Stream) error
- type BridgeConnection
- type Client
- type CommandError
- type Endpoint
- type EndpointAllocator
- type Record
- type RelayResult
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ErrDataLost = errors.New("debug stream data lost; debugging cannot continue")
ErrDataLost means the Session overwrote bytes before the relay consumed them.
Functions ¶
func DialBridge ¶
DialBridge authenticates the server certificate before transmitting the bearer token. Cancellation bounds connection/authentication; after return, the caller owns the connection and its lifetime. No RSP bytes are generated.
func DialBridgeKeepAlive ¶
DialBridgeKeepAlive authenticates one data socket and one control socket on the same endpoint. It returns an unchanged RSP byte stream. Closing either socket terminates the pair; ctx bounds setup, and the caller owns the returned connection. A current Host is required; legacy data-only clients can still use DialBridge with explicit management renewal.
func IsCommandError ¶
IsCommandError reports a completed MI error response that leaves correlation intact.
func Relay ¶
Relay forwards bytes unchanged in both directions, including binary packets, acknowledgements and interrupts. Empty reads are not EOF. Packet framing is observed for ACK evidence but never rewritten. It does not negotiate no-ack mode or generate acknowledgements. Both directions drain before it returns. A failed direction closes the socket and cancels the other Session read. Blocked Session writes must be released by Application closing the Session.
Types ¶
type BridgeConnection ¶
type BridgeConnection struct {
Address string `json:"address"`
Fingerprint string `json:"fingerprint"`
Token string `json:"token"`
}
BridgeConnection is a private connection descriptor for an external RSP client. Token is a bearer capability; callers must not publish this object in events or logs. Fingerprint pins the ephemeral TLS certificate before Token is sent.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns one GDB process and its MI reader. Commands are serialized; asynchronous records are delivered independently of command responses.
func Start ¶
Start launches GDB with init files, auto-loaded code, and debuginfod disabled. onRecord must return promptly and must not call Command synchronously.
func (*Client) Close ¶
func (c *Client) Close()
Close kills only the owned GDB process, closes stdin, and reaps it. Target detach/termination must already have been handled by Application.
func (*Client) Command ¶
Command waits for its token-correlated response. Cancellation kills GDB: once a command may have executed, retrying it without a result is unsafe. Application owns target recovery and must not release its terminal lease on this error without independently proving shell restoration.
type CommandError ¶
type CommandError struct{ Record Record }
CommandError is an authoritative GDB rejection rather than a lost response.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
Error returns GDB's MI error message.
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint accepts one authorized TLS data connection and, for a current helper, one authenticated control connection on the same TCP listener. Rejected peers do not consume them. Close interrupts authentication and both accepted sockets; the relay owner must still join its I/O workers.
func ListenBridge ¶
ListenBridge binds a standalone endpoint using the default port policy. Hosts should share an EndpointAllocator across their bridge operations.
func (*Endpoint) Accept ¶
Accept authenticates bounded, sequential handshakes until one succeeds or ctx/Close ends the wait. Authentication bytes never reach the Session. The listener remains bound until Close. A v2 helper can authenticate one separate control connection on that listener; additional data clients are rejected. Neither disconnect nor OS address reuse releases the logical reservation; the operation owner calls Close at finalization.
func (*Endpoint) ClientAlive ¶
ClientAlive reports recent challenge/response evidence from the helper's separately authenticated control socket. Merely retaining a data socket, or receiving RSP bytes, is not liveness evidence. Legacy clients return false.
func (*Endpoint) ClientError ¶
ClientError returns a control failure without disclosing authentication data.
func (*Endpoint) Close ¶
func (e *Endpoint) Close()
Close idempotently releases the listener, pending authentication, and logical port reservation. It also interrupts both accepted sockets; the relay still owns joining its I/O workers.
func (*Endpoint) Connection ¶
func (e *Endpoint) Connection() BridgeConnection
Connection returns the secret descriptor to the authorized operation owner.
type EndpointAllocator ¶
type EndpointAllocator struct {
// contains filtered or unexported fields
}
EndpointAllocator tracks addresses owned by unfinished bridge operations. The zero value rotates through ports 37100..37999. Its mutex covers the cursor, real TCP binds, and reservations, never a probe-then-bind sequence. The OS bind additionally excludes other processes; the map expresses operation ownership.
func (*EndpointAllocator) Listen ¶
func (a *EndpointAllocator) Listen(address, allowedPeer string, strictPool bool) (*Endpoint, error)
Listen binds a specific numeric IP (default loopback port pool). Wildcard binding is forbidden. A non-loopback bind requires an exact allowed peer IP; all clients, including loopback clients, must authenticate over pinned TLS. strictPool disables dynamic fallback for an omitted address. Explicit ports, including zero, always use exactly the caller's requested bind policy.
type Record ¶
type Record struct {
Token string `json:"token,omitempty"`
Kind string `json:"kind"`
Class string `json:"class,omitempty"`
Results map[string]any `json:"results,omitempty"`
Text string `json:"text,omitempty"`
}
Record is one parsed MI record. Repeated result keys are retained as lists. Stream text uses Go strings as byte containers; adapters must encode invalid UTF-8 before presenting it as JSON text.
type RelayResult ¶
type RelayResult struct {
// ExitACK confirms a checksum-valid W/X packet was acknowledged.
ExitACK bool
// LastACK confirms the most recent complete target packet was acknowledged.
LastACK bool
}
RelayResult records ACK evidence after both relay directions have drained.
func RelayFinalACK ¶
RelayFinalACK also reports whether GDB acknowledged a checksum-valid W/X exit packet. PTYs cannot convey socket EOF; Application uses this evidence before ending a gdbserver that is waiting for stdio EOF after the inferior exited. It observes framing only: all original bytes still pass through unchanged.
type Stream ¶
type Stream interface {
Read(context.Context) (data []byte, dropped bool, err error)
Write(context.Context, []byte) error
}
Stream is the minimal cursor-based Session service used by the RSP relay. Read must return an independent bounded copy and report any overwritten bytes. Write must use the existing Application lease and Session write serialization.