目录搜索
archivearchive/tararchive/zipbufiobufio(缓存)builtinbuiltin(内置包)bytesbytes(包字节)compresscompress/bzip2(压缩/bzip2)compress/flate(压缩/flate)compress/gzip(压缩/gzip)compress/lzw(压缩/lzw)compress/zlib(压缩/zlib)containercontainer/heap(容器数据结构heap)container/list(容器数据结构list)container/ring(容器数据结构ring)contextcontext(上下文)cryptocrypto(加密)crypto/aes(加密/aes)crypto/cipher(加密/cipher)crypto/des(加密/des)crypto/dsa(加密/dsa)crypto/ecdsa(加密/ecdsa)crypto/elliptic(加密/elliptic)crypto/hmac(加密/hmac)crypto/md5(加密/md5)crypto/rand(加密/rand)crypto/rc4(加密/rc4)crypto/rsa(加密/rsa)crypto/sha1(加密/sha1)crypto/sha256(加密/sha256)crypto/sha512(加密/sha512)crypto/subtle(加密/subtle)crypto/tls(加密/tls)crypto/x509(加密/x509)crypto/x509/pkix(加密/x509/pkix)databasedatabase/sql(数据库/sql)database/sql/driver(数据库/sql/driver)debugdebug/dwarf(调试/dwarf)debug/elf(调试/elf)debug/gosym(调试/gosym)debug/macho(调试/macho)debug/pe(调试/pe)debug/plan9obj(调试/plan9obj)encodingencoding(编码)encoding/ascii85(编码/ascii85)encoding/asn1(编码/asn1)encoding/base32(编码/base32)encoding/base64(编码/base64)encoding/binary(编码/binary)encoding/csv(编码/csv)encoding/gob(编码/gob)encoding/hex(编码/hex)encoding/json(编码/json)encoding/pem(编码/pem)encoding/xml(编码/xml)errorserrors(错误)expvarexpvarflagflag(命令行参数解析flag包)fmtfmtgogo/ast(抽象语法树)go/buildgo/constant(常量)go/doc(文档)go/format(格式)go/importergo/parsergo/printergo/scanner(扫描仪)go/token(令牌)go/types(类型)hashhash(散列)hash/adler32hash/crc32hash/crc64hash/fnvhtmlhtmlhtml/template(模板)imageimage(图像)image/color(颜色)image/color/palette(调色板)image/draw(绘图)image/gifimage/jpegimage/pngindexindex/suffixarrayioioio/ioutillogloglog/syslog(日志系统)mathmathmath/bigmath/bigmath/bitsmath/bitsmath/cmplxmath/cmplxmath/randmath/randmimemimemime/multipart(多部分)mime/quotedprintablenetnetnet/httpnet/httpnet/http/cginet/http/cookiejarnet/http/fcginet/http/httptestnet/http/httptracenet/http/httputilnet/http/internalnet/http/pprofnet/mailnet/mailnet/rpcnet/rpcnet/rpc/jsonrpcnet/smtpnet/smtpnet/textprotonet/textprotonet/urlnet/urlososos/execos/signalos/userpathpathpath/filepath(文件路径)pluginplugin(插件)reflectreflect(反射)regexpregexp(正则表达式)regexp/syntaxruntimeruntime(运行时)runtime/debug(调试)runtime/internal/sysruntime/pprofruntime/race(竞争)runtime/trace(执行追踪器)sortsort(排序算法)strconvstrconv(转换)stringsstrings(字符串)syncsync(同步)sync/atomic(原子操作)syscallsyscall(系统调用)testingtesting(测试)testing/iotesttesting/quicktexttext/scanner(扫描文本)text/tabwritertext/template(定义模板)text/template/parsetimetime(时间戳)unicodeunicodeunicode/utf16unicode/utf8unsafeunsafe
文字

  • import "debug/gosym"

  • 概述

  • 参数

概述

gosym 包可以访问由 gc 编译器生成的 Go 二进制文件中嵌入的 Go 符号和行号表。

参数

  • type DecodingError

  • func (e *DecodingError) Error() string

  • type Func

  • type LineTable

  • func NewLineTable(data []byte, text uint64) *LineTable

  • func (t *LineTable) LineToPC(line int, maxpc uint64) uint64

  • func (t *LineTable) PCToLine(pc uint64) int

  • type Obj

  • type Sym

  • func (s *Sym) BaseName() string

  • func (s *Sym) PackageName() string

  • func (s *Sym) ReceiverName() string

  • func (s *Sym) Static() bool

  • type Table

  • func NewTable(symtab []byte, pcln *LineTable) (*Table, error)

  • func (t *Table) LineToPC(file string, line int) (pc uint64, fn *Func, err error)

  • func (t *Table) LookupFunc(name string) *Func

  • func (t *Table) LookupSym(name string) *Sym

  • func (t *Table) PCToFunc(pc uint64) *Func

  • func (t *Table) PCToLine(pc uint64) (file string, line int, fn *Func)

  • func (t *Table) SymByAddr(addr uint64) *Sym

  • type UnknownFileError

  • func (e UnknownFileError) Error() string

  • type UnknownLineError

  • func (e *UnknownLineError) Error() string

打包文件

pclntab.go symtab.go

type DecodingError

DecodingError表示解码符号表时发生错误。

type DecodingError struct {        // 包含过滤或未导出的字段}

func (*DecodingError) Error

func (e *DecodingError) Error() string

type Func

Func 收集有关单个功能的信息。

type Func struct {
        Entry uint64        *Sym
        End       uint64
        Params    []*Sym
        Locals    []*Sym
        FrameSize int
        LineTable *LineTable
        Obj       *Obj}

type LineTable

LineTable 是一个数据结构映射程序计数器到行号。

在 Go 1.1 及更早版本中,每个函数(由 Func 表示)都有自己的 LineTable,并且行号对应于程序中所有源文件行中所有文件的编号。绝对行号将不得不单独转换为文件内的文件名和行号。

在 Go 1.2 中,数据的格式发生了变化,因此整个程序都有一个 LineTable,由所有 Funcs 共享,并且没有绝对行号,只有特定文件中的行号。

大多数情况下,LineTable 的方法应该被视为包的内部细节; 调用者应该使用 Table 上的方法。

type LineTable struct {
        Data []byte
        PC   uint64
        Line int        // 包含过滤或未导出的字段}

func NewLineTable

func NewLineTable(data []byte, text uint64) *LineTable

NewLineTable 返回与编码数据对应的新PC/line 表。文本必须是相应文本段的起始地址。

func (*LineTable) LineToPC

func (t *LineTable) LineToPC(line int, maxpc uint64) uint64

LineToPC 返回给定行号的程序计数器,只考虑maxpc 之前的程序计数器。调用者应该使用 Table 的 LineToPC 方法。

func (*LineTable) PCToLine

func (t *LineTable) PCToLine(pc uint64) int

PCToLine 返回给定程序计数器的行号。调用者应该使用 Table 的 PCToLine 方法。

type Obj

Obj 表示符号表中的函数集合。

将二进制分割成单独的 Objs 的确切方法是符号表格式的内部细节。

在Go的早期版本中,每个源文件都变成了不同的 Obj。

在Go 1和Go 1.1中,每个软件包为所有 Go 源和每个C源文件创建一个 Obj。

在Go 1.2中,整个程序都有一个Obj。

type Obj struct {        // Funcs是Obj中的函数列表。
        Funcs []Func        // 在Go 1.1和更早版本中,路径是相应符号的列表        // 到产生Obj的源文件名。        // 在Go 1.2中,Paths是零。        // 使用Table.Files的键获取源文件列表。
        Paths []Sym // 元(meta)}

type Sym

Sym代表一个符号表项。

type Sym struct {
        Value  uint64
        Type   byte
        Name   string
        GoType uint64        // 如果此符号是函数符号,则对应Func
        Func *Func}

func (*Sym) BaseName

func (s *Sym) BaseName() string

BaseName返回没有包名或接收者名称的符号名称。

func (*Sym) PackageName

func (s *Sym) PackageName() string

PackageName 返回符号名称的包部分,如果没有则返回空字符串。

func (*Sym) ReceiverName

func (s *Sym) ReceiverName() string

ReceiverName 返回此符号的接收器类型名称,如果没有,则返回空字符串。

func (*Sym) Static

func (s *Sym) Static() bool

静态报告此符号是否为静态(在其文件外部不可见)。

type Table

表格代表一个 Go 符号表。它存储从程序解码的所有符号,并提供在符号,名称和地址之间进行转换的方法。

type Table struct {
        Syms  []Sym
        Funcs []Func
        Files map[string]*Obj // 无论是Go 1.2还是更高版本的二进制文件
        Objs  []Obj           // 无论是Go 1.2还是更高版本的二进制文件        // 包含过滤或未导出的字段}

func NewTable

func NewTable(symtab []byte, pcln *LineTable) (*Table, error)

NewTable 对数据中的 Go 符号表进行解码,返回一个内存中表示。

func (*Table) LineToPC

func (t *Table) LineToPC(file string, line int) (pc uint64, fn *Func, err error)

LineToPC 在指定文件的给定行中查找第一个程序计数器。如果查找此行时发生错误,它将返回 UnknownPathError 或 UnknownLineError。

func (*Table) LookupFunc

func (t *Table) LookupFunc(name string) *Func

LookupFunc 返回给定名称的文本,数据或 bss 符号,如果没有找到这样的符号,则返回 nil。

func (*Table) LookupSym

func (t *Table) LookupSym(name string) *Sym

LookupSym 返回给定名称的文本,数据或 bss 符号,如果没有找到这样的符号,则返回 nil。

func (*Table) PCToFunc

func (t *Table) PCToFunc(pc uint64) *Func

PCToFunc 返回包含程序计数器 pc 的函数,如果没有这种函数,则返回 nil。

func (*Table) PCToLine

func (t *Table) PCToLine(pc uint64) (file string, line int, fn *Func)

PCToLine 查找程序计数器的行号信息。如果没有信息,则返回 fn == nil。

func (*Table) SymByAddr

func (t *Table) SymByAddr(addr uint64) *Sym

SymByAddr 返回从给定地址开始的文本,数据或 bss 符号。

type UnknownFileError

UnknownFileError 表示找不到符号表中的特定文件。

type UnknownFileError string

func (UnknownFileError) Error

func (e UnknownFileError) Error() string

type UnknownLineError

UnknownLineError 表示无法将行映射到程序计数器,因为行超出了文件的界限或者因为给定行上没有代码。

type UnknownLineError struct {
        File string
        Line int}

func (*UnknownLineError) Error

func (e *UnknownLineError) Error() string
上一篇:下一篇: