gosym
5 分钟阅读
Package gosym implements access to the Go symbol and line number tables embedded in Go binaries generated by the gc compilers.
gosym
包实现了对由 gc 编译器生成的 Go 二进制文件中嵌入的符号和行号表的访问。
常量
This section is empty.
变量
This section is empty.
函数
This section is empty.
类型
type DecodingError
|
|
DecodingError represents an error during the decoding of the symbol table.
DecodingError
表示在解码符号表过程中发生的错误。
(*DecodingError) Error
|
|
type Func
|
|
A Func collects information about a single function.
Func
收集关于单个函数的信息。
type LineTable
|
|
A LineTable is a data structure mapping program counters to line numbers.
LineTable
是一个将程序计数器映射到行号的数据结构。
In Go 1.1 and earlier, each function (represented by a Func) had its own LineTable, and the line number corresponded to a numbering of all source lines in the program, across all files. That absolute line number would then have to be converted separately to a file name and line number within the file.
在 Go 1.1 及之前的版本中,每个函数(由 Func 表示)都有自己的 LineTable,而行号对应于程序中所有文件的所有源代码行的编号。然后,该绝对行号必须单独转换为文件名和文件内的行号。
In Go 1.2, the format of the data changed so that there is a single LineTable for the entire program, shared by all Funcs, and there are no absolute line numbers, just line numbers within specific files.
在 Go 1.2 中,数据的格式发生了变化,整个程序共享一个 LineTable,由所有的 Func 共享,并且没有绝对行号,只有特定文件内的行号。
For the most part, LineTable’s methods should be treated as an internal detail of the package; callers should use the methods on Table instead.
在大多数情况下,LineTable 的方法应被视为包的内部细节;调用者应使用 Table 上的方法。
func NewLineTable
|
|
NewLineTable returns a new PC/line table corresponding to the encoded data. Text must be the start address of the corresponding text segment.
NewLineTable
返回对应于编码数据的新的 PC/行号表。Text 必须是相应文本段的起始地址。
(*LineTable) LineToPC <- DEPRECATED
|
|
LineToPC returns the program counter for the given line number, considering only program counters before maxpc.
Deprecated: Use Table’s LineToPC method instead.
func (*LineTable) PCToLine <-DEPRECATED
|
|
PCToLine returns the line number for the given program counter.
Deprecated: Use Table’s PCToLine method instead.
type Obj
|
|
An Obj represents a collection of functions in a symbol table.
Obj
表示符号表中的一组函数。
The exact method of division of a binary into separate Objs is an internal detail of the symbol table format.
将二进制文件划分为单独的 Obj 的确切方法是符号表格式的内部细节。
In early versions of Go each source file became a different Obj.
在早期的 Go 版本中,每个源文件成为不同的 Obj。
In Go 1 and Go 1.1, each package produced one Obj for all Go sources and one Obj per C source file.
在 Go 1 和 Go 1.1 中,每个包为所有的 Go 源文件产生一个 Obj,并为每个 C 源文件产生一个 Obj。
In Go 1.2, there is a single Obj for the entire program.
在 Go 1.2 中,整个程序只有一个 Obj。
type Sym
|
|
A Sym represents a single symbol table entry.
Sym
表示单个符号表条目。
(*Sym) BaseName
|
|
BaseName returns the symbol name without the package or receiver name.
BaseName
返回不包含包名或接收器名称的符号名。
(*Sym) PackageName
|
|
PackageName returns the package part of the symbol name, or the empty string if there is none.
PackageName
返回符号名的包部分,如果没有则返回空字符串。
(*Sym) ReceiverName
|
|
ReceiverName returns the receiver type name of this symbol, or the empty string if there is none. A receiver name is only detected in the case that s.Name is fully-specified with a package name.
ReceiverName
返回此符号的接收器类型名称,如果没有则返回空字符串。仅在 s.Name 完全指定了包名的情况下才检测到接收器名称。
(*Sym) Static
|
|
Static reports whether this symbol is static (not visible outside its file).
Static
报告此符号是否为静态符号(在其文件外不可见)。
type Table
|
|
Table represents a Go symbol table. It stores all of the symbols decoded from the program and provides methods to translate between symbols, names, and addresses.
Table
表示 Go 符号表。它存储从程序中解码的所有符号,并提供在符号、名称和地址之间进行转换的方法。
func NewTable
|
|
NewTable decodes the Go symbol table (the “.gosymtab” section in ELF), returning an in-memory representation. Starting with Go 1.3, the Go symbol table no longer includes symbol data.
NewTable
解码 Go 符号表(ELF 中的 “.gosymtab” 部分),返回一个内存中的表示。从 Go 1.3 开始,Go 符号表不再包含符号数据。
(*Table) LineToPC
|
|
LineToPC looks up the first program counter on the given line in the named file. It returns UnknownPathError or UnknownLineError if there is an error looking up this line.
LineToPC
在指定文件中查找给定行号上的第一个程序计数器。如果查找该行时出现错误,将返回 UnknownPathError 或 UnknownLineError。
(*Table) LookupFunc
|
|
LookupFunc returns the text, data, or bss symbol with the given name, or nil if no such symbol is found.
LookupFunc
返回具有给定名称的文本、数据或 bss 符号,如果找不到此类符号,则返回 nil。
(*Table) LookupSym
|
|
LookupSym returns the text, data, or bss symbol with the given name, or nil if no such symbol is found.
LookupSym
返回具有给定名称的文本、数据或 bss 符号,如果找不到此类符号,则返回 nil。
(*Table) PCToFunc
|
|
PCToFunc returns the function containing the program counter pc, or nil if there is no such function.
PCToFunc
返回包含程序计数器 pc 的函数,如果没有这样的函数,则返回 nil。
(*Table) PCToLine
|
|
PCToLine looks up line number information for a program counter. If there is no information, it returns fn == nil.
PCToLine
查找程序计数器的行号信息。如果没有信息,则返回 fn == nil。
(*Table) SymByAddr
|
|
SymByAddr returns the text, data, or bss symbol starting at the given address.
SymByAddr
返回以给定地址开始的文本、数据或 bss 符号。
type UnknownFileError
|
|
UnknownFileError represents a failure to find the specific file in the symbol table.
UnknownLineError
表示无法将行号映射到程序计数器,原因是行号超出文件范围或给定行上没有代码。
(UnknownFileError) Error
|
|
type UnknownLineError
|
|
UnknownLineError represents a failure to map a line to a program counter, either because the line is beyond the bounds of the file or because there is no code on the given line.
UnknownLineError
表示将行号映射到程序计数器失败,可能是因为行号超出文件范围或给定行上没有代码。
(*UnknownLineError) Error
|
|