aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-09-21 01:35:48 +0200
committerRon Evans <[email protected]>2023-09-22 15:28:52 +0200
commit081d2e58c6a9b616b5fc3f19b4ce3850d0f398d8 (patch)
tree91b058871cc9908c32de09a53f900cb614067631 /interp
parented2a98c7d03dd9b02ec4a83f381eb3144ca75ed3 (diff)
downloadtinygo-081d2e58c6a9b616b5fc3f19b4ce3850d0f398d8.tar.gz
tinygo-081d2e58c6a9b616b5fc3f19b4ce3850d0f398d8.zip
interp: print LLVM instruction in traceback
The old traceback would look like this: # internal/godebug /usr/local/go/src/internal/godebug/godebug.go:101:11: interp: test call <2> 0 <3> 0 traceback: /usr/local/go/src/internal/godebug/godebug.go:101:11: call <2> 0 <3> 0 /usr/local/go/src/internal/godebug: call <1> 0 With this patch, it looks like this: # io/fs /usr/local/go/src/io/fs/fs.go:144:45: interp: test %0 = load %runtime._interface, ptr @"internal/oserror.ErrInvalid", align 8, !dbg !316 traceback: /usr/local/go/src/io/fs/fs.go:144:45: %0 = load %runtime._interface, ptr @"internal/oserror.ErrInvalid", align 8, !dbg !316 /usr/local/go/src/io/fs/fs.go:137:28: %0 = call %runtime._interface @"io/fs.errInvalid"(ptr undef), !dbg !317 For developers (like me) who are familiar with LLVM, this is probably easier to read. For users, I'm not sure: the instructions have quite a lot of distracting fluff in them. But at least it contains the function names that are called (which are not currently present in the old traceback). ...that said, having the LLVM instructions in a bug report is probably going to be easier for people who are familar with LLVM.
Diffstat (limited to 'interp')
-rw-r--r--interp/errors.go4
-rw-r--r--interp/interpreter.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/interp/errors.go b/interp/errors.go
index 7aad39fb8..551a18d48 100644
--- a/interp/errors.go
+++ b/interp/errors.go
@@ -60,10 +60,10 @@ func (r *runner) errorAt(inst instruction, err error) *Error {
pos := getPosition(inst.llvmInst)
return &Error{
ImportPath: r.pkgName,
- Inst: inst.String(),
+ Inst: inst.llvmInst.String(),
Pos: pos,
Err: err,
- Traceback: []ErrorLine{{pos, inst.String()}},
+ Traceback: []ErrorLine{{pos, inst.llvmInst.String()}},
}
}
diff --git a/interp/interpreter.go b/interp/interpreter.go
index dcea0044a..3150aca93 100644
--- a/interp/interpreter.go
+++ b/interp/interpreter.go
@@ -543,7 +543,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
// how this function got called.
callErr.Traceback = append(callErr.Traceback, ErrorLine{
Pos: getPosition(inst.llvmInst),
- Inst: inst.String(),
+ Inst: inst.llvmInst.String(),
})
return nil, mem, callErr
}