_g_ := getg()
var t sigTabT
var docrash bool
- var length int
var sig int
var flags int
c := &sigctxt{_ureg}
+ notestr := gostringnocopy(note)
// The kernel will never pass us a nil note or ureg so we probably
// made a mistake somewhere in sigtramp.
}
// Check that the note is no more than ERRMAX bytes (including
// the trailing NUL). We should never receive a longer note.
- length = findnull(note)
- if length > _ERRMAX-1 {
+ if len(notestr) > _ERRMAX-1 {
print("sighandler: note is longer than ERRMAX\n")
goto Throw
}
// level by the program but will otherwise be ignored.
flags = _SigNotify
for sig, t = range sigtable {
- n := len(t.name)
- if length < n {
- continue
- }
- if strncmp(note, &t.name[0], uintptr(n)) == 0 {
+ if hasprefix(notestr, t.name) {
flags = t.flags
break
}
if flags&_SigPanic != 0 {
// Copy the error string from sigtramp's stack into m->notesig so
// we can reliably access it from the panic routines.
- memmove(unsafe.Pointer(_g_.m.notesig), unsafe.Pointer(note), uintptr(length+1))
+ memmove(unsafe.Pointer(_g_.m.notesig), unsafe.Pointer(note), uintptr(len(notestr)+1))
gp.sig = uint32(sig)
gp.sigpc = c.pc()
// Only push sigpanic if PC != 0.
_g_.m.throwing = 1
_g_.m.caughtsig = gp
startpanic()
- print(gostringnocopy(note), "\n")
+ print(notestr, "\n")
print("PC=", hex(c.pc()), "\n")
print("\n")
if gotraceback(&docrash) > 0 {
type sigTabT struct {
flags int
- name []byte
+ name string
}
// Incoming notes are compared against this table using strncmp, so the
// and also update the constant values is os2_plan9.go.
var sigtable = [...]sigTabT{
// Traps that we cannot be recovered.
- {_SigThrow, []byte("sys: trap: debug exception")},
- {_SigThrow, []byte("sys: trap: invalid opcode")},
+ {_SigThrow, "sys: trap: debug exception"},
+ {_SigThrow, "sys: trap: invalid opcode"},
// We can recover from some memory errors in runtime·sigpanic.
- {_SigPanic, []byte("sys: trap: fault read addr")}, // SIGRFAULT
- {_SigPanic, []byte("sys: trap: fault write addr")}, // SIGWFAULT
+ {_SigPanic, "sys: trap: fault read addr"}, // SIGRFAULT
+ {_SigPanic, "sys: trap: fault write addr"}, // SIGWFAULT
// We can also recover from math errors.
- {_SigPanic, []byte("sys: trap: divide error")}, // SIGINTDIV
- {_SigPanic, []byte("sys: fp:")}, // SIGFLOAT
+ {_SigPanic, "sys: trap: divide error"}, // SIGINTDIV
+ {_SigPanic, "sys: fp:"}, // SIGFLOAT
// All other traps are normally handled as if they were marked SigThrow.
// We mark them SigPanic here so that debug.SetPanicOnFault will work.
- {_SigPanic, []byte("sys: trap:")}, // SIGTRAP
+ {_SigPanic, "sys: trap:"}, // SIGTRAP
// Writes to a closed pipe can be handled if desired, otherwise they're ignored.
- {_SigNotify, []byte("sys: write on closed pipe")},
+ {_SigNotify, "sys: write on closed pipe"},
// Other system notes are more serious and cannot be recovered.
- {_SigThrow, []byte("sys:")},
+ {_SigThrow, "sys:"},
// Issued to all other procs when calling runtime·exit.
- {_SigGoExit, []byte("go: exit ")},
+ {_SigGoExit, "go: exit "},
// Kill is sent by external programs to cause an exit.
- {_SigKill, []byte("kill")},
+ {_SigKill, "kill"},
// Interrupts can be handled if desired, otherwise they cause an exit.
- {_SigNotify + _SigKill, []byte("interrupt")},
- {_SigNotify + _SigKill, []byte("hangup")},
+ {_SigNotify + _SigKill, "interrupt"},
+ {_SigNotify + _SigKill, "hangup"},
// Alarms can be handled if desired, otherwise they're ignored.
- {_SigNotify, []byte("alarm")},
+ {_SigNotify, "alarm"},
}