本文整理汇总了Golang中debug/gosym.NewTable函数的典型用法代码### 示例。如果您正苦于以下问题:Golang NewTable函数的具体用法?Golang NewTable怎么用?Golang NewTable使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了NewTable函数的13个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: obtainGoSymbols

func (dbp *Process) obtainGoSymbols(exe *macho.File, wg *sync.WaitGroup) {
    defer wg.Done()

    var (
        symdat  []byte
        pclndat []byte
        err     error
    )

    if sec := exe.Section("__gosymtab"); sec != nil {
        symdat, err = sec.Data()
        if err != nil {
            fmt.Println("could not get .gosymtab section", err)
            os.Exit(1)
        }
    }

    if sec := exe.Section("__gopclntab"); sec != nil {
        pclndat, err = sec.Data()
        if err != nil {
            fmt.Println("could not get .gopclntab section", err)
            os.Exit(1)
        }
    }

    pcln := gosym.NewLineTable(pclndat, exe.Section("__text").Addr)
    tab, err := gosym.NewTable(symdat, pcln)
    if err != nil {
        fmt.Println("could not get initialize line table", err)
        os.Exit(1)
    }

    dbp.goSymTable = tab
}

开发者ID:alaska,项目名称:delve,代码行数:34,代码来源:proc_darwin.go

示例2: PCLineTable

func (f *File) PCLineTable() (*gosym.Table, error) {
    textStart, symtab, pclntab, err := f.raw.pcln()
    if err != nil {
        return nil, err
    }
    return gosym.NewTable(symtab, gosym.NewLineTable(pclntab, textStart))
}

开发者ID:Greentor,项目名称:go,代码行数:7,代码来源:objfile.go

示例3: elfGoSyms

func elfGoSyms(f *elf.File) (*gosym.Table, os.Error) {
    text := f.Section(".text")
    symtab := f.Section(".gosymtab")
    pclntab := f.Section(".gopclntab")
    if text == nil || symtab == nil || pclntab == nil {
        return nil, nil
    }

    symdat, err := symtab.Data()
    if err != nil {
        return nil, err
    }
    pclndat, err := pclntab.Data()
    if err != nil {
        return nil, err
    }

    pcln := gosym.NewLineTable(pclndat, text.Addr)
    tab, err := gosym.NewTable(symdat, pcln)
    if err != nil {
        return nil, err
    }

    return tab, nil
}

开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:25,代码来源:process.go

示例4: symbolTable

func symbolTable() *gosym.Table {
    attempts := []func() (uint64, []byte, []byte, error){
        pclnElf,
        pclnMacho,
        pclnPE,
        pclnPlan9,
    }

    var errors []error

    for _, a := range attempts {
        textStart, symtab, pclntab, err := a()
        if err == nil {
            var table *gosym.Table
            table, err = gosym.NewTable(symtab, gosym.NewLineTable(pclntab, textStart))
            if err == nil {
                return table
            }
        }
        errors = append(errors, err)
    }

    for _, err := range errors {
        fmt.Fprintln(os.Stderr, err)
    }
    flagset.Usage()
    os.Exit(1)
    panic("unreachable")
}

开发者ID:BenLubar,项目名称:bit,代码行数:29,代码来源:main.go

示例5: main

func main() {
    log.SetFlags(0)
    log.SetPrefix("addr2line: ")

    // pprof expects this behavior when checking for addr2line
    if len(os.Args) > 1 && os.Args[1] == "--help" {
        printUsage(os.Stdout)
        os.Exit(0)
    }

    flag.Usage = usage
    flag.Parse()
    if flag.NArg() != 1 {
        usage()
    }

    f, err := os.Open(flag.Arg(0))
    if err != nil {
        log.Fatal(err)
    }

    textStart, symtab, pclntab, err := loadTables(f)
    if err != nil {
        log.Fatalf("reading %s: %v", flag.Arg(0), err)
    }

    pcln := gosym.NewLineTable(pclntab, textStart)
    tab, err := gosym.NewTable(symtab, pcln)
    if err != nil {
        log.Fatalf("reading %s: %v", flag.Arg(0), err)
    }

    stdin := bufio.NewScanner(os.Stdin)
    stdout := bufio.NewWriter(os.Stdout)

    for stdin.Scan() {
        p := stdin.Text()
        if strings.Contains(p, ":") {
            // Reverse translate file:line to pc.
            // This was an extension in the old C version of 'go tool addr2line'
            // and is probably not used by anyone, but recognize the syntax.
            // We don't have an implementation.
            fmt.Fprintf(stdout, "!reverse translation not implemented\n")
            continue
        }
        pc, _ := strconv.ParseUint(p, 16, 64)
        file, line, fn := tab.PCToLine(pc)
        name := "?"
        if fn != nil {
            name = fn.Name
        } else {
            file = "?"
            line = 0
        }
        fmt.Fprintf(stdout, "%s\n%s:%d\n", name, file, line)
    }
    stdout.Flush()
}

开发者ID:TomHoenderdos,项目名称:go-sunos,代码行数:58,代码来源:main.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng