client

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: GPL-3.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client implements the debugger's connection to a debug server. It dials the server's TCP port, switches the connection to JSON mode, and then exposes two streams: in-order command responses and pushed watch/break events. The package has no UI dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is one server connection. Commands are matched to responses by order: the server executes one command at a time and emits exactly one resp or error line per command, so the oldest pending command owns the next response line.

func Dial

func Dial(addr string) (*Client, error)

Dial connects to a debug server, switches it to JSON mode, and starts the reader. The mode switch doubles as a handshake: if the expected mode response does not arrive within the timeout, the endpoint is not a debug server and Dial fails.

func (*Client) Close

func (c *Client) Close()

Close tears the connection down. It is safe to call more than once and concurrently with in-flight commands, which complete with errors.

func (*Client) Do

func (c *Client) Do(line string) <-chan Response

Do queues one command line and returns a channel that delivers its response exactly once. On a dead connection the response is an immediate error. A line containing a newline is rejected: it would reach the server as multiple commands and desynchronize the in-order response matching.

func (*Client) Err

func (c *Client) Err() error

Err reports why the connection ended. It is nil while the connection is alive and after a local Close.

func (*Client) Events

func (c *Client) Events() <-chan Event

Events returns the pushed-event stream. The channel is closed when the connection ends, which is the disconnect signal for a consumer that polls it.

type Event

type Event struct {
	Kind  string `json:"type"`
	Frame uint64 `json:"frame"`
	Addr  uint32 `json:"addr"`
	Width int    `json:"width"`
	Prev  uint32 `json:"prev"`
	Cur   uint32 `json:"cur"`
	Cond  string `json:"cond"`
}

Event is one pushed watch or break notification. Kind is "watch" or "break". Cond is the break condition and is empty for watches. A break event means emulation is now paused.

type Response

type Response struct {
	Data json.RawMessage
	Err  error
}

Response is the outcome of one command. Err is set for both server-reported errors and connection failures; Data is the resp envelope payload otherwise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL