// LineToPC converts a file/line location to a PC. It performs a "fuzzy" search
// on the filename similar to FuncToPC.
LineToPC converts a file/line location to a PC. It performs a "fuzzy" search
on the filename similar to FuncToPC.
// LineToPC converts a file / line location to a PC . It performs a " fuzzy " search // on the filename similar to FuncToPC .
func (b *BinFile) LineToPC(file string, line int) (uint64, error) {
	if b.lines == nil {
		return 0, errors.New("no DWARF debugging data")
	}
	addrs, ok := b.lines[line]
	if !ok {
		return 0, fmt.Errorf("%s:%d has no associated PC", file, line)
	}
	var addr uint64
	matches := make([]string, 0)
	for _, fa := range addrs {
		if fa.file == file {
			return fa.addr, nil
		} else if strings.Contains(fa.file, file) {
			matches = append(matches, fa.file)
			addr = fa.addr
		}
	}
	if len(matches) == 1 {
		return addr, nil
	} else if len(matches) == 0 {
		return 0, fmt.Errorf("%s:%d has no associated PC", file, line)
	}
	return 0, &ErrMultipleMatches{
		Matches: matches,
	}
}
func ( b * BinFile ) LineToPC ( file string , line int ) ( uint64 , error ) { if b . lines == nil { return 0 , errors . New ( " " ) } addrs , ok := b . lines [ line ] if ! ok { return 0 , fmt . Errorf ( " " , file , line ) } var addr uint64 matches := make ( [ ] string , 0 ) for _ , fa := range addrs { if fa . file == file { return fa . addr , nil } else if strings . Contains ( fa . file , file ) { matches = append ( matches , fa . file ) addr = fa . addr } } if len ( matches ) == 1 { return addr , nil } else if len ( matches ) == 0 { return 0 , fmt . Errorf ( " " , file , line ) } return 0 , & ErrMultipleMatches { Matches : matches , } }
LineToPC converts a file/line location to a PC.
LineToPC converts a file / line location to a PC .