Documentation
¶
Index ¶
- Constants
- Variables
- type AllSourceLines
- type Cartridge
- type FunctionFilter
- type SortedFunctions
- func (e SortedFunctions) Len() int
- func (e SortedFunctions) Less(i int, j int) bool
- func (e *SortedFunctions) SetCumulative(set bool)
- func (e *SortedFunctions) SetFocus(focus profiling.Focus)
- func (e SortedFunctions) Sort()
- func (e *SortedFunctions) SortByAverageCycles(descending bool)
- func (e *SortedFunctions) SortByFile(descending bool)
- func (e *SortedFunctions) SortByFrameCycles(descending bool)
- func (e *SortedFunctions) SortByFunction(descending bool)
- func (e *SortedFunctions) SortByMaxCycles(descending bool)
- func (e SortedFunctions) Swap(i int, j int)
- func (e *SortedFunctions) UseRawCyclesCounts(use bool)
- type SortedLines
- func (e SortedLines) Len() int
- func (e SortedLines) Less(i int, j int) bool
- func (e *SortedLines) SetKernel(kernel profiling.Focus)
- func (e SortedLines) Sort()
- func (e *SortedLines) SortByAverageLoadOverFunction(descending bool)
- func (e *SortedLines) SortByAverageLoadOverSource(descending bool)
- func (e *SortedLines) SortByFile(descending bool)
- func (e *SortedLines) SortByFrameLoadOverFunction(descending bool)
- func (e *SortedLines) SortByFrameLoadOverSource(descending bool)
- func (e *SortedLines) SortByFunction(descending bool)
- func (e *SortedLines) SortByLineAndFunction(descending bool)
- func (e *SortedLines) SortByLineNumber(descending bool)
- func (e *SortedLines) SortByMaxLoadOverFunction(descending bool)
- func (e *SortedLines) SortByMaxLoadOverSource(descending bool)
- func (e SortedLines) Swap(i int, j int)
- func (e *SortedLines) UseRawCyclesCounts(use bool)
- type SortedVariableMethod
- type SortedVariables
- type SortedVariablesLocal
- type Source
- func (src *Source) AddFunctionFilter(functionName string)
- func (src *Source) DropFunctionFilter(functionName string)
- func (src *Source) ExecutionProfile(ln *SourceLine, ct float32, focus profiling.Focus)
- func (src *Source) ExecutionProfileCumulative(fn *SourceFunction, ct float32, focus profiling.Focus)
- func (src *Source) FindSourceLine(addr uint32) *SourceLine
- func (src *Source) FramebaseCurrent(derivation io.Writer) (uint64, error)
- func (src *Source) GetLocalVariables(ln *SourceLine, addr uint32) []*SourceVariableLocal
- func (src *Source) NewFrame()
- func (src *Source) ResetStatistics()
- func (src *Source) SourceLineByAddr(addr uint32) *SourceLine
- func (src *Source) UpdateGlobalVariables()
- type SourceFile
- type SourceFileContent
- type SourceFunction
- type SourceInstruction
- type SourceLine
- type SourceLineFragment
- type SourceLineFragmentType
- type SourceRange
- type SourceType
- type SourceVariable
- func (varb *SourceVariable) Address() (uint64, bool)
- func (varb *SourceVariable) Child(i int) *SourceVariable
- func (varb *SourceVariable) IsValid() bool
- func (varb *SourceVariable) NumChildren() int
- func (varb *SourceVariable) String() string
- func (varb *SourceVariable) Update()
- func (varb *SourceVariable) Value() uint32
- func (varb *SourceVariable) WriteDerivation(w io.Writer) error
- type SourceVariableLocal
Constants ¶
const DriverFunctionName = "<driver>"
DriverFunctionName is the name given to a function that represents all the instructions that fall outside of the ROM and are in fact in the "driver".
Variables ¶
var UnsupportedDWARF = errors.New("unsupported DWARF")
Sentinal error to indicate that the DWARF data isn't supported by the package. It might be valid DWARF but we don't want to deal with it
Functions ¶
This section is empty.
Types ¶
type AllSourceLines ¶
type AllSourceLines struct {
// contains filtered or unexported fields
}
func (AllSourceLines) Get ¶
func (a AllSourceLines) Get(i int) *SourceLine
func (AllSourceLines) Len ¶
func (a AllSourceLines) Len() int
func (AllSourceLines) String ¶
func (a AllSourceLines) String(i int) string
type Cartridge ¶
type Cartridge interface {
GetCoProcBus() coprocessor.CartCoProcBus
}
Cartridge defines the interface to the cartridge required by the source package
type FunctionFilter ¶
type FunctionFilter struct {
FunctionName string
Function *SourceFunction
Lines SortedLines
}
type SortedFunctions ¶
type SortedFunctions struct {
Functions []*SourceFunction
// contains filtered or unexported fields
}
func (SortedFunctions) Len ¶
func (e SortedFunctions) Len() int
func (*SortedFunctions) SetCumulative ¶
func (e *SortedFunctions) SetCumulative(set bool)
func (*SortedFunctions) SetFocus ¶
func (e *SortedFunctions) SetFocus(focus profiling.Focus)
func (SortedFunctions) Sort ¶
func (e SortedFunctions) Sort()
func (*SortedFunctions) SortByAverageCycles ¶
func (e *SortedFunctions) SortByAverageCycles(descending bool)
func (*SortedFunctions) SortByFile ¶
func (e *SortedFunctions) SortByFile(descending bool)
func (*SortedFunctions) SortByFrameCycles ¶
func (e *SortedFunctions) SortByFrameCycles(descending bool)
func (*SortedFunctions) SortByFunction ¶
func (e *SortedFunctions) SortByFunction(descending bool)
func (*SortedFunctions) SortByMaxCycles ¶
func (e *SortedFunctions) SortByMaxCycles(descending bool)
func (SortedFunctions) Swap ¶
func (e SortedFunctions) Swap(i int, j int)
func (*SortedFunctions) UseRawCyclesCounts ¶
func (e *SortedFunctions) UseRawCyclesCounts(use bool)
type SortedLines ¶
type SortedLines struct {
Lines []*SourceLine
// contains filtered or unexported fields
}
func (SortedLines) Len ¶
func (e SortedLines) Len() int
func (*SortedLines) SetKernel ¶
func (e *SortedLines) SetKernel(kernel profiling.Focus)
func (SortedLines) Sort ¶
func (e SortedLines) Sort()
func (*SortedLines) SortByAverageLoadOverFunction ¶
func (e *SortedLines) SortByAverageLoadOverFunction(descending bool)
func (*SortedLines) SortByAverageLoadOverSource ¶
func (e *SortedLines) SortByAverageLoadOverSource(descending bool)
func (*SortedLines) SortByFile ¶
func (e *SortedLines) SortByFile(descending bool)
func (*SortedLines) SortByFrameLoadOverFunction ¶
func (e *SortedLines) SortByFrameLoadOverFunction(descending bool)
func (*SortedLines) SortByFrameLoadOverSource ¶
func (e *SortedLines) SortByFrameLoadOverSource(descending bool)
func (*SortedLines) SortByFunction ¶
func (e *SortedLines) SortByFunction(descending bool)
func (*SortedLines) SortByLineAndFunction ¶
func (e *SortedLines) SortByLineAndFunction(descending bool)
func (*SortedLines) SortByLineNumber ¶
func (e *SortedLines) SortByLineNumber(descending bool)
func (*SortedLines) SortByMaxLoadOverFunction ¶
func (e *SortedLines) SortByMaxLoadOverFunction(descending bool)
func (*SortedLines) SortByMaxLoadOverSource ¶
func (e *SortedLines) SortByMaxLoadOverSource(descending bool)
func (SortedLines) Swap ¶
func (e SortedLines) Swap(i int, j int)
func (*SortedLines) UseRawCyclesCounts ¶
func (e *SortedLines) UseRawCyclesCounts(use bool)
type SortedVariableMethod ¶
type SortedVariableMethod int
const ( SortVariableByName SortedVariableMethod = iota SortVariableByAddress )
type SortedVariables ¶
type SortedVariables struct {
Variables []*SourceVariable
Method SortedVariableMethod
Descending bool
}
func (SortedVariables) Len ¶
func (v SortedVariables) Len() int
func (*SortedVariables) SortByAddress ¶
func (e *SortedVariables) SortByAddress(descending bool)
func (*SortedVariables) SortByName ¶
func (e *SortedVariables) SortByName(descending bool)
func (SortedVariables) Swap ¶
func (v SortedVariables) Swap(i int, j int)
type SortedVariablesLocal ¶
type SortedVariablesLocal struct {
Locals []*SourceVariableLocal
Method SortedVariableMethod
Descending bool
}
SortedVariabelsLocal is exactly the same as the SortedVariables type except for the type of the Variables field. this is a good candidate for replacing with a Go1.19 generic solution
func (SortedVariablesLocal) Len ¶
func (v SortedVariablesLocal) Len() int
func (*SortedVariablesLocal) SortByAddress ¶
func (e *SortedVariablesLocal) SortByAddress(descending bool)
func (*SortedVariablesLocal) SortByName ¶
func (e *SortedVariablesLocal) SortByName(descending bool)
func (SortedVariablesLocal) Swap ¶
func (v SortedVariablesLocal) Swap(i int, j int)
type Source ¶
type Source struct {
// source is compiled with optimisation
Optimised bool
// instructions in the source code
Instructions map[uint64]*SourceInstruction
// all the files in all the compile units
Files map[string]*SourceFile
Filenames []string
// as above but indexed by the file's short filename, which is sometimes
// more useful than the full name
//
// short filenames also only include files that are in the same path as the
// ROM file
FilesByShortname map[string]*SourceFile
ShortFilenames []string
// functions found in the compile units
Functions map[string]*SourceFunction
FunctionNames []string
// best guess at what the "main" function is in the program. very often
// this function will be called "main" and will be easy to discern but
// sometimes it is named something else and we must figure out as best we
// can which function it is
//
// if no function can be found at all, MainFunction will be a stub entry
MainFunction *SourceFunction
// special purpose line used to collate instructions that are outside the
// loaded ROM and are very likely instructions handled by the "driver". the
// actual driver function is in the Functions map as normal, under the name
// given in "const driverFunction"
DriverSourceLine *SourceLine
// sorted list of every function in all compile unit
SortedFunctions SortedFunctions
// all global variables in all compile units
GlobalsByAddress map[uint64]*SourceVariable
SortedGlobals SortedVariables
// all local variables in all compile units
SortedLocals SortedVariablesLocal
// the highest address of any variable (not just global variables, any
// variable)
HighAddress uint64
// lines of source code found in the compile units. this is a sparse
// coverage of the total address space
LinesByAddress map[uint64]*SourceLine
// sorted list of every source line in all compile units
SortedLines SortedLines
// every non-blank line of source code in all compile units
AllLines AllSourceLines
// sorted lines filtered by function name
FunctionFilters []*FunctionFilter
// statistics for the entire program
Stats profiling.StatsGroup
// flag to indicate whether the execution profile has changed since it was cleared
//
// cheap and easy way to prevent sorting too often - rather than sort after
// every call to execute(), we can use this flag to sort only when we need
// to in the GUI.
//
// probably not scalable but sufficient for our needs of a single GUI
// running and using the statistics for only one reason
ExecutionProfileChanged bool
// contains filtered or unexported fields
}
Source is created from available DWARF data that has been found in relation to and ELF file that looks to be related to the specified ROM.
It is possible for the arrays/map fields to be empty
func NewSource ¶
NewSource is the preferred method of initialisation for the Source type.
If no ELF file or valid DWARF data can be found in relation to the ROM file the function will return nil with an error.
Once the ELF and DWARF file has been identified then Source will always be non-nil but with the understanding that the fields may be empty.
func (*Source) AddFunctionFilter ¶
func (*Source) DropFunctionFilter ¶
DropFunctionFilter drops the existing filter.
func (*Source) ExecutionProfile ¶
func (src *Source) ExecutionProfile(ln *SourceLine, ct float32, focus profiling.Focus)
func (*Source) ExecutionProfileCumulative ¶
func (src *Source) ExecutionProfileCumulative(fn *SourceFunction, ct float32, focus profiling.Focus)
func (*Source) FindSourceLine ¶
func (src *Source) FindSourceLine(addr uint32) *SourceLine
FindSourceLine returns line entry for the address. Returns nil if the address has no source line.
func (*Source) FramebaseCurrent ¶
FramebaseCurrent returns the current framebase value
func (*Source) GetLocalVariables ¶
func (src *Source) GetLocalVariables(ln *SourceLine, addr uint32) []*SourceVariableLocal
GetLocalVariables retuns the list of local variables for the supplied address. Local variables will not be updated.
func (*Source) ResetStatistics ¶
func (src *Source) ResetStatistics()
ResetStatistics resets all performance statistics.
func (*Source) SourceLineByAddr ¶
func (src *Source) SourceLineByAddr(addr uint32) *SourceLine
SourceLineByAddr returns the source line for a intruciton address. If there is no corresponding source line then a stub is returned.
func (*Source) UpdateGlobalVariables ¶
func (src *Source) UpdateGlobalVariables()
UpdateGlobalVariables using the current state of the emulated coprocessor. Local variables are updated when coprocessor yields (see OnYield() function)
type SourceFile ¶
type SourceFile struct {
Filename string
ShortFilename string
Content SourceFileContent
// the source file has at least one global variable if HasGlobals is true
HasGlobals bool
}
SourceFile is a single source file indentified by the DWARF data.
func (*SourceFile) IsStub ¶
func (f *SourceFile) IsStub() bool
IsStub returns true if the SourceFile is just a stub.
type SourceFileContent ¶
type SourceFileContent struct {
Lines []*SourceLine
MaxLineWidth int
}
SourceFileContent lists the lines in a source file
func (SourceFileContent) Len ¶
func (s SourceFileContent) Len() int
Len implements the fuzzy.Source interface
func (SourceFileContent) String ¶
func (s SourceFileContent) String(i int) string
String implements the fuzzy.Source interface
type SourceFunction ¶
type SourceFunction struct {
// name of function
Name string
// range of addresses in which function resides
Range []SourceRange
// first source line for each instance of the function. note that the first
// line of a function may not have any code directly associated with it -
// meaning that the Instruction and Stats fields of the DeclLine may be
// empty
DeclLine *SourceLine
// stats for the function
FlatStats profiling.StatsGroup
CumulativeStats profiling.StatsGroup
// which 2600 kernel has this function executed in
Kernel profiling.Focus
// whether the call stack involving this function is likely inaccurate
OptimisedCallStack bool
// contains filtered or unexported fields
}
SourceFunction is a single function identified by the DWARF data or by the ELF symbol table in the case of no DWARF information being available for the function.
func (*SourceFunction) IsInlined ¶
func (fn *SourceFunction) IsInlined() bool
IsInlined returns true if the function has at least one inlined instance
func (*SourceFunction) IsStub ¶
func (fn *SourceFunction) IsStub() bool
IsStub returns true if the SourceFunction is just a stub
func (*SourceFunction) String ¶
func (fn *SourceFunction) String() string
type SourceInstruction ¶
type SourceInstruction struct {
// the address in memory of the instruction
Addr uint32
// the disassembly entry from the cartridge dissassembly. we don't deal with
// the details of this type in the coprocessor.developer package
Disasm coprocessor.CartCoProcDisasmEntry
// the line of source code this diassembly entry is associated with
Line *SourceLine
// contains filtered or unexported fields
}
SourceInstruction is a single intruction from the ELF binary with a reference to a disassembly supplied by the cartridges coprocessor interface.
Not to be confused with anything in the the coprocessor.disassembly package. SourceInstruction instances are intended to be used by static disasemblers.
func (*SourceInstruction) Opcode ¶
func (d *SourceInstruction) Opcode() string
Opcode returns a string formatted opcode appropriate for the bit length.
func (*SourceInstruction) String ¶
func (d *SourceInstruction) String() string
type SourceLine ¶
type SourceLine struct {
// the actual file/line of the SourceLine. line numbers are counted from one
File *SourceFile
LineNumber int
// the function the line of source can be found within
Function *SourceFunction
// whether this line is to be found inlined elsewhere in the program
Inlined bool
// plain string of line
PlainContent string
// line divided into parts
Fragments []SourceLineFragment
// the list of instructions for this line. will be empty if line is not used
// in the program (eg. a comment line)
//
// note that only instructions for non-inlined ranges will be collated
Instruction []*SourceInstruction
// what are the addresses to use for breakpoints
BreakAddresses []uint32
// whether this source line has been responsible for a likely bug (eg. illegal access of memory)
Bug bool
// statistics for the line
Stats profiling.StatsGroup
// which 2600 kernel has this line executed in
Kernel profiling.Focus
}
SourceLine is a single line of source in a source file, identified by the DWARF data and loaded from the actual source file.
func CreateStubLine ¶
func CreateStubLine(stubFn *SourceFunction) *SourceLine
CreateStubLine returns an instance of SourceLine with the specified SourceFunction assigned to it.
If stubFn is nil then a dummy function will be created.
A stub SourceFile will be created for assignment to the SourceLine.File field.
func (*SourceLine) IsStub ¶
func (ln *SourceLine) IsStub() bool
IsStub returns true if the SourceLine is just a stub.
func (*SourceLine) String ¶
func (ln *SourceLine) String() string
type SourceLineFragment ¶
type SourceLineFragment struct {
Type SourceLineFragmentType
Content string
}
SourceLineFragment represents an single part of the entire source line.
type SourceLineFragmentType ¶
type SourceLineFragmentType int
SourceLineFragmentType defines how a single SourceLineFragment should be interpretted.
const ( FragmentCode SourceLineFragmentType = iota FragmentComment FragmentStringLiteral )
A list of the valid SourceLineFragmentTypes.
type SourceRange ¶
SourceRange is used to specify the effective start and end addresses of a function or a variable.
func (SourceRange) InRange ¶
func (r SourceRange) InRange(addr uint64) bool
InRange returns true if address is in range of start and end addresses
func (SourceRange) String ¶
func (r SourceRange) String() string
String returns the start/end addresses of the range. If the range is inlined then the addresses are printed with square brackets.
type SourceType ¶
type SourceType struct {
Name string
// is a constant type
Constant bool
// the base type of pointer types. will be nil if type is not a pointer type
PointerType *SourceType
// size of values of this type (in bytes)
Size int
// empty if type is not a composite type. see SourceVariable.IsComposite() function
Members []*SourceVariable
// number of elements in the type. if count is more than zero then this
// type is an array. see SourceVariable.IsArry() function
ElementCount int
// the base type of all the elements in the type
ElementType *SourceType
// whether to allow type level conversion of the type
Conversion func(v uint32) (string, any)
}
SourceType is a single type identified by the DWARF data. Composite types are differentiated by the existance of member fields
func (*SourceType) Bin ¶
func (typ *SourceType) Bin() string
Bin returns a format string to represent a value as a correctly padded binary number.
func (*SourceType) Hex ¶
func (typ *SourceType) Hex() string
Hex returns a format string to represent a value as a correctly padded hexadecinal number.
func (*SourceType) IsArray ¶
func (typ *SourceType) IsArray() bool
IsArray returns true if SourceType is an array type.
func (*SourceType) IsComposite ¶
func (typ *SourceType) IsComposite() bool
IsComposite returns true if SourceType is a composite type.
func (*SourceType) IsPointer ¶
func (typ *SourceType) IsPointer() bool
IsPointer returns true if SourceType is a pointer type.
func (*SourceType) Mask ¶
func (typ *SourceType) Mask() uint32
Mask returns the mask value of the correct size for the type.
func (*SourceType) String ¶
func (typ *SourceType) String() string
type SourceVariable ¶
type SourceVariable struct {
// name of variable
Name string
// variable type (int, char, etc.)
Type *SourceType
// first source line for each instance of the function
DeclLine *SourceLine
// if Error is not nil then an error was enountered during a resolve()
// sequence. the error will be logged when the field is first set to true
Error error
// contains filtered or unexported fields
}
SourceVariable is a single variable identified by the DWARF data.
func (*SourceVariable) Address ¶
func (varb *SourceVariable) Address() (uint64, bool)
Address returns the location in memory of the variable referred to by SourceVariable
func (*SourceVariable) Child ¶
func (varb *SourceVariable) Child(i int) *SourceVariable
Child returns the i'th child of the variable. A child can be an array element, composite member or dereferenced variable, as appropriate for the variables SourceType
Count from zero. Returns nil if no such child exists
func (*SourceVariable) IsValid ¶
func (varb *SourceVariable) IsValid() bool
IsValid returns true if the variable has a valid or resolvable value
func (*SourceVariable) NumChildren ¶
func (varb *SourceVariable) NumChildren() int
NumChildren returns the number of children for this variable
func (*SourceVariable) String ¶
func (varb *SourceVariable) String() string
func (*SourceVariable) Update ¶
func (varb *SourceVariable) Update()
Update variable. It should be called periodically before using the return value from Address() or Value()
Be careful to only call this from the emulation goroutine.
func (*SourceVariable) Value ¶
func (varb *SourceVariable) Value() uint32
Value returns the current value of a SourceVariable
func (*SourceVariable) WriteDerivation ¶
func (varb *SourceVariable) WriteDerivation(w io.Writer) error
WriteDerivation outputs the derivation of a varibale to the io.Writer. If the derivation encounters an error the error is returned
Note that the basic information about the variable is not output by this function. The String() function provides that information
type SourceVariableLocal ¶
type SourceVariableLocal struct {
*SourceVariable
// the address range for which the variable is valid
Range SourceRange
}
SourceVariableLocal represents a single local variable identified by the DWARF data.