developer

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: GPL-3.0, GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package developer offers additional functionality to the developer of ROMs that use a coprocessor. For instance, it handles the loading of .map and .obj files if they have been generated during the compilation of the 2600 ROM. The .map and .obj files are used to provide source code level information during execution.

Objdump type is a very basic parser for obj files as produced by "objdump -S" on the base elf file that is used to create a cartridge binary

Index

Constants

View Source
const (
	UnknownFunction   = "<unknown function>"
	UnknownSourceLine = "<unknown source line>"
)

Strings used to indicate unknown values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Developer

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

Developer implements the CartCoProcDeveloper interface.

func NewDeveloper

func NewDeveloper(pathToROM string, cart mapper.CartCoProcBus) *Developer

NewDeveloper is the preferred method of initialisation for the Developer type.

func (*Developer) BorrowIllegalAccess

func (dev *Developer) BorrowIllegalAccess(f func(*IllegalAccess))

BorrowIllegalAccess will lock the illegal access log for the duration of the supplied fucntion, which will be executed with the illegal access log as an argument.

func (*Developer) BorrowSource

func (dev *Developer) BorrowSource(f func(*Source))

BorrowSource will lock the source code structure for the durction of the supplied function, which will be executed with the source code structure as an argument.

May return nil.

func (*Developer) ExecutionProfile

func (dev *Developer) ExecutionProfile(addr map[uint32]float32)

ExecutionProfile implements the CartCoProcDeveloper interface.

func (*Developer) HasSource

func (dev *Developer) HasSource() bool

HasSource returns true if source information has been found.

func (*Developer) IllegalAccess

func (dev *Developer) IllegalAccess(event string, pc uint32, addr uint32) string

IllegalAccess implements the CartCoProcDeveloper interface.

func (*Developer) NewFrame

func (dev *Developer) NewFrame(_ television.FrameInfo) error

NewFrame implements the television.FrameTrigger interface.

type ExecutedLines

type ExecutedLines struct {
	Lines []*SrcLine
	// contains filtered or unexported fields
}

ExecutedLines orders every line of executable source code in the identified source files. Useful for determining the most expensive lines of source code in terms of execution time.

func (ExecutedLines) Len

func (e ExecutedLines) Len() int

Len implements sort.Interface.

func (ExecutedLines) Less

func (e ExecutedLines) Less(i int, j int) bool

Less implements sort.Interface.

func (ExecutedLines) SortedBy

func (e ExecutedLines) SortedBy() string

SortedBy returns a string describing the sort method

func (ExecutedLines) Swap

func (e ExecutedLines) Swap(i int, j int)

Swap implements sort.Interface.

type IllegalAccess

type IllegalAccess struct {
	Log []IllegalAccessEntry
	// contains filtered or unexported fields
}

IllegalAccess records memory accesses by the coprocesser that are "illegal".

type IllegalAccessEntry

type IllegalAccessEntry struct {
	Event      string
	PC         uint32
	AccessAddr uint32
	SrcLine    *SrcLine
}

IllegalAccessEntry is a single entry in the illegal access log.

type Source

type Source struct {
	Files      map[string]*SrcFile
	FilesNames []string

	// A list of all the source lines in the program. only those lines that
	// have SrcLineAsm entries are included.
	//
	// sorted by cycle count from highest to lowest
	ExecutedLines ExecutedLines

	// the number of cycles this line has instruction consumed on the
	// coprocessor during the course of the previous frame
	FrameCycles float32

	// the total number of cycles over the lifetime of the program
	TotalCycles float32
	// contains filtered or unexported fields
}

Source files for the currently loaded ROM. It is built through a combination of a binary objdump and the original source files.

func (*Source) Resort

func (src *Source) Resort(byLifetimeCycles bool)

Resort the execution source lines.

type SrcFile

type SrcFile struct {
	// name and path of loaded file
	Filename string

	// the lines of the file
	Lines []*SrcLine
}

SrcFile represents a single file of original source code. A file is made up of many SrcLine entries.

type SrcLine

type SrcLine struct {
	// the file the line is found in
	File *SrcFile

	Function   string // function name line is contained in (if found)
	LineNumber int    // counting from one
	Content    string // the actual line

	Inlined bool

	// the generated assembly for this line. will be empty if line is a comment
	// or otherwise unsused
	Asm []*SrcLineAsm

	// the number of cycles this line has instruction consumed on the
	// coprocessor during the course of the previous frame
	FrameCycles float32

	// the total number of cycles over the lifetime of the program
	LifetimeCycles float32

	// whether this src line has been responsible for an illegal access
	IllegalAccess bool

	// the number of times the line has been responsible for an illegal access
	IllegalCount int
	// contains filtered or unexported fields
}

SrcLine represents a single line of source in a SrcFile.

func (*SrcLine) String

func (src *SrcLine) String() string

type SrcLineAsm

type SrcLineAsm struct {
	// address of instruction
	Addr uint32

	// the actual coprocessor instruction
	Instruction string
	// contains filtered or unexported fields
}

SrcLineAsm associates an asm with a block of source (which might be a single line).

Jump to

Keyboard shortcuts

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