CachedFile contains the content of a file split into lines.
type CachedFile struct { FileName string Lines [][]byte }
Disasm is a disassembler for a given File.
type Disasm struct {
// contains filtered or unexported fields
}
func DisasmForFile(f *objfile.File) (*Disasm, error)
DisasmForFile returns a disassembler for the file f.
func (d *Disasm) Decode(start, end uint64, relocs []objfile.Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string))
Decode disassembles the text segment range [start, end), calling f for each instruction.
func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, printCode bool, gnuAsm bool)
Print prints a disassembly of the file to w. If filter is non-nil, the disassembly only includes functions with names matching filter. If printCode is true, the disassembly includes corresponding source lines. The disassembly only includes functions that overlap the range [start, end).
FileCache is a simple LRU cache of file contents.
type FileCache struct {
// contains filtered or unexported fields
}
func NewFileCache(maxLen int) *FileCache
NewFileCache returns a FileCache which can contain up to maxLen cached file contents.
func (fc *FileCache) Line(filename string, line int) ([]byte, error)
Line returns the source code line for the given file and line number. If the file is not already cached, reads it, inserts it into the cache, and removes the least recently used file if necessary. If the file is in cache, it is moved to the front of the list.