delve/dwarf/_helper/helper.go
Derek Parker a788e03c7b Implement initial next implementation
This current implementation does not cover the following:

* Setting correct breakpoint when exiting loop
* Setting correct breakpoint when returning from function
    * All facilities are available for this, it just is not taken into
      account in the current `next` implementation.
2014-07-07 08:26:36 -05:00

43 lines
680 B
Go

package dwarfhelper
import (
"debug/elf"
"debug/gosym"
"os"
"testing"
)
func GosymData(testfile string, t *testing.T) *gosym.Table {
f, err := os.Open(testfile)
if err != nil {
t.Fatal(err)
}
e, err := elf.NewFile(f)
if err != nil {
t.Fatal(err)
}
return parseGoSym(t, e)
}
func parseGoSym(t *testing.T, exe *elf.File) *gosym.Table {
symdat, err := exe.Section(".gosymtab").Data()
if err != nil {
t.Fatal(err)
}
pclndat, err := exe.Section(".gopclntab").Data()
if err != nil {
t.Fatal(err)
}
pcln := gosym.NewLineTable(pclndat, exe.Section(".text").Addr)
tab, err := gosym.NewTable(symdat, pcln)
if err != nil {
t.Fatal(err)
}
return tab
}