Format sigaction in strace
Sample: I1206 14:24:56.768520 3700 x:0] [ 1] ioctl_test E rt_sigaction(SIGSEGV, 0x7ee6edb0c590 {Handler: 0x559c6d915cf0, Flags: SA_SIGINFO|SA_RESTORER|SA_ONSTACK|SA_NODEFER, Restorer: 0x2a9901a259a0, Mask: []}, 0x7ee6edb0c630) I1206 14:24:56.768530 3700 x:0] [ 1] ioctl_test X rt_sigaction(SIGSEGV, 0x7ee6edb0c590 {Handler: 0x559c6d915cf0, Flags: SA_SIGINFO|SA_RESTORER|SA_ONSTACK|SA_NODEFER, Restorer: 0x2a9901a259a0, Mask: []}, 0x7ee6edb0c630 {Handler: SIG_DFL, Flags: 0x0, Restorer: 0x0, Mask: []}) = 0x0 (2.701?s) PiperOrigin-RevId: 224596606 Change-Id: I3512493aed99d3d75600249263da46686b1dc0e7
This commit is contained in:
parent
673949048e
commit
42e2e5cae9
|
@ -43,6 +43,11 @@ func (s FlagSet) Parse(val uint64) string {
|
|||
flags = append(flags, "0x"+strconv.FormatUint(val, 16))
|
||||
}
|
||||
|
||||
if len(flags) == 0 {
|
||||
// Prefer 0 to an empty string.
|
||||
return "0x0"
|
||||
}
|
||||
|
||||
return strings.Join(flags, "|")
|
||||
}
|
||||
|
||||
|
|
|
@ -165,15 +165,16 @@ const (
|
|||
|
||||
// Signal action flags for rt_sigaction(2), from uapi/asm-generic/signal.h
|
||||
const (
|
||||
SA_NOCLDSTOP = 0x00000001
|
||||
SA_NOCLDWAIT = 0x00000002
|
||||
SA_SIGINFO = 0x00000004
|
||||
SA_ONSTACK = 0x08000000
|
||||
SA_RESTART = 0x10000000
|
||||
SA_NODEFER = 0x40000000
|
||||
SA_RESTARTHAND = 0x80000000
|
||||
SA_NOMASK = SA_NODEFER
|
||||
SA_ONESHOT = SA_RESTARTHAND
|
||||
SA_NOCLDSTOP = 0x00000001
|
||||
SA_NOCLDWAIT = 0x00000002
|
||||
SA_SIGINFO = 0x00000004
|
||||
SA_RESTORER = 0x04000000
|
||||
SA_ONSTACK = 0x08000000
|
||||
SA_RESTART = 0x10000000
|
||||
SA_NODEFER = 0x40000000
|
||||
SA_RESETHAND = 0x80000000
|
||||
SA_NOMASK = SA_NODEFER
|
||||
SA_ONESHOT = SA_RESETHAND
|
||||
)
|
||||
|
||||
// Signal info types.
|
||||
|
|
|
@ -30,7 +30,7 @@ var linuxAMD64 = SyscallMap{
|
|||
10: makeSyscallInfo("mprotect", Hex, Hex, Hex),
|
||||
11: makeSyscallInfo("munmap", Hex, Hex),
|
||||
12: makeSyscallInfo("brk", Hex),
|
||||
13: makeSyscallInfo("rt_sigaction", Signal, Hex, Hex),
|
||||
13: makeSyscallInfo("rt_sigaction", Signal, SigAction, PostSigAction),
|
||||
14: makeSyscallInfo("rt_sigprocmask", SignalMaskAction, SigSet, PostSigSet, Hex),
|
||||
15: makeSyscallInfo("rt_sigreturn"),
|
||||
16: makeSyscallInfo("ioctl", Hex, Hex, Hex),
|
||||
|
|
|
@ -65,6 +65,41 @@ var signalMaskActions = abi.ValueSet{
|
|||
linux.SIG_SETMASK: "SIG_SETMASK",
|
||||
}
|
||||
|
||||
var sigActionFlags = abi.FlagSet{
|
||||
{
|
||||
Flag: linux.SA_NOCLDSTOP,
|
||||
Name: "SA_NOCLDSTOP",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_NOCLDWAIT,
|
||||
Name: "SA_NOCLDWAIT",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_SIGINFO,
|
||||
Name: "SA_SIGINFO",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_RESTORER,
|
||||
Name: "SA_RESTORER",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_ONSTACK,
|
||||
Name: "SA_ONSTACK",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_RESTART,
|
||||
Name: "SA_RESTART",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_NODEFER,
|
||||
Name: "SA_NODEFER",
|
||||
},
|
||||
{
|
||||
Flag: linux.SA_RESETHAND,
|
||||
Name: "SA_RESETHAND",
|
||||
},
|
||||
}
|
||||
|
||||
func sigSet(t *kernel.Task, addr usermem.Addr) string {
|
||||
if addr == 0 {
|
||||
return "null"
|
||||
|
@ -77,10 +112,37 @@ func sigSet(t *kernel.Task, addr usermem.Addr) string {
|
|||
|
||||
set := linux.SignalSet(usermem.ByteOrder.Uint64(b[:]))
|
||||
|
||||
return fmt.Sprintf("%#x %s", addr, formatSigSet(set))
|
||||
}
|
||||
|
||||
func formatSigSet(set linux.SignalSet) string {
|
||||
var signals []string
|
||||
linux.ForEachSignal(set, func(sig linux.Signal) {
|
||||
signals = append(signals, signalNames.ParseDecimal(uint64(sig)))
|
||||
})
|
||||
|
||||
return fmt.Sprintf("%#x [%v]", addr, strings.Join(signals, " "))
|
||||
return fmt.Sprintf("[%v]", strings.Join(signals, " "))
|
||||
}
|
||||
|
||||
func sigAction(t *kernel.Task, addr usermem.Addr) string {
|
||||
if addr == 0 {
|
||||
return "null"
|
||||
}
|
||||
|
||||
sa, err := t.CopyInSignalAct(addr)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("%#x (error copying sigaction: %v)", addr, err)
|
||||
}
|
||||
|
||||
var handler string
|
||||
switch sa.Handler {
|
||||
case linux.SIG_IGN:
|
||||
handler = "SIG_IGN"
|
||||
case linux.SIG_DFL:
|
||||
handler = "SIG_DFL"
|
||||
default:
|
||||
handler = fmt.Sprintf("%#x", sa.Handler)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%#x {Handler: %s, Flags: %s, Restorer: %#x, Mask: %s}", addr, handler, sigActionFlags.Parse(sa.Flags), sa.Restorer, formatSigSet(sa.Mask))
|
||||
}
|
||||
|
|
|
@ -339,6 +339,8 @@ func (i *SyscallInfo) pre(t *kernel.Task, args arch.SyscallArguments, maximumBlo
|
|||
output = append(output, signalMaskActions.Parse(uint64(args[arg].Int())))
|
||||
case SigSet:
|
||||
output = append(output, sigSet(t, args[arg].Pointer()))
|
||||
case SigAction:
|
||||
output = append(output, sigAction(t, args[arg].Pointer()))
|
||||
case Oct:
|
||||
output = append(output, "0o"+strconv.FormatUint(args[arg].Uint64(), 8))
|
||||
case Hex:
|
||||
|
@ -399,6 +401,8 @@ func (i *SyscallInfo) post(t *kernel.Task, args arch.SyscallArguments, rval uint
|
|||
output[arg] = rusage(t, args[arg].Pointer())
|
||||
case PostSigSet:
|
||||
output[arg] = sigSet(t, args[arg].Pointer())
|
||||
case PostSigAction:
|
||||
output[arg] = sigAction(t, args[arg].Pointer())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,6 +182,12 @@ const (
|
|||
|
||||
// PostSigSet is a signal set, formatted after syscall execution.
|
||||
PostSigSet
|
||||
|
||||
// SigAction is a struct sigaction.
|
||||
SigAction
|
||||
|
||||
// PostSigAction is a struct sigaction, formatted after syscall execution.
|
||||
PostSigAction
|
||||
)
|
||||
|
||||
// defaultFormat is the syscall argument format to use if the actual format is
|
||||
|
|
Loading…
Reference in New Issue