debugger

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: GPL-3.0, GPL-3.0 Imports: 42 Imported by: 0

Documentation

Overview

Package debugger implements a reaonably comprehensive debugging tool. Features include:

  • cartridge disassembly
  • memory peek and poke
  • cpu and video cycle stepping
  • basic scripting
  • breakpoints
  • traps
  • watches

Some of these features come courtesy of other packages, described elsewhere, and some are inherent in the gopher2600's emulation strategy, but all are nicely exposed via the debugger package.

Initialisation of the debugger is done with the NewDebugger() function

dbg, _ := debugger.NewDebugger(television, gui, term)

The tv, gui and term arguments must be instances of types that satisfy the respective interfaces. This gives the debugger great flexibility and should allow easy porting to new platforms

Interaction with the debugger is primarily through a terminal. The Terminal interface is defined in the terminal package. The colorterm and plainterm sub-packages provide good reference implementations.

The GUI helps visualise the television and coordinates events (keyboard, mouse) which the debugger can then poll. A good reference implementation of a debugging GUI can be in found the gui.sdldebug package.

The television argument should be an instance of TV. For all practical purposes this will be instance createed with television.NewTelevision(), but other implementations are possible if not yet available.

Once initialised, the debugger can be started with the Start() function.

dbg.Start(initScript, cartloader)

The initscript is a script previously created either by the script.Scribe package or by hand. The cartloader argument must be an instance of cartloader.

Interaction with the debugger for both user and programs that use the debugger, is through the Terminal interface (see terminal package). Where this is not possible, functions have been provided. For interaction from other goroutines, the PushRawEvent() function should be used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakGroup

type BreakGroup int

BreakGroup indicates the broad category of breakpoint an address has.

const (
	BrkNone BreakGroup = iota

	// a breakpoint.
	BrkPCAddress

	// a breakpoint on something other than the program counter / address.
	BrkOther
)

List of valid BreakGroup values.

type Debugger

type Debugger struct {
	Disasm *disassembly.Disassembly

	// the Rewind system stores and restores machine state.
	Rewind *rewind.Rewind
	// contains filtered or unexported fields
}

Debugger is the basic debugging frontend for the emulation. In order to be kind to code that accesses the debugger from a different goroutine (ie. a GUI), we try not to reinitialise anything once it has been initialised. For example, disassembly on a cartridge change (which can happen at any time) updates the Disasm field, it does not reinitialise it.

func NewDebugger

func NewDebugger(tv *television.Television, scr gui.GUI, term terminal.Terminal, useSavekey bool) (*Debugger, error)

NewDebugger creates and initialises everything required for a new debugging session. Use the Start() method to actually begin the session.

func (*Debugger) CatchUpLoop added in v0.7.1

func (dbg *Debugger) CatchUpLoop(continueCheck func() bool) error

CatchupLoop is an implementation of the rewind.Runner interface.

Runs the emulation from it's current state until the supplied continueCheck callback function returns false.

func (*Debugger) Debugger added in v0.14.0

func (dbg *Debugger) Debugger() emulation.Debugger

Debugger implements the emulation.Emulation interface.

func (*Debugger) GetLastResult added in v0.3.1

func (dbg *Debugger) GetLastResult() disassembly.Entry

GetLastResult returns the formatted disasembly entry of the last CPU execution.

func (*Debugger) GetQuantum

func (dbg *Debugger) GetQuantum() QuantumMode

GetQuantum returns the current quantum value.

func (*Debugger) HasBreak

func (dbg *Debugger) HasBreak(addr uint16, bank int) BreakGroup

HasBreak returns true if there is a breakpoint at the address. the second return value indicates if there is a breakpoint at the address AND bank.

func (*Debugger) HasChanged added in v0.8.0

func (dbg *Debugger) HasChanged() bool

HasChanged returns true if emulation state has changed since last call to the function.

func (*Debugger) IsDeepPoking added in v0.10.1

func (dbg *Debugger) IsDeepPoking() bool

IsDeepPoking returns true if a deep poke search is in progress.

func (*Debugger) Pause added in v0.14.0

func (dbg *Debugger) Pause(set bool)

Pause implements the emulation.Emulation interface.

func (*Debugger) PushDeepPoke added in v0.10.1

func (dbg *Debugger) PushDeepPoke(addr uint16, value uint8, newValue uint8, valueMask uint8) bool

PushDeepPoke schedules a deep poke search for the specificed value in the address, replacing it with newValue if found. The valueMask will be applied to the value for matching and for setting the newValue - unset bits in the mask will preserve the corresponding bits in the found value.

func (*Debugger) PushGotoCoords added in v0.7.1

func (dbg *Debugger) PushGotoCoords(frame int, scanline int, clock int)

PushGotoCoords is a special case of PushRawEvent(). It prevents too may pushed rewind.GotoFrameCoords() function calls.

To be used from the GUI thread.

func (*Debugger) PushRawEvent

func (dbg *Debugger) PushRawEvent(f func())

PushRawEvent onto the event queue. This can be used to get information out of the debygger into another goroutine. Useful for when there is no equivalent terminal command.

func (*Debugger) PushRawEventImm added in v0.8.0

func (dbg *Debugger) PushRawEventImm(f func())

PushRawEventImm onto the event queue. Similar to PushRawEvent() but handlers will relinquish control of the handler thread immediately upon completion of pushed funcion.

Useful when pushed function has visual side-effects that must be serviced immediately.

func (*Debugger) PushRewind added in v0.7.1

func (dbg *Debugger) PushRewind(fn int, last bool) bool

PushRewind is a special case of PushRawEvent(). It prevents too many pushed rewind.Goto*() function calls. Returns false if the rewind hasn't been pushed. The caller should try again.

To be used from the GUI thread.

func (*Debugger) Start

func (dbg *Debugger) Start(initScript string, cartload cartridgeloader.Loader) error

Start the main debugger sequence.

func (*Debugger) State added in v0.14.0

func (dbg *Debugger) State() emulation.State

State implements the emulation.Emulation interface.

func (*Debugger) TogglePCBreak

func (dbg *Debugger) TogglePCBreak(e *disassembly.Entry)

TogglePCBreak sets or unsets a PC break at the address rerpresented by th disassembly entry.

func (*Debugger) UserInput added in v0.14.0

func (dbg *Debugger) UserInput() chan userinput.Event

UserInput implements the emulation.Emulation interface.

func (*Debugger) VCS added in v0.2.1

func (dbg *Debugger) VCS() emulation.VCS

VCS implements the emulation.Emulation interface.

type QuantumMode

type QuantumMode int

QuantumMode specifies the step granularity of the emulator.

const (
	QuantumInstruction QuantumMode = iota
	QuantumVideo
)

List of valid QuantumModes.

func (QuantumMode) String

func (mode QuantumMode) String() string

Directories

Path Synopsis
Package script allows the debugger to record and replay debugging scripts.
Package script allows the debugger to record and replay debugging scripts.
Package terminal defines the operations required for command-line interaction with the debugger.
Package terminal defines the operations required for command-line interaction with the debugger.
colorterm
Package colorterm implements the Terminal interface for the gopher2600 debugger.
Package colorterm implements the Terminal interface for the gopher2600 debugger.
colorterm/easyterm
Package easyterm is a wrapper for "github.com/pkg/term/termios".
Package easyterm is a wrapper for "github.com/pkg/term/termios".
colorterm/easyterm/ansi
Package ansi defines ANSI control codes for styles and colours.
Package ansi defines ANSI control codes for styles and colours.
commandline
Package commandline facilitates parsing of command line input.
Package commandline facilitates parsing of command line input.
plainterm
Package plainterm implements the Terminal interface for the gopher2600 debugger.
Package plainterm implements the Terminal interface for the gopher2600 debugger.

Jump to

Keyboard shortcuts

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