Log a runtime error and terminate the program.
(format string, args ...interface{})
| 95 | |
| 96 | // Log a runtime error and terminate the program. |
| 97 | func (v *VM) errorf(format string, args ...interface{}) { |
| 98 | i := v.prog[v.t.pc-1] |
| 99 | ProgRuntimeErrors.Add(v.name, 1) |
| 100 | v.runtimeErrorMu.Lock() |
| 101 | v.runtimeError = fmt.Sprintf(format+"\n", args...) |
| 102 | v.runtimeError += fmt.Sprintf( |
| 103 | "Error occurred at instruction %d {%s, %v}, originating in %s at line %d\n", |
| 104 | v.t.pc-1, i.Opcode, i.Operand, v.name, i.SourceLine+1) |
| 105 | v.runtimeError += fmt.Sprintf("Full input text from %q was %q", v.input.Filename, v.input.Line) |
| 106 | if v.logRuntimeErrors || bool(glog.V(1)) { |
| 107 | glog.Info(v.name + ": Runtime error: " + v.runtimeError) |
| 108 | |
| 109 | glog.Infof("Set logging verbosity higher (-v1 or more) to see full VM state dump.") |
| 110 | } |
| 111 | if glog.V(1) { |
| 112 | glog.Infof("VM stack:\n%s", debug.Stack()) |
| 113 | glog.Infof("Dumping vm state") |
| 114 | glog.Infof("Name: %s", v.name) |
| 115 | glog.Infof("Input: %#v", v.input) |
| 116 | glog.Infof("Thread:") |
| 117 | glog.Infof(" PC %v", v.t.pc-1) |
| 118 | glog.Infof(" Matched %v", v.t.matched) |
| 119 | glog.Infof(" Matches %v", v.t.matches) |
| 120 | glog.Infof(" Timestamp %v", v.t.time) |
| 121 | glog.Infof(" Stack %v", v.t.stack) |
| 122 | glog.Infof(v.DumpByteCode()) |
| 123 | } |
| 124 | if v.trace != nil { |
| 125 | glog.Infof("Execution Trace: %v", v.trace) |
| 126 | } |
| 127 | v.runtimeErrorMu.Unlock() |
| 128 | v.terminate = true |
| 129 | } |
| 130 | |
| 131 | func (t *thread) PopInt() (int64, error) { |
| 132 | val := t.Pop() |
no test coverage detected