// Error paths through this code will default the version to 1.1.
t.version = ver11
- defer func() {
- // If we panic parsing, assume it's a Go 1.1 pclntab.
- recover()
- }()
+ if !disableRecover {
+ defer func() {
+ // If we panic parsing, assume it's a Go 1.1 pclntab.
+ recover()
+ }()
+ }
// Check header: 4-byte magic, two zeros, pc quantum, pointer size.
if len(t.Data) < 16 || t.Data[4] != 0 || t.Data[5] != 0 ||
// go12Funcs returns a slice of Funcs derived from the Go 1.2 pcln table.
func (t *LineTable) go12Funcs() []Func {
// Assume it is malformed and return nil on error.
- defer func() {
- recover()
- }()
+ if !disableRecover {
+ defer func() {
+ recover()
+ }()
+ }
n := len(t.functab) / int(t.ptrsize) / 2
funcs := make([]Func, n)
// go12PCToLine maps program counter to line number for the Go 1.2 pcln table.
func (t *LineTable) go12PCToLine(pc uint64) (line int) {
defer func() {
- if recover() != nil {
+ if !disableRecover && recover() != nil {
line = -1
}
}()
// go12PCToFile maps program counter to file name for the Go 1.2 pcln table.
func (t *LineTable) go12PCToFile(pc uint64) (file string) {
defer func() {
- if recover() != nil {
+ if !disableRecover && recover() != nil {
file = ""
}
}()
// go12LineToPC maps a (file, line) pair to a program counter for the Go 1.2/1.16 pcln table.
func (t *LineTable) go12LineToPC(file string, line int) (pc uint64) {
defer func() {
- if recover() != nil {
+ if !disableRecover && recover() != nil {
pc = 0
}
}()
// Every key maps to obj. That's not a very interesting map, but it provides
// a way for callers to obtain the list of files in the program.
func (t *LineTable) go12MapFiles(m map[string]*Obj, obj *Obj) {
- defer func() {
- recover()
- }()
+ if !disableRecover {
+ defer func() {
+ recover()
+ }()
+ }
t.initFileMap()
for file := range t.fileMap {
m[file] = obj
}
}
+
+// disableRecover causes this package not to swallow panics.
+// This is useful when making changes.
+const disableRecover = false