MCPcopy Create free account
hub / github.com/google/pprof / openPE

Method openPE

internal/binutils/binutils.go:498–523  ·  view source on GitHub ↗
(name string, start, limit, offset uint64)

Source from the content-addressed store, hash-verified

496}
497
498func (b *binrep) openPE(name string, start, limit, offset uint64) (plugin.ObjFile, error) {
499 pf, err := pe.Open(name)
500 if err != nil {
501 return nil, fmt.Errorf("error parsing %s: %v", name, err)
502 }
503 defer pf.Close()
504
505 var imageBase uint64
506 switch h := pf.OptionalHeader.(type) {
507 case *pe.OptionalHeader32:
508 imageBase = uint64(h.ImageBase)
509 case *pe.OptionalHeader64:
510 imageBase = uint64(h.ImageBase)
511 default:
512 return nil, fmt.Errorf("unknown OptionalHeader %T", pf.OptionalHeader)
513 }
514
515 var base uint64
516 if start > 0 {
517 base = start - imageBase
518 }
519 if b.fast || (!b.addr2lineFound && !b.llvmSymbolizerFound) {
520 return &fileNM{file: file{b: b, name: name, base: base}}, nil
521 }
522 return &fileAddr2Line{file: file{b: b, name: name, base: base}}, nil
523}
524
525// elfMapping stores the parameters of a runtime mapping that are needed to
526// identify the ELF segment associated with a mapping.

Callers 1

OpenMethod · 0.80

Calls 2

OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected