1997-12-20 18:40:43 +00:00
|
|
|
/*
|
2010-03-10 20:31:30 +00:00
|
|
|
* Copyright 1997 Sean Eric Fagan
|
1997-12-20 18:40:43 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Sean Eric Fagan
|
|
|
|
* 4. Neither the name of the author may be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1998-01-05 07:30:26 +00:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] =
|
1999-08-28 01:08:13 +00:00
|
|
|
"$FreeBSD$";
|
1998-01-05 07:30:26 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
1997-12-06 05:23:12 +00:00
|
|
|
/*
|
|
|
|
* This file has routines used to print out system calls and their
|
|
|
|
* arguments.
|
|
|
|
*/
|
|
|
|
|
2001-10-21 21:57:10 +00:00
|
|
|
#include <sys/types.h>
|
2013-09-12 18:08:25 +00:00
|
|
|
#include <sys/mman.h>
|
2013-09-19 18:53:42 +00:00
|
|
|
#include <sys/procctl.h>
|
2007-04-10 04:03:34 +00:00
|
|
|
#include <sys/ptrace.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
#include <sys/socket.h>
|
2002-10-06 21:46:04 +00:00
|
|
|
#include <sys/time.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
#include <sys/un.h>
|
2013-09-12 18:08:25 +00:00
|
|
|
#include <sys/wait.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <machine/atomic.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/umtx.h>
|
|
|
|
#include <sys/event.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/resource.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
|
2001-11-06 19:26:51 +00:00
|
|
|
#include <ctype.h>
|
1998-01-05 07:30:26 +00:00
|
|
|
#include <err.h>
|
2004-03-23 09:04:06 +00:00
|
|
|
#include <fcntl.h>
|
Add support for decoding Timespec, Timeval, Itimerval, Pollfd,
Fd_set and Sigaction structures. Use these for printing the arguments
to sigaction(), nanosleep(), select(), poll(), gettimeofday(),
clock_gettime(), recvfrom(), getitimer() and setitimer().
This is based on Dan's patch from the PR but I've hacked it for
style and some other issues. While Dan has checked this patch, any
goofs are probably my fault.
(The PR also contains support for the dual return values of pipe().
These will follow once I've ported that support to platforms other
than i386.)
PR: 52190
Submitted by: Dan Nelson <dnelson@allantgroup.com>
2004-03-23 12:37:02 +00:00
|
|
|
#include <poll.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
#include <signal.h>
|
Add support for decoding Timespec, Timeval, Itimerval, Pollfd,
Fd_set and Sigaction structures. Use these for printing the arguments
to sigaction(), nanosleep(), select(), poll(), gettimeofday(),
clock_gettime(), recvfrom(), getitimer() and setitimer().
This is based on Dan's patch from the PR but I've hacked it for
style and some other issues. While Dan has checked this patch, any
goofs are probably my fault.
(The PR also contains support for the dual return values of pipe().
These will follow once I've ported that support to platforms other
than i386.)
PR: 52190
Submitted by: Dan Nelson <dnelson@allantgroup.com>
2004-03-23 12:37:02 +00:00
|
|
|
#include <stdint.h>
|
1997-12-06 05:23:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-08-06 12:46:14 +00:00
|
|
|
#include <time.h>
|
1997-12-06 05:23:12 +00:00
|
|
|
#include <unistd.h>
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
#include <vis.h>
|
2001-10-21 21:57:10 +00:00
|
|
|
|
2002-08-04 00:46:48 +00:00
|
|
|
#include "truss.h"
|
2001-12-11 23:34:02 +00:00
|
|
|
#include "extern.h"
|
1997-12-06 05:23:12 +00:00
|
|
|
#include "syscall.h"
|
|
|
|
|
2007-07-28 23:15:04 +00:00
|
|
|
/* 64-bit alignment on 32-bit platforms. */
|
|
|
|
#ifdef __powerpc__
|
|
|
|
#define QUAD_ALIGN 1
|
|
|
|
#else
|
|
|
|
#define QUAD_ALIGN 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Number of slots needed for a 64-bit argument. */
|
|
|
|
#ifdef __LP64__
|
|
|
|
#define QUAD_SLOTS 1
|
|
|
|
#else
|
|
|
|
#define QUAD_SLOTS 2
|
|
|
|
#endif
|
|
|
|
|
1997-12-06 05:23:12 +00:00
|
|
|
/*
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
* This should probably be in its own file, sorted alphabetically.
|
1997-12-06 05:23:12 +00:00
|
|
|
*/
|
2011-12-10 18:27:55 +00:00
|
|
|
static struct syscall syscalls[] = {
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "fcntl", .ret_type = 1, .nargs = 3,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Int, 0 }, { Fcntl, 1 }, { Fcntlflag | OUT, 2 } } },
|
2009-12-20 10:58:34 +00:00
|
|
|
{ .name = "fork", .ret_type = 1, .nargs = 0 },
|
2013-08-01 02:57:04 +00:00
|
|
|
{ .name = "vfork", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "rfork", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Rforkflags, 0 } } },
|
2009-12-20 10:58:34 +00:00
|
|
|
{ .name = "getegid", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "geteuid", .ret_type = 1, .nargs = 0 },
|
2014-04-24 14:12:35 +00:00
|
|
|
{ .name = "linux_readlink", .ret_type = 1, .nargs = 3,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name, 0 }, { Name | OUT, 1 }, { Int, 2 }}},
|
2014-04-24 14:12:35 +00:00
|
|
|
{ .name = "linux_socketcall", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Int, 0 }, { LinuxSockArgs, 1 }}},
|
2009-12-20 10:58:34 +00:00
|
|
|
{ .name = "getgid", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "getpid", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "getpgid", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "getpgrp", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "getppid", .ret_type = 1, .nargs = 0 },
|
|
|
|
{ .name = "getsid", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "getuid", .ret_type = 1, .nargs = 0 },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "readlink", .ret_type = 1, .nargs = 3,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name, 0 }, { Readlinkres | OUT, 1 }, { Int, 2 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "lseek", .ret_type = 2, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Quad, 1 + QUAD_ALIGN }, { Whence, 1 + QUAD_SLOTS + QUAD_ALIGN } } },
|
|
|
|
{ .name = "linux_lseek", .ret_type = 2, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } },
|
|
|
|
{ .name = "mmap", .ret_type = 2, .nargs = 6,
|
|
|
|
.args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 }, { Mmapflags, 3 }, { Int, 4 }, { Quad, 5 + QUAD_ALIGN } } },
|
2014-04-24 14:12:35 +00:00
|
|
|
{ .name = "linux_mkdir", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name | IN, 0}, {Int, 1}}},
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "mprotect", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 } } },
|
|
|
|
{ .name = "open", .ret_type = 1, .nargs = 3,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name | IN, 0 }, { Open, 1 }, { Octal, 2 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "mkdir", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name, 0 }, { Octal, 1 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "linux_open", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Name, 0 }, { Hex, 1 }, { Octal, 2 } } },
|
|
|
|
{ .name = "close", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "link", .ret_type = 0, .nargs = 2,
|
|
|
|
.args = { { Name, 0 }, { Name, 1 } } },
|
|
|
|
{ .name = "unlink", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Name, 0 } } },
|
|
|
|
{ .name = "chdir", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Name, 0 } } },
|
|
|
|
{ .name = "chroot", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Name, 0 } } },
|
|
|
|
{ .name = "mknod", .ret_type = 0, .nargs = 3,
|
|
|
|
.args = { { Name, 0 }, { Octal, 1 }, { Int, 3 } } },
|
|
|
|
{ .name = "chmod", .ret_type = 0, .nargs = 2,
|
|
|
|
.args = { { Name, 0 }, { Octal, 1 } } },
|
|
|
|
{ .name = "chown", .ret_type = 0, .nargs = 3,
|
|
|
|
.args = { { Name, 0 }, { Int, 1 }, { Int, 2 } } },
|
2014-04-24 14:12:35 +00:00
|
|
|
{ .name = "linux_stat64", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Name | IN, 0 }, { Ptr | OUT, 1 }, { Ptr | IN, 1 }}},
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "mount", .ret_type = 0, .nargs = 4,
|
|
|
|
.args = { { Name, 0 }, { Name, 1 }, { Int, 2 }, { Ptr, 3 } } },
|
|
|
|
{ .name = "umount", .ret_type = 0, .nargs = 2,
|
|
|
|
.args = { { Name, 0 }, { Int, 2 } } },
|
|
|
|
{ .name = "fstat", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Int, 0 }, { Stat | OUT, 1 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "stat", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
|
|
|
|
{ .name = "lstat", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
|
|
|
|
{ .name = "linux_newstat", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Ptr | OUT, 1 } } },
|
2014-04-24 14:12:35 +00:00
|
|
|
{ .name = "linux_access", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name, 0 }, { Int, 1 }}},
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "linux_newfstat", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Ptr | OUT, 1 } } },
|
|
|
|
{ .name = "write", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "ioctl", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Ioctl, 1 }, { Hex, 2 } } },
|
|
|
|
{ .name = "break", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Ptr, 0 } } },
|
|
|
|
{ .name = "exit", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Hex, 0 } } },
|
|
|
|
{ .name = "access", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Int, 1 } } },
|
|
|
|
{ .name = "sigaction", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Signal, 0 }, { Sigaction | IN, 1 }, { Sigaction | OUT, 2 } } },
|
|
|
|
{ .name = "accept", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
|
|
|
|
{ .name = "bind", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "connect", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "getpeername", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
|
|
|
|
{ .name = "getsockname", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
|
|
|
|
{ .name = "recvfrom", .ret_type = 1, .nargs = 6,
|
|
|
|
.args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, { Hex, 3 }, { Sockaddr | OUT, 4 }, { Ptr | OUT, 5 } } },
|
|
|
|
{ .name = "sendto", .ret_type = 1, .nargs = 6,
|
|
|
|
.args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, { Hex, 3 }, { Sockaddr | IN, 4 }, { Ptr | IN, 5 } } },
|
|
|
|
{ .name = "execve", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Name | IN, 0 }, { StringArray | IN, 1 }, { StringArray | IN, 2 } } },
|
|
|
|
{ .name = "linux_execve", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Name | IN, 0 }, { StringArray | IN, 1 }, { StringArray | IN, 2 } } },
|
|
|
|
{ .name = "kldload", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Name | IN, 0 } } },
|
|
|
|
{ .name = "kldunload", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "kldfind", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Name | IN, 0 } } },
|
|
|
|
{ .name = "kldnext", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "kldstat", .ret_type = 0, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Ptr, 1 } } },
|
|
|
|
{ .name = "kldfirstmod", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Int, 0 } } },
|
|
|
|
{ .name = "nanosleep", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Timespec, 0 } } },
|
|
|
|
{ .name = "select", .ret_type = 1, .nargs = 5,
|
|
|
|
.args = { { Int, 0 }, { Fd_set, 1 }, { Fd_set, 2 }, { Fd_set, 3 }, { Timeval, 4 } } },
|
|
|
|
{ .name = "poll", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Pollfd, 0 }, { Int, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "gettimeofday", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Timeval | OUT, 0 }, { Ptr, 1 } } },
|
|
|
|
{ .name = "clock_gettime", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Timespec | OUT, 1 } } },
|
|
|
|
{ .name = "getitimer", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Itimerval | OUT, 2 } } },
|
|
|
|
{ .name = "setitimer", .ret_type = 1, .nargs = 3,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Int, 0 }, { Itimerval, 1 }, { Itimerval | OUT, 2 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "kse_release", .ret_type = 0, .nargs = 1,
|
|
|
|
.args = { { Timespec, 0 } } },
|
|
|
|
{ .name = "kevent", .ret_type = 0, .nargs = 6,
|
|
|
|
.args = { { Int, 0 }, { Kevent, 1 }, { Int, 2 }, { Kevent | OUT, 3 }, { Int, 4 }, { Timespec, 5 } } },
|
|
|
|
{ .name = "sigprocmask", .ret_type = 0, .nargs = 3,
|
|
|
|
.args = { { Sigprocmask, 0 }, { Sigset, 1 }, { Sigset | OUT, 2 } } },
|
|
|
|
{ .name = "unmount", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name, 0 }, { Int, 1 } } },
|
|
|
|
{ .name = "socket", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Sockdomain, 0 }, { Socktype, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "getrusage", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Rusage | OUT, 1 } } },
|
|
|
|
{ .name = "__getcwd", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | OUT, 0 }, { Int, 1 } } },
|
|
|
|
{ .name = "shutdown", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Shutdown, 1 } } },
|
|
|
|
{ .name = "getrlimit", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Resource, 0 }, { Rlimit | OUT, 1 } } },
|
|
|
|
{ .name = "setrlimit", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Resource, 0 }, { Rlimit | IN, 1 } } },
|
|
|
|
{ .name = "utimes", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Timeval2 | IN, 1 } } },
|
|
|
|
{ .name = "lutimes", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Timeval2 | IN, 1 } } },
|
|
|
|
{ .name = "futimes", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int, 0 }, { Timeval | IN, 1 } } },
|
|
|
|
{ .name = "chflags", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Hex, 1 } } },
|
|
|
|
{ .name = "lchflags", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Hex, 1 } } },
|
|
|
|
{ .name = "pathconf", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Name | IN, 0 }, { Pathconf, 1 } } },
|
2009-12-21 17:38:13 +00:00
|
|
|
{ .name = "pipe", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Ptr, 0 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "truncate", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Name | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
|
|
|
|
{ .name = "ftruncate", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
|
|
|
|
{ .name = "kill", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Int | IN, 0 }, { Signal | IN, 1 } } },
|
|
|
|
{ .name = "munmap", .ret_type = 1, .nargs = 2,
|
|
|
|
.args = { { Ptr, 0 }, { Int, 1 } } },
|
|
|
|
{ .name = "read", .ret_type = 1, .nargs = 3,
|
|
|
|
.args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 } } },
|
|
|
|
{ .name = "rename", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name, 0 }, { Name, 1 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = "symlink", .ret_type = 1, .nargs = 2,
|
2015-08-05 18:10:46 +00:00
|
|
|
.args = { { Name, 0 }, { Name, 1 } } },
|
2009-12-23 15:22:50 +00:00
|
|
|
{ .name = "posix_openpt", .ret_type = 1, .nargs = 1,
|
|
|
|
.args = { { Open, 0 } } },
|
2013-09-12 18:08:25 +00:00
|
|
|
{ .name = "wait4", .ret_type = 1, .nargs = 4,
|
|
|
|
.args = { { Int, 0 }, { ExitStatus | OUT, 1 }, { Waitoptions, 2 },
|
|
|
|
{ Rusage | OUT, 3 } } },
|
|
|
|
{ .name = "wait6", .ret_type = 1, .nargs = 6,
|
|
|
|
.args = { { Idtype, 0 }, { Int, 1 }, { ExitStatus | OUT, 2 },
|
|
|
|
{ Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
|
2013-09-19 18:53:42 +00:00
|
|
|
{ .name = "procctl", .ret_type = 1, .nargs = 4,
|
|
|
|
.args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
|
2014-10-13 16:37:06 +00:00
|
|
|
{ .name = "_umtx_op", .ret_type = 1, .nargs = 5,
|
|
|
|
.args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 },
|
|
|
|
{ Ptr, 4 } } },
|
2009-05-12 20:42:12 +00:00
|
|
|
{ .name = 0 },
|
1997-12-06 05:23:12 +00:00
|
|
|
};
|
|
|
|
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
/* Xlat idea taken from strace */
|
|
|
|
struct xlat {
|
|
|
|
int val;
|
2007-04-10 04:03:34 +00:00
|
|
|
const char *str;
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
};
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
#define X(a) { a, #a },
|
|
|
|
#define XEND { 0, NULL }
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
|
|
|
|
static struct xlat kevent_filters[] = {
|
|
|
|
X(EVFILT_READ) X(EVFILT_WRITE) X(EVFILT_AIO) X(EVFILT_VNODE)
|
|
|
|
X(EVFILT_PROC) X(EVFILT_SIGNAL) X(EVFILT_TIMER)
|
2009-12-31 20:29:58 +00:00
|
|
|
X(EVFILT_FS) X(EVFILT_READ) XEND
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat kevent_flags[] = {
|
|
|
|
X(EV_ADD) X(EV_DELETE) X(EV_ENABLE) X(EV_DISABLE) X(EV_ONESHOT)
|
|
|
|
X(EV_CLEAR) X(EV_FLAG1) X(EV_ERROR) X(EV_EOF) XEND
|
|
|
|
};
|
|
|
|
|
2011-12-10 18:27:55 +00:00
|
|
|
static struct xlat poll_flags[] = {
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
X(POLLSTANDARD) X(POLLIN) X(POLLPRI) X(POLLOUT) X(POLLERR)
|
|
|
|
X(POLLHUP) X(POLLNVAL) X(POLLRDNORM) X(POLLRDBAND)
|
|
|
|
X(POLLWRBAND) X(POLLINIGNEOF) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat mmap_flags[] = {
|
2014-10-18 12:28:51 +00:00
|
|
|
X(MAP_SHARED) X(MAP_PRIVATE) X(MAP_FIXED) X(MAP_RESERVED0020)
|
|
|
|
X(MAP_RESERVED0040) X(MAP_RESERVED0080) X(MAP_RESERVED0100)
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
X(MAP_HASSEMAPHORE) X(MAP_STACK) X(MAP_NOSYNC) X(MAP_ANON)
|
2013-09-09 18:11:59 +00:00
|
|
|
X(MAP_NOCORE) X(MAP_PREFAULT_READ)
|
|
|
|
#ifdef MAP_32BIT
|
|
|
|
X(MAP_32BIT)
|
|
|
|
#endif
|
|
|
|
XEND
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat mprot_flags[] = {
|
|
|
|
X(PROT_NONE) X(PROT_READ) X(PROT_WRITE) X(PROT_EXEC) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat whence_arg[] = {
|
|
|
|
X(SEEK_SET) X(SEEK_CUR) X(SEEK_END) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat sigaction_flags[] = {
|
|
|
|
X(SA_ONSTACK) X(SA_RESTART) X(SA_RESETHAND) X(SA_NOCLDSTOP)
|
|
|
|
X(SA_NODEFER) X(SA_NOCLDWAIT) X(SA_SIGINFO) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat fcntl_arg[] = {
|
|
|
|
X(F_DUPFD) X(F_GETFD) X(F_SETFD) X(F_GETFL) X(F_SETFL)
|
|
|
|
X(F_GETOWN) X(F_SETOWN) X(F_GETLK) X(F_SETLK) X(F_SETLKW) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat fcntlfd_arg[] = {
|
|
|
|
X(FD_CLOEXEC) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat fcntlfl_arg[] = {
|
|
|
|
X(O_APPEND) X(O_ASYNC) X(O_FSYNC) X(O_NONBLOCK) X(O_NOFOLLOW)
|
|
|
|
X(O_DIRECT) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat sockdomain_arg[] = {
|
|
|
|
X(PF_UNSPEC) X(PF_LOCAL) X(PF_UNIX) X(PF_INET) X(PF_IMPLINK)
|
|
|
|
X(PF_PUP) X(PF_CHAOS) X(PF_NETBIOS) X(PF_ISO) X(PF_OSI)
|
|
|
|
X(PF_ECMA) X(PF_DATAKIT) X(PF_CCITT) X(PF_SNA) X(PF_DECnet)
|
|
|
|
X(PF_DLI) X(PF_LAT) X(PF_HYLINK) X(PF_APPLETALK) X(PF_ROUTE)
|
|
|
|
X(PF_LINK) X(PF_XTP) X(PF_COIP) X(PF_CNT) X(PF_SIP) X(PF_IPX)
|
|
|
|
X(PF_RTIP) X(PF_PIP) X(PF_ISDN) X(PF_KEY) X(PF_INET6)
|
|
|
|
X(PF_NATM) X(PF_ATM) X(PF_NETGRAPH) X(PF_SLOW) X(PF_SCLUSTER)
|
|
|
|
X(PF_ARP) X(PF_BLUETOOTH) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat socktype_arg[] = {
|
|
|
|
X(SOCK_STREAM) X(SOCK_DGRAM) X(SOCK_RAW) X(SOCK_RDM)
|
|
|
|
X(SOCK_SEQPACKET) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat open_flags[] = {
|
|
|
|
X(O_RDONLY) X(O_WRONLY) X(O_RDWR) X(O_ACCMODE) X(O_NONBLOCK)
|
|
|
|
X(O_APPEND) X(O_SHLOCK) X(O_EXLOCK) X(O_ASYNC) X(O_FSYNC)
|
|
|
|
X(O_NOFOLLOW) X(O_CREAT) X(O_TRUNC) X(O_EXCL) X(O_NOCTTY)
|
2013-06-30 13:14:46 +00:00
|
|
|
X(O_DIRECT) X(O_DIRECTORY) X(O_EXEC) X(O_TTY_INIT) X(O_CLOEXEC) XEND
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat shutdown_arg[] = {
|
|
|
|
X(SHUT_RD) X(SHUT_WR) X(SHUT_RDWR) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat resource_arg[] = {
|
|
|
|
X(RLIMIT_CPU) X(RLIMIT_FSIZE) X(RLIMIT_DATA) X(RLIMIT_STACK)
|
|
|
|
X(RLIMIT_CORE) X(RLIMIT_RSS) X(RLIMIT_MEMLOCK) X(RLIMIT_NPROC)
|
|
|
|
X(RLIMIT_NOFILE) X(RLIMIT_SBSIZE) X(RLIMIT_VMEM) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat pathconf_arg[] = {
|
|
|
|
X(_PC_LINK_MAX) X(_PC_MAX_CANON) X(_PC_MAX_INPUT)
|
|
|
|
X(_PC_NAME_MAX) X(_PC_PATH_MAX) X(_PC_PIPE_BUF)
|
|
|
|
X(_PC_CHOWN_RESTRICTED) X(_PC_NO_TRUNC) X(_PC_VDISABLE)
|
|
|
|
X(_PC_ASYNC_IO) X(_PC_PRIO_IO) X(_PC_SYNC_IO)
|
|
|
|
X(_PC_ALLOC_SIZE_MIN) X(_PC_FILESIZEBITS)
|
|
|
|
X(_PC_REC_INCR_XFER_SIZE) X(_PC_REC_MAX_XFER_SIZE)
|
|
|
|
X(_PC_REC_MIN_XFER_SIZE) X(_PC_REC_XFER_ALIGN)
|
|
|
|
X(_PC_SYMLINK_MAX) X(_PC_ACL_EXTENDED) X(_PC_ACL_PATH_MAX)
|
|
|
|
X(_PC_CAP_PRESENT) X(_PC_INF_PRESENT) X(_PC_MAC_PRESENT)
|
|
|
|
XEND
|
|
|
|
};
|
|
|
|
|
2013-08-01 02:57:04 +00:00
|
|
|
static struct xlat rfork_flags[] = {
|
|
|
|
X(RFPROC) X(RFNOWAIT) X(RFFDG) X(RFCFDG) X(RFTHREAD) X(RFMEM)
|
|
|
|
X(RFSIGSHARE) X(RFTSIGZMB) X(RFLINUXTHPN) XEND
|
|
|
|
};
|
|
|
|
|
2013-09-12 18:08:25 +00:00
|
|
|
static struct xlat wait_options[] = {
|
|
|
|
X(WNOHANG) X(WUNTRACED) X(WCONTINUED) X(WNOWAIT) X(WEXITED)
|
|
|
|
X(WTRAPPED) XEND
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct xlat idtype_arg[] = {
|
|
|
|
X(P_PID) X(P_PPID) X(P_PGID) X(P_SID) X(P_CID) X(P_UID) X(P_GID)
|
|
|
|
X(P_ALL) X(P_LWPID) X(P_TASKID) X(P_PROJID) X(P_POOLID) X(P_JAILID)
|
|
|
|
X(P_CTID) X(P_CPUID) X(P_PSETID) XEND
|
|
|
|
};
|
|
|
|
|
2013-09-19 18:53:42 +00:00
|
|
|
static struct xlat procctl_arg[] = {
|
|
|
|
X(PROC_SPROTECT) XEND
|
|
|
|
};
|
|
|
|
|
2014-10-13 16:37:06 +00:00
|
|
|
static struct xlat umtx_ops[] = {
|
|
|
|
X(UMTX_OP_RESERVED0) X(UMTX_OP_RESERVED1) X(UMTX_OP_WAIT)
|
|
|
|
X(UMTX_OP_WAKE) X(UMTX_OP_MUTEX_TRYLOCK) X(UMTX_OP_MUTEX_LOCK)
|
|
|
|
X(UMTX_OP_MUTEX_UNLOCK) X(UMTX_OP_SET_CEILING) X(UMTX_OP_CV_WAIT)
|
|
|
|
X(UMTX_OP_CV_SIGNAL) X(UMTX_OP_CV_BROADCAST) X(UMTX_OP_WAIT_UINT)
|
|
|
|
X(UMTX_OP_RW_RDLOCK) X(UMTX_OP_RW_WRLOCK) X(UMTX_OP_RW_UNLOCK)
|
|
|
|
X(UMTX_OP_WAIT_UINT_PRIVATE) X(UMTX_OP_WAKE_PRIVATE)
|
|
|
|
X(UMTX_OP_MUTEX_WAIT) X(UMTX_OP_MUTEX_WAKE) X(UMTX_OP_SEM_WAIT)
|
|
|
|
X(UMTX_OP_SEM_WAKE) X(UMTX_OP_NWAKE_PRIVATE) X(UMTX_OP_MUTEX_WAKE2)
|
2014-10-24 20:02:44 +00:00
|
|
|
X(UMTX_OP_SEM2_WAIT) X(UMTX_OP_SEM2_WAKE)
|
2014-10-13 16:37:06 +00:00
|
|
|
XEND
|
|
|
|
};
|
|
|
|
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
#undef X
|
|
|
|
#undef XEND
|
|
|
|
|
2008-07-31 17:15:21 +00:00
|
|
|
/*
|
|
|
|
* Searches an xlat array for a value, and returns it if found. Otherwise
|
|
|
|
* return a string representation.
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
lookup(struct xlat *xlat, int val, int base)
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
{
|
|
|
|
static char tmp[16];
|
2008-07-31 17:15:21 +00:00
|
|
|
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
for (; xlat->str != NULL; xlat++)
|
|
|
|
if (xlat->val == val)
|
2008-07-31 17:15:21 +00:00
|
|
|
return (xlat->str);
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
switch (base) {
|
|
|
|
case 8:
|
|
|
|
sprintf(tmp, "0%o", val);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
sprintf(tmp, "0x%x", val);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
sprintf(tmp, "%u", val);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errx(1,"Unknown lookup base");
|
|
|
|
break;
|
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
return (tmp);
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 04:03:34 +00:00
|
|
|
static const char *
|
|
|
|
xlookup(struct xlat *xlat, int val)
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
{
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
return (lookup(xlat, val, 16));
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Searches an xlat array containing bitfield values. Remaining bits
|
|
|
|
set after removing the known ones are printed at the end:
|
|
|
|
IN|0x400 */
|
2008-07-31 17:15:21 +00:00
|
|
|
static char *
|
|
|
|
xlookup_bits(struct xlat *xlat, int val)
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
{
|
2012-09-02 11:03:18 +00:00
|
|
|
int len, rem;
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
static char str[512];
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
len = 0;
|
|
|
|
rem = val;
|
2008-07-31 17:15:21 +00:00
|
|
|
for (; xlat->str != NULL; xlat++) {
|
|
|
|
if ((xlat->val & rem) == xlat->val) {
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
/* don't print the "all-bits-zero" string unless all
|
|
|
|
bits are really zero */
|
|
|
|
if (xlat->val == 0 && val != 0)
|
|
|
|
continue;
|
|
|
|
len += sprintf(str + len, "%s|", xlat->str);
|
|
|
|
rem &= ~(xlat->val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if we have leftover bits or didn't match anything */
|
|
|
|
if (rem || len == 0)
|
|
|
|
len += sprintf(str + len, "0x%x", rem);
|
|
|
|
if (len && str[len - 1] == '|')
|
|
|
|
len--;
|
|
|
|
str[len] = 0;
|
2008-07-31 17:15:21 +00:00
|
|
|
return (str);
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
}
|
|
|
|
|
1997-12-06 05:23:12 +00:00
|
|
|
/*
|
|
|
|
* If/when the list gets big, it might be desirable to do it
|
|
|
|
* as a hash table or binary search.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct syscall *
|
2008-07-31 17:15:21 +00:00
|
|
|
get_syscall(const char *name)
|
|
|
|
{
|
2012-09-02 11:03:18 +00:00
|
|
|
struct syscall *sc;
|
1997-12-06 05:23:12 +00:00
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
sc = syscalls;
|
2004-08-08 23:29:36 +00:00
|
|
|
if (name == NULL)
|
|
|
|
return (NULL);
|
1997-12-06 05:23:12 +00:00
|
|
|
while (sc->name) {
|
2012-09-02 11:03:18 +00:00
|
|
|
if (strcmp(name, sc->name) == 0)
|
2008-07-31 17:15:21 +00:00
|
|
|
return (sc);
|
1997-12-06 05:23:12 +00:00
|
|
|
sc++;
|
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
return (NULL);
|
1997-12-06 05:23:12 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 21:57:10 +00:00
|
|
|
/*
|
|
|
|
* get_struct
|
|
|
|
*
|
|
|
|
* Copy a fixed amount of bytes from the process.
|
|
|
|
*/
|
|
|
|
|
2001-12-11 23:34:02 +00:00
|
|
|
static int
|
2012-08-21 14:58:51 +00:00
|
|
|
get_struct(pid_t pid, void *offset, void *buf, int len)
|
2008-07-31 17:15:21 +00:00
|
|
|
{
|
2007-04-10 04:03:34 +00:00
|
|
|
struct ptrace_io_desc iorequest;
|
2008-07-31 17:15:21 +00:00
|
|
|
|
2007-04-10 04:03:34 +00:00
|
|
|
iorequest.piod_op = PIOD_READ_D;
|
|
|
|
iorequest.piod_offs = offset;
|
|
|
|
iorequest.piod_addr = buf;
|
|
|
|
iorequest.piod_len = len;
|
|
|
|
if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0)
|
2008-07-31 17:15:21 +00:00
|
|
|
return (-1);
|
|
|
|
return (0);
|
2001-10-21 21:57:10 +00:00
|
|
|
}
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
#define MAXSIZE 4096
|
|
|
|
#define BLOCKSIZE 1024
|
1997-12-06 05:23:12 +00:00
|
|
|
/*
|
|
|
|
* get_string
|
|
|
|
* Copy a string from the process. Note that it is
|
|
|
|
* expected to be a C string, but if max is set, it will
|
|
|
|
* only get that much.
|
|
|
|
*/
|
|
|
|
|
2007-04-10 04:03:34 +00:00
|
|
|
static char *
|
2008-07-31 17:15:21 +00:00
|
|
|
get_string(pid_t pid, void *offset, int max)
|
|
|
|
{
|
2007-04-10 04:03:34 +00:00
|
|
|
struct ptrace_io_desc iorequest;
|
2012-09-02 11:03:18 +00:00
|
|
|
char *buf;
|
|
|
|
int diff, i, size, totalsize;
|
2008-07-31 17:15:21 +00:00
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
diff = 0;
|
2008-07-31 17:15:21 +00:00
|
|
|
totalsize = size = max ? (max + 1) : BLOCKSIZE;
|
2007-04-10 04:03:34 +00:00
|
|
|
buf = malloc(totalsize);
|
|
|
|
if (buf == NULL)
|
2008-07-31 17:15:21 +00:00
|
|
|
return (NULL);
|
|
|
|
for (;;) {
|
2007-04-10 04:03:34 +00:00
|
|
|
diff = totalsize - size;
|
|
|
|
iorequest.piod_op = PIOD_READ_D;
|
|
|
|
iorequest.piod_offs = (char *)offset + diff;
|
|
|
|
iorequest.piod_addr = buf + diff;
|
|
|
|
iorequest.piod_len = size;
|
|
|
|
if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0) {
|
|
|
|
free(buf);
|
2008-07-31 17:15:21 +00:00
|
|
|
return (NULL);
|
2007-04-10 04:03:34 +00:00
|
|
|
}
|
|
|
|
for (i = 0 ; i < size; i++) {
|
|
|
|
if (buf[diff + i] == '\0')
|
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
if (totalsize < MAXSIZE - BLOCKSIZE && max == 0) {
|
|
|
|
totalsize += BLOCKSIZE;
|
|
|
|
buf = realloc(buf, totalsize);
|
|
|
|
size = BLOCKSIZE;
|
2008-07-31 17:15:21 +00:00
|
|
|
} else {
|
2010-12-06 09:18:11 +00:00
|
|
|
buf[totalsize - 1] = '\0';
|
2008-07-31 17:15:21 +00:00
|
|
|
return (buf);
|
1997-12-06 05:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 18:08:25 +00:00
|
|
|
static char *
|
|
|
|
strsig2(int sig)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
tmp = strsig(sig);
|
|
|
|
if (tmp == NULL)
|
|
|
|
asprintf(&tmp, "%d", sig);
|
|
|
|
return (tmp);
|
|
|
|
}
|
1997-12-06 05:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* print_arg
|
|
|
|
* Converts a syscall argument into a string. Said string is
|
|
|
|
* allocated via malloc(), so needs to be free()'d. The file
|
|
|
|
* descriptor is for the process' memory (via /proc), and is used
|
|
|
|
* to get any data (where the argument is a pointer). sc is
|
|
|
|
* a pointer to the syscall description (see above); args is
|
|
|
|
* an array of all of the system call arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *
|
2012-09-02 11:03:18 +00:00
|
|
|
print_arg(struct syscall_args *sc, unsigned long *args, long retval,
|
|
|
|
struct trussinfo *trussinfo)
|
2008-07-31 17:15:21 +00:00
|
|
|
{
|
2012-09-02 11:03:18 +00:00
|
|
|
char *tmp;
|
|
|
|
pid_t pid;
|
2008-07-31 17:15:21 +00:00
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
tmp = NULL;
|
|
|
|
pid = trussinfo->pid;
|
2008-07-31 17:15:21 +00:00
|
|
|
switch (sc->type & ARG_MASK) {
|
|
|
|
case Hex:
|
|
|
|
asprintf(&tmp, "0x%x", (int)args[sc->offset]);
|
|
|
|
break;
|
|
|
|
case Octal:
|
|
|
|
asprintf(&tmp, "0%o", (int)args[sc->offset]);
|
|
|
|
break;
|
|
|
|
case Int:
|
|
|
|
asprintf(&tmp, "%d", (int)args[sc->offset]);
|
|
|
|
break;
|
2014-10-13 16:37:06 +00:00
|
|
|
case LongHex:
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
2008-07-31 17:15:21 +00:00
|
|
|
case Name: {
|
|
|
|
/* NULL-terminated string. */
|
|
|
|
char *tmp2;
|
|
|
|
tmp2 = get_string(pid, (void*)args[sc->offset], 0);
|
|
|
|
asprintf(&tmp, "\"%s\"", tmp2);
|
|
|
|
free(tmp2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BinString: {
|
|
|
|
/* Binary block of data that might have printable characters.
|
|
|
|
XXX If type|OUT, assume that the length is the syscall's
|
|
|
|
return value. Otherwise, assume that the length of the block
|
|
|
|
is in the next syscall argument. */
|
|
|
|
int max_string = trussinfo->strsize;
|
|
|
|
char tmp2[max_string+1], *tmp3;
|
|
|
|
int len;
|
|
|
|
int truncated = 0;
|
|
|
|
|
|
|
|
if (sc->type & OUT)
|
|
|
|
len = retval;
|
|
|
|
else
|
|
|
|
len = args[sc->offset + 1];
|
|
|
|
|
|
|
|
/* Don't print more than max_string characters, to avoid word
|
|
|
|
wrap. If we have to truncate put some ... after the string.
|
|
|
|
*/
|
|
|
|
if (len > max_string) {
|
|
|
|
len = max_string;
|
|
|
|
truncated = 1;
|
|
|
|
}
|
2012-09-02 11:03:18 +00:00
|
|
|
if (len && get_struct(pid, (void*)args[sc->offset], &tmp2, len)
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
tmp3 = malloc(len * 4 + 1);
|
|
|
|
while (len) {
|
2012-09-02 11:03:18 +00:00
|
|
|
if (strvisx(tmp3, tmp2, len,
|
|
|
|
VIS_CSTYLE|VIS_TAB|VIS_NL) <= max_string)
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
len--;
|
|
|
|
truncated = 1;
|
|
|
|
};
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp, "\"%s\"%s", tmp3, truncated ?
|
|
|
|
"..." : "");
|
2008-07-31 17:15:21 +00:00
|
|
|
free(tmp3);
|
|
|
|
} else {
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case StringArray: {
|
|
|
|
int num, size, i;
|
|
|
|
char *tmp2;
|
|
|
|
char *string;
|
|
|
|
char *strarray[100]; /* XXX This is ugly. */
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset],
|
|
|
|
(void *)&strarray, sizeof(strarray)) == -1)
|
2008-07-31 17:15:21 +00:00
|
|
|
err(1, "get_struct %p", (void *)args[sc->offset]);
|
|
|
|
num = 0;
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
/* Find out how large of a buffer we'll need. */
|
|
|
|
while (strarray[num] != NULL) {
|
|
|
|
string = get_string(pid, (void*)strarray[num], 0);
|
|
|
|
size += strlen(string);
|
|
|
|
free(string);
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
size += 4 + (num * 4);
|
|
|
|
tmp = (char *)malloc(size);
|
|
|
|
tmp2 = tmp;
|
|
|
|
|
|
|
|
tmp2 += sprintf(tmp2, " [");
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
string = get_string(pid, (void*)strarray[i], 0);
|
2012-09-02 11:03:18 +00:00
|
|
|
tmp2 += sprintf(tmp2, " \"%s\"%c", string,
|
|
|
|
(i + 1 == num) ? ' ' : ',');
|
2008-07-31 17:15:21 +00:00
|
|
|
free(string);
|
|
|
|
}
|
|
|
|
tmp2 += sprintf(tmp2, "]");
|
|
|
|
break;
|
|
|
|
}
|
2004-09-05 05:27:30 +00:00
|
|
|
#ifdef __LP64__
|
2008-07-31 17:15:21 +00:00
|
|
|
case Quad:
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
2004-09-05 05:27:30 +00:00
|
|
|
#else
|
2008-07-31 17:15:21 +00:00
|
|
|
case Quad: {
|
|
|
|
unsigned long long ll;
|
|
|
|
ll = *(unsigned long long *)(args + sc->offset);
|
|
|
|
asprintf(&tmp, "0x%llx", ll);
|
|
|
|
break;
|
|
|
|
}
|
2004-09-05 05:27:30 +00:00
|
|
|
#endif
|
2008-07-31 17:15:21 +00:00
|
|
|
case Ptr:
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
case Readlinkres: {
|
|
|
|
char *tmp2;
|
|
|
|
if (retval == -1) {
|
|
|
|
tmp = strdup("");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp2 = get_string(pid, (void*)args[sc->offset], retval);
|
|
|
|
asprintf(&tmp, "\"%s\"", tmp2);
|
|
|
|
free(tmp2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Ioctl: {
|
|
|
|
const char *temp = ioctlname(args[sc->offset]);
|
2012-09-02 11:03:18 +00:00
|
|
|
if (temp)
|
2008-07-31 17:15:21 +00:00
|
|
|
tmp = strdup(temp);
|
2012-09-02 11:03:18 +00:00
|
|
|
else {
|
2008-07-31 17:15:21 +00:00
|
|
|
unsigned long arg = args[sc->offset];
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp, "0x%lx { IO%s%s 0x%lx('%c'), %lu, %lu }",
|
|
|
|
arg, arg & IOC_OUT ? "R" : "",
|
|
|
|
arg & IOC_IN ? "W" : "", IOCGROUP(arg),
|
|
|
|
isprint(IOCGROUP(arg)) ? (char)IOCGROUP(arg) : '?',
|
2008-07-31 17:15:21 +00:00
|
|
|
arg & 0xFF, IOCPARM_LEN(arg));
|
|
|
|
}
|
|
|
|
break;
|
Add support for decoding Timespec, Timeval, Itimerval, Pollfd,
Fd_set and Sigaction structures. Use these for printing the arguments
to sigaction(), nanosleep(), select(), poll(), gettimeofday(),
clock_gettime(), recvfrom(), getitimer() and setitimer().
This is based on Dan's patch from the PR but I've hacked it for
style and some other issues. While Dan has checked this patch, any
goofs are probably my fault.
(The PR also contains support for the dual return values of pipe().
These will follow once I've ported that support to platforms other
than i386.)
PR: 52190
Submitted by: Dan Nelson <dnelson@allantgroup.com>
2004-03-23 12:37:02 +00:00
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Timespec: {
|
|
|
|
struct timespec ts;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &ts,
|
|
|
|
sizeof(ts)) != -1)
|
|
|
|
asprintf(&tmp, "{%ld.%09ld }", (long)ts.tv_sec,
|
|
|
|
ts.tv_nsec);
|
2008-07-31 17:15:21 +00:00
|
|
|
else
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Timeval: {
|
|
|
|
struct timeval tv;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
|
|
|
|
!= -1)
|
|
|
|
asprintf(&tmp, "{%ld.%06ld }", (long)tv.tv_sec,
|
|
|
|
tv.tv_usec);
|
2008-07-31 17:15:21 +00:00
|
|
|
else
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Timeval2: {
|
|
|
|
struct timeval tv[2];
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
|
|
|
|
!= -1)
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }",
|
|
|
|
(long)tv[0].tv_sec, tv[0].tv_usec,
|
|
|
|
(long)tv[1].tv_sec, tv[1].tv_usec);
|
|
|
|
else
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Itimerval: {
|
|
|
|
struct itimerval itv;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &itv,
|
|
|
|
sizeof(itv)) != -1)
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }",
|
|
|
|
(long)itv.it_interval.tv_sec,
|
|
|
|
itv.it_interval.tv_usec,
|
|
|
|
(long)itv.it_value.tv_sec,
|
|
|
|
itv.it_value.tv_usec);
|
|
|
|
else
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
2014-04-24 14:12:35 +00:00
|
|
|
case LinuxSockArgs:
|
|
|
|
{
|
|
|
|
struct linux_socketcall_args largs;
|
|
|
|
if (get_struct(pid, (void *)args[sc->offset], (void *)&largs,
|
|
|
|
sizeof(largs)) == -1) {
|
|
|
|
err(1, "get_struct %p", (void *)args[sc->offset]);
|
|
|
|
}
|
|
|
|
const char *what;
|
|
|
|
char buf[30];
|
|
|
|
|
|
|
|
switch (largs.what) {
|
|
|
|
case LINUX_SOCKET:
|
|
|
|
what = "LINUX_SOCKET";
|
|
|
|
break;
|
|
|
|
case LINUX_BIND:
|
|
|
|
what = "LINUX_BIND";
|
|
|
|
break;
|
|
|
|
case LINUX_CONNECT:
|
|
|
|
what = "LINUX_CONNECT";
|
|
|
|
break;
|
|
|
|
case LINUX_LISTEN:
|
|
|
|
what = "LINUX_LISTEN";
|
|
|
|
break;
|
|
|
|
case LINUX_ACCEPT:
|
|
|
|
what = "LINUX_ACCEPT";
|
|
|
|
break;
|
|
|
|
case LINUX_GETSOCKNAME:
|
|
|
|
what = "LINUX_GETSOCKNAME";
|
|
|
|
break;
|
|
|
|
case LINUX_GETPEERNAME:
|
|
|
|
what = "LINUX_GETPEERNAME";
|
|
|
|
break;
|
|
|
|
case LINUX_SOCKETPAIR:
|
|
|
|
what = "LINUX_SOCKETPAIR";
|
|
|
|
break;
|
|
|
|
case LINUX_SEND:
|
|
|
|
what = "LINUX_SEND";
|
|
|
|
break;
|
|
|
|
case LINUX_RECV:
|
|
|
|
what = "LINUX_RECV";
|
|
|
|
break;
|
|
|
|
case LINUX_SENDTO:
|
|
|
|
what = "LINUX_SENDTO";
|
|
|
|
break;
|
|
|
|
case LINUX_RECVFROM:
|
|
|
|
what = "LINUX_RECVFROM";
|
|
|
|
break;
|
|
|
|
case LINUX_SHUTDOWN:
|
|
|
|
what = "LINUX_SHUTDOWN";
|
|
|
|
break;
|
|
|
|
case LINUX_SETSOCKOPT:
|
|
|
|
what = "LINUX_SETSOCKOPT";
|
|
|
|
break;
|
|
|
|
case LINUX_GETSOCKOPT:
|
|
|
|
what = "LINUX_GETSOCKOPT";
|
|
|
|
break;
|
|
|
|
case LINUX_SENDMSG:
|
|
|
|
what = "LINUX_SENDMSG";
|
|
|
|
break;
|
|
|
|
case LINUX_RECVMSG:
|
|
|
|
what = "LINUX_RECVMSG";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(buf, "%d", largs.what);
|
|
|
|
what = buf;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
asprintf(&tmp, "(0x%lx)%s, 0x%lx", args[sc->offset], what, (long unsigned int)largs.args);
|
|
|
|
break;
|
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Pollfd: {
|
|
|
|
/*
|
2012-09-02 11:03:18 +00:00
|
|
|
* XXX: A Pollfd argument expects the /next/ syscall argument
|
|
|
|
* to be the number of fds in the array. This matches the poll
|
|
|
|
* syscall.
|
2008-07-31 17:15:21 +00:00
|
|
|
*/
|
|
|
|
struct pollfd *pfd;
|
|
|
|
int numfds = args[sc->offset+1];
|
|
|
|
int bytes = sizeof(struct pollfd) * numfds;
|
|
|
|
int i, tmpsize, u, used;
|
|
|
|
const int per_fd = 100;
|
|
|
|
|
|
|
|
if ((pfd = malloc(bytes)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot malloc %d bytes for pollfd array",
|
|
|
|
bytes);
|
|
|
|
if (get_struct(pid, (void *)args[sc->offset], pfd, bytes)
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
used = 0;
|
|
|
|
tmpsize = 1 + per_fd * numfds + 2;
|
|
|
|
if ((tmp = malloc(tmpsize)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot alloc %d bytes for poll output",
|
|
|
|
tmpsize);
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
tmp[used++] = '{';
|
|
|
|
for (i = 0; i < numfds; i++) {
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
u = snprintf(tmp + used, per_fd, "%s%d/%s",
|
|
|
|
i > 0 ? " " : "", pfd[i].fd,
|
|
|
|
xlookup_bits(poll_flags, pfd[i].events));
|
2008-07-31 17:15:21 +00:00
|
|
|
if (u > 0)
|
|
|
|
used += u < per_fd ? u : per_fd;
|
|
|
|
}
|
|
|
|
tmp[used++] = '}';
|
|
|
|
tmp[used++] = '\0';
|
|
|
|
} else {
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
}
|
|
|
|
free(pfd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Fd_set: {
|
|
|
|
/*
|
2012-09-02 11:03:18 +00:00
|
|
|
* XXX: A Fd_set argument expects the /first/ syscall argument
|
|
|
|
* to be the number of fds in the array. This matches the
|
|
|
|
* select syscall.
|
2008-07-31 17:15:21 +00:00
|
|
|
*/
|
|
|
|
fd_set *fds;
|
|
|
|
int numfds = args[0];
|
|
|
|
int bytes = _howmany(numfds, _NFDBITS) * _NFDBITS;
|
|
|
|
int i, tmpsize, u, used;
|
|
|
|
const int per_fd = 20;
|
|
|
|
|
|
|
|
if ((fds = malloc(bytes)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot malloc %d bytes for fd_set array",
|
|
|
|
bytes);
|
|
|
|
if (get_struct(pid, (void *)args[sc->offset], fds, bytes)
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
used = 0;
|
|
|
|
tmpsize = 1 + numfds * per_fd + 2;
|
|
|
|
if ((tmp = malloc(tmpsize)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot alloc %d bytes for fd_set "
|
|
|
|
"output", tmpsize);
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
tmp[used++] = '{';
|
|
|
|
for (i = 0; i < numfds; i++) {
|
|
|
|
if (FD_ISSET(i, fds)) {
|
2012-09-02 11:03:18 +00:00
|
|
|
u = snprintf(tmp + used, per_fd, "%d ",
|
|
|
|
i);
|
2008-07-31 17:15:21 +00:00
|
|
|
if (u > 0)
|
|
|
|
used += u < per_fd ? u : per_fd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tmp[used-1] == ' ')
|
|
|
|
used--;
|
|
|
|
tmp[used++] = '}';
|
|
|
|
tmp[used++] = '\0';
|
2012-09-02 11:03:18 +00:00
|
|
|
} else
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
free(fds);
|
|
|
|
break;
|
|
|
|
}
|
2013-09-12 18:08:25 +00:00
|
|
|
case Signal:
|
|
|
|
tmp = strsig2(args[sc->offset]);
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
case Sigset: {
|
|
|
|
long sig;
|
|
|
|
sigset_t ss;
|
|
|
|
int i, used;
|
2013-09-12 18:08:25 +00:00
|
|
|
char *signame;
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
sig = args[sc->offset];
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
|
|
|
|
sizeof(ss)) == -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp = malloc(sys_nsig * 8); /* 7 bytes avg per signal name */
|
|
|
|
used = 0;
|
|
|
|
for (i = 1; i < sys_nsig; i++) {
|
2013-09-12 18:08:25 +00:00
|
|
|
if (sigismember(&ss, i)) {
|
|
|
|
signame = strsig(i);
|
|
|
|
used += sprintf(tmp + used, "%s|", signame);
|
|
|
|
free(signame);
|
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
}
|
|
|
|
if (used)
|
|
|
|
tmp[used-1] = 0;
|
|
|
|
else
|
|
|
|
strcpy(tmp, "0x0");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Sigprocmask: {
|
|
|
|
switch (args[sc->offset]) {
|
2012-09-02 11:03:18 +00:00
|
|
|
#define S(a) case a: tmp = strdup(#a); break;
|
2008-07-31 17:15:21 +00:00
|
|
|
S(SIG_BLOCK);
|
|
|
|
S(SIG_UNBLOCK);
|
|
|
|
S(SIG_SETMASK);
|
2004-03-23 09:04:06 +00:00
|
|
|
#undef S
|
2008-07-31 17:15:21 +00:00
|
|
|
}
|
|
|
|
if (tmp == NULL)
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Fcntlflag: {
|
|
|
|
/* XXX output depends on the value of the previous argument */
|
|
|
|
switch (args[sc->offset-1]) {
|
|
|
|
case F_SETFD:
|
2012-09-02 11:03:18 +00:00
|
|
|
tmp = strdup(xlookup_bits(fcntlfd_arg,
|
|
|
|
args[sc->offset]));
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
case F_SETFL:
|
2012-09-02 11:03:18 +00:00
|
|
|
tmp = strdup(xlookup_bits(fcntlfl_arg,
|
|
|
|
args[sc->offset]));
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
case F_GETFD:
|
|
|
|
case F_GETFL:
|
|
|
|
case F_GETOWN:
|
|
|
|
tmp = strdup("");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Open:
|
|
|
|
tmp = strdup(xlookup_bits(open_flags, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Fcntl:
|
|
|
|
tmp = strdup(xlookup(fcntl_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Mprot:
|
|
|
|
tmp = strdup(xlookup_bits(mprot_flags, args[sc->offset]));
|
|
|
|
break;
|
2013-08-16 21:13:55 +00:00
|
|
|
case Mmapflags: {
|
2013-08-19 17:09:14 +00:00
|
|
|
char *base, *alignstr;
|
2013-08-16 21:13:55 +00:00
|
|
|
int align, flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MAP_ALIGNED can't be handled by xlookup_bits(), so
|
|
|
|
* generate that string manually and prepend it to the
|
|
|
|
* string from xlookup_bits(). Have to be careful to
|
|
|
|
* avoid outputting MAP_ALIGNED|0 if MAP_ALIGNED is
|
|
|
|
* the only flag.
|
|
|
|
*/
|
|
|
|
flags = args[sc->offset] & ~MAP_ALIGNMENT_MASK;
|
|
|
|
align = args[sc->offset] & MAP_ALIGNMENT_MASK;
|
|
|
|
if (align != 0) {
|
|
|
|
if (align == MAP_ALIGNED_SUPER)
|
|
|
|
alignstr = strdup("MAP_ALIGNED_SUPER");
|
|
|
|
else
|
|
|
|
asprintf(&alignstr, "MAP_ALIGNED(%d)",
|
|
|
|
align >> MAP_ALIGNMENT_SHIFT);
|
|
|
|
if (flags == 0) {
|
|
|
|
tmp = alignstr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
alignstr = NULL;
|
|
|
|
base = strdup(xlookup_bits(mmap_flags, flags));
|
|
|
|
if (alignstr == NULL) {
|
|
|
|
tmp = base;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
asprintf(&tmp, "%s|%s", alignstr, base);
|
|
|
|
free(alignstr);
|
|
|
|
free(base);
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
2013-08-16 21:13:55 +00:00
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Whence:
|
|
|
|
tmp = strdup(xlookup(whence_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Sockdomain:
|
|
|
|
tmp = strdup(xlookup(sockdomain_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Socktype:
|
|
|
|
tmp = strdup(xlookup(socktype_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Shutdown:
|
|
|
|
tmp = strdup(xlookup(shutdown_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Resource:
|
|
|
|
tmp = strdup(xlookup(resource_arg, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Pathconf:
|
|
|
|
tmp = strdup(xlookup(pathconf_arg, args[sc->offset]));
|
|
|
|
break;
|
2013-08-01 02:57:04 +00:00
|
|
|
case Rforkflags:
|
|
|
|
tmp = strdup(xlookup_bits(rfork_flags, args[sc->offset]));
|
|
|
|
break;
|
2008-07-31 17:15:21 +00:00
|
|
|
case Sockaddr: {
|
|
|
|
struct sockaddr_storage ss;
|
|
|
|
char addr[64];
|
|
|
|
struct sockaddr_in *lsin;
|
|
|
|
struct sockaddr_in6 *lsin6;
|
|
|
|
struct sockaddr_un *sun;
|
|
|
|
struct sockaddr *sa;
|
|
|
|
char *p;
|
|
|
|
u_char *q;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (args[sc->offset] == 0) {
|
|
|
|
asprintf(&tmp, "NULL");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* yuck: get ss_len */
|
|
|
|
if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
|
2012-09-02 11:03:18 +00:00
|
|
|
sizeof(ss.ss_len) + sizeof(ss.ss_family)) == -1)
|
2008-07-31 17:15:21 +00:00
|
|
|
err(1, "get_struct %p", (void *)args[sc->offset]);
|
|
|
|
/*
|
|
|
|
* If ss_len is 0, then try to guess from the sockaddr type.
|
|
|
|
* AF_UNIX may be initialized incorrectly, so always frob
|
|
|
|
* it by using the "right" size.
|
|
|
|
*/
|
|
|
|
if (ss.ss_len == 0 || ss.ss_family == AF_UNIX) {
|
|
|
|
switch (ss.ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
ss.ss_len = sizeof(*lsin);
|
|
|
|
break;
|
|
|
|
case AF_UNIX:
|
|
|
|
ss.ss_len = sizeof(*sun);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* hurrrr */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
|
|
|
|
ss.ss_len) == -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
err(2, "get_struct %p", (void *)args[sc->offset]);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ss.ss_family) {
|
|
|
|
case AF_INET:
|
|
|
|
lsin = (struct sockaddr_in *)&ss;
|
|
|
|
inet_ntop(AF_INET, &lsin->sin_addr, addr, sizeof addr);
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp, "{ AF_INET %s:%d }", addr,
|
|
|
|
htons(lsin->sin_port));
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
lsin6 = (struct sockaddr_in6 *)&ss;
|
2012-09-02 11:03:18 +00:00
|
|
|
inet_ntop(AF_INET6, &lsin6->sin6_addr, addr,
|
|
|
|
sizeof addr);
|
|
|
|
asprintf(&tmp, "{ AF_INET6 [%s]:%d }", addr,
|
|
|
|
htons(lsin6->sin6_port));
|
2008-07-31 17:15:21 +00:00
|
|
|
break;
|
|
|
|
case AF_UNIX:
|
|
|
|
sun = (struct sockaddr_un *)&ss;
|
|
|
|
asprintf(&tmp, "{ AF_UNIX \"%s\" }", sun->sun_path);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sa = (struct sockaddr *)&ss;
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp, "{ sa_len = %d, sa_family = %d, sa_data "
|
|
|
|
"= {%n%*s } }", (int)sa->sa_len, (int)sa->sa_family,
|
|
|
|
&i, 6 * (int)(sa->sa_len - ((char *)&sa->sa_data -
|
|
|
|
(char *)sa)), "");
|
2008-07-31 17:15:21 +00:00
|
|
|
if (tmp != NULL) {
|
|
|
|
p = tmp + i;
|
2012-09-02 11:03:18 +00:00
|
|
|
for (q = (u_char *)&sa->sa_data;
|
|
|
|
q < (u_char *)sa + sa->sa_len; q++)
|
2008-07-31 17:15:21 +00:00
|
|
|
p += sprintf(p, " %#02x,", *q);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-03-23 09:04:06 +00:00
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Sigaction: {
|
|
|
|
struct sigaction sa;
|
|
|
|
char *hand;
|
|
|
|
const char *h;
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &sa, sizeof(sa))
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&hand, "%p", sa.sa_handler);
|
|
|
|
if (sa.sa_handler == SIG_DFL)
|
|
|
|
h = "SIG_DFL";
|
|
|
|
else if (sa.sa_handler == SIG_IGN)
|
|
|
|
h = "SIG_IGN";
|
|
|
|
else
|
|
|
|
h = hand;
|
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp, "{ %s %s ss_t }", h,
|
2008-07-31 17:15:21 +00:00
|
|
|
xlookup_bits(sigaction_flags, sa.sa_flags));
|
|
|
|
free(hand);
|
2012-09-02 11:03:18 +00:00
|
|
|
} else
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
2001-11-06 19:26:51 +00:00
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Kevent: {
|
|
|
|
/*
|
|
|
|
* XXX XXX: the size of the array is determined by either the
|
|
|
|
* next syscall argument, or by the syscall returnvalue,
|
|
|
|
* depending on which argument number we are. This matches the
|
|
|
|
* kevent syscall, but luckily that's the only syscall that uses
|
|
|
|
* them.
|
|
|
|
*/
|
|
|
|
struct kevent *ke;
|
|
|
|
int numevents = -1;
|
|
|
|
int bytes = 0;
|
|
|
|
int i, tmpsize, u, used;
|
|
|
|
const int per_ke = 100;
|
|
|
|
|
|
|
|
if (sc->offset == 1)
|
|
|
|
numevents = args[sc->offset+1];
|
|
|
|
else if (sc->offset == 3 && retval != -1)
|
|
|
|
numevents = retval;
|
|
|
|
|
|
|
|
if (numevents >= 0)
|
|
|
|
bytes = sizeof(struct kevent) * numevents;
|
|
|
|
if ((ke = malloc(bytes)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot malloc %d bytes for kevent array",
|
|
|
|
bytes);
|
|
|
|
if (numevents >= 0 && get_struct(pid, (void *)args[sc->offset],
|
|
|
|
ke, bytes) != -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
used = 0;
|
|
|
|
tmpsize = 1 + per_ke * numevents + 2;
|
|
|
|
if ((tmp = malloc(tmpsize)) == NULL)
|
2012-09-02 11:03:18 +00:00
|
|
|
err(1, "Cannot alloc %d bytes for kevent "
|
|
|
|
"output", tmpsize);
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
tmp[used++] = '{';
|
|
|
|
for (i = 0; i < numevents; i++) {
|
|
|
|
u = snprintf(tmp + used, per_ke,
|
|
|
|
"%s%p,%s,%s,%d,%p,%p",
|
|
|
|
i > 0 ? " " : "",
|
|
|
|
(void *)ke[i].ident,
|
|
|
|
xlookup(kevent_filters, ke[i].filter),
|
|
|
|
xlookup_bits(kevent_flags, ke[i].flags),
|
|
|
|
ke[i].fflags,
|
|
|
|
(void *)ke[i].data,
|
|
|
|
(void *)ke[i].udata);
|
|
|
|
if (u > 0)
|
|
|
|
used += u < per_ke ? u : per_ke;
|
|
|
|
}
|
|
|
|
tmp[used++] = '}';
|
|
|
|
tmp[used++] = '\0';
|
|
|
|
} else {
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
}
|
|
|
|
free(ke);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Stat: {
|
|
|
|
struct stat st;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st))
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
char mode[12];
|
|
|
|
strmode(st.st_mode, mode);
|
2012-09-02 11:03:18 +00:00
|
|
|
asprintf(&tmp,
|
|
|
|
"{ mode=%s,inode=%jd,size=%jd,blksize=%ld }", mode,
|
|
|
|
(intmax_t)st.st_ino, (intmax_t)st.st_size,
|
|
|
|
(long)st.st_blksize);
|
2008-07-31 17:15:21 +00:00
|
|
|
} else {
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
}
|
|
|
|
break;
|
- Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
pathconf, truncate, ftruncate, kill
- Decode more arguments of open, mprot, *stat, and fcntl.
- Convert all constant-macro and bitfield decoding to lookup tables; much
cleaner than previous code.
- Print the timestamp of process exit and signal reception when -d or -D are in
use
- Try six times with 1/2 second delay to debug the child
PR: bin/52190 (updated)
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: alfred
2006-05-15 21:18:28 +00:00
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
case Rusage: {
|
|
|
|
struct rusage ru;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &ru, sizeof(ru))
|
|
|
|
!= -1) {
|
|
|
|
asprintf(&tmp,
|
|
|
|
"{ u=%ld.%06ld,s=%ld.%06ld,in=%ld,out=%ld }",
|
2008-07-31 17:15:21 +00:00
|
|
|
(long)ru.ru_utime.tv_sec, ru.ru_utime.tv_usec,
|
|
|
|
(long)ru.ru_stime.tv_sec, ru.ru_stime.tv_usec,
|
|
|
|
ru.ru_inblock, ru.ru_oublock);
|
2012-09-02 11:03:18 +00:00
|
|
|
} else
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Rlimit: {
|
|
|
|
struct rlimit rl;
|
2012-09-02 11:03:18 +00:00
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &rl, sizeof(rl))
|
|
|
|
!= -1) {
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "{ cur=%ju,max=%ju }",
|
|
|
|
rl.rlim_cur, rl.rlim_max);
|
2012-09-02 11:03:18 +00:00
|
|
|
} else
|
2008-07-31 17:15:21 +00:00
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
break;
|
|
|
|
}
|
2013-09-12 18:08:25 +00:00
|
|
|
case ExitStatus: {
|
|
|
|
char *signame;
|
|
|
|
int status;
|
|
|
|
signame = NULL;
|
|
|
|
if (get_struct(pid, (void *)args[sc->offset], &status,
|
|
|
|
sizeof(status)) != -1) {
|
|
|
|
if (WIFCONTINUED(status))
|
|
|
|
tmp = strdup("{ CONTINUED }");
|
|
|
|
else if (WIFEXITED(status))
|
|
|
|
asprintf(&tmp, "{ EXITED,val=%d }",
|
|
|
|
WEXITSTATUS(status));
|
|
|
|
else if (WIFSIGNALED(status))
|
|
|
|
asprintf(&tmp, "{ SIGNALED,sig=%s%s }",
|
|
|
|
signame = strsig2(WTERMSIG(status)),
|
|
|
|
WCOREDUMP(status) ? ",cored" : "");
|
|
|
|
else
|
|
|
|
asprintf(&tmp, "{ STOPPED,sig=%s }",
|
|
|
|
signame = strsig2(WTERMSIG(status)));
|
|
|
|
} else
|
|
|
|
asprintf(&tmp, "0x%lx", args[sc->offset]);
|
|
|
|
free(signame);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Waitoptions:
|
|
|
|
tmp = strdup(xlookup_bits(wait_options, args[sc->offset]));
|
|
|
|
break;
|
|
|
|
case Idtype:
|
|
|
|
tmp = strdup(xlookup(idtype_arg, args[sc->offset]));
|
|
|
|
break;
|
2013-09-19 18:53:42 +00:00
|
|
|
case Procctl:
|
|
|
|
tmp = strdup(xlookup(procctl_arg, args[sc->offset]));
|
|
|
|
break;
|
2014-10-13 16:37:06 +00:00
|
|
|
case Umtxop:
|
|
|
|
tmp = strdup(xlookup(umtx_ops, args[sc->offset]));
|
|
|
|
break;
|
2008-07-31 17:15:21 +00:00
|
|
|
default:
|
|
|
|
errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK);
|
|
|
|
}
|
|
|
|
return (tmp);
|
1997-12-06 05:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* print_syscall
|
|
|
|
* Print (to outfile) the system call and its arguments. Note that
|
|
|
|
* nargs is the number of arguments (not the number of words; this is
|
|
|
|
* potentially confusing, I know).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-09-02 11:03:18 +00:00
|
|
|
print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
|
|
|
|
char **s_args)
|
2008-07-31 17:15:21 +00:00
|
|
|
{
|
|
|
|
struct timespec timediff;
|
2012-09-02 11:03:18 +00:00
|
|
|
int i, len;
|
2008-07-31 17:15:21 +00:00
|
|
|
|
2012-09-02 11:03:18 +00:00
|
|
|
len = 0;
|
2008-07-31 17:15:21 +00:00
|
|
|
if (trussinfo->flags & FOLLOWFORKS)
|
|
|
|
len += fprintf(trussinfo->outfile, "%5d: ", trussinfo->pid);
|
|
|
|
|
2012-09-16 14:38:01 +00:00
|
|
|
if (name != NULL && (strcmp(name, "execve") == 0 ||
|
2012-09-02 11:03:18 +00:00
|
|
|
strcmp(name, "exit") == 0)) {
|
2012-09-16 14:38:01 +00:00
|
|
|
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
2008-07-31 17:15:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
2013-02-26 19:46:59 +00:00
|
|
|
timespecsubt(&trussinfo->curthread->after,
|
2012-09-16 14:38:01 +00:00
|
|
|
&trussinfo->start_time, &timediff);
|
2008-07-31 17:15:21 +00:00
|
|
|
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
|
|
|
(long)timediff.tv_sec, timediff.tv_nsec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
2013-02-26 19:46:59 +00:00
|
|
|
timespecsubt(&trussinfo->curthread->after,
|
2012-09-16 14:38:01 +00:00
|
|
|
&trussinfo->curthread->before, &timediff);
|
2008-07-31 17:15:21 +00:00
|
|
|
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
|
|
|
(long)timediff.tv_sec, timediff.tv_nsec);
|
|
|
|
}
|
|
|
|
|
|
|
|
len += fprintf(trussinfo->outfile, "%s(", name);
|
|
|
|
|
|
|
|
for (i = 0; i < nargs; i++) {
|
|
|
|
if (s_args[i])
|
|
|
|
len += fprintf(trussinfo->outfile, "%s", s_args[i]);
|
|
|
|
else
|
2012-09-02 11:03:18 +00:00
|
|
|
len += fprintf(trussinfo->outfile,
|
|
|
|
"<missing argument>");
|
|
|
|
len += fprintf(trussinfo->outfile, "%s", i < (nargs - 1) ?
|
|
|
|
"," : "");
|
2008-07-31 17:15:21 +00:00
|
|
|
}
|
|
|
|
len += fprintf(trussinfo->outfile, ")");
|
|
|
|
for (i = 0; i < 6 - (len / 8); i++)
|
|
|
|
fprintf(trussinfo->outfile, "\t");
|
2000-03-18 08:49:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-11-09 03:48:13 +00:00
|
|
|
print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
|
2009-05-12 20:42:12 +00:00
|
|
|
char **s_args, int errorp, long retval, struct syscall *sc)
|
2003-11-09 03:48:13 +00:00
|
|
|
{
|
2009-05-12 20:42:12 +00:00
|
|
|
struct timespec timediff;
|
|
|
|
|
|
|
|
if (trussinfo->flags & COUNTONLY) {
|
|
|
|
if (!sc)
|
|
|
|
return;
|
2012-09-16 14:38:01 +00:00
|
|
|
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
2013-02-26 19:46:59 +00:00
|
|
|
timespecsubt(&trussinfo->curthread->after,
|
2012-09-16 14:38:01 +00:00
|
|
|
&trussinfo->curthread->before, &timediff);
|
2013-02-26 19:46:59 +00:00
|
|
|
timespecadd(&sc->time, &timediff, &sc->time);
|
2009-05-12 20:42:12 +00:00
|
|
|
sc->ncalls++;
|
|
|
|
if (errorp)
|
|
|
|
sc->nerror++;
|
|
|
|
return;
|
|
|
|
}
|
2008-07-31 17:15:21 +00:00
|
|
|
|
|
|
|
print_syscall(trussinfo, name, nargs, s_args);
|
|
|
|
fflush(trussinfo->outfile);
|
2012-09-02 11:03:18 +00:00
|
|
|
if (errorp)
|
|
|
|
fprintf(trussinfo->outfile, " ERR#%ld '%s'\n", retval,
|
|
|
|
strerror(retval));
|
|
|
|
else {
|
2009-12-21 17:38:13 +00:00
|
|
|
/*
|
|
|
|
* Because pipe(2) has a special assembly glue to provide the
|
|
|
|
* libc API, we have to adjust retval.
|
|
|
|
*/
|
2012-09-02 11:03:18 +00:00
|
|
|
if (name != NULL && strcmp(name, "pipe") == 0)
|
2009-12-21 17:38:13 +00:00
|
|
|
retval = 0;
|
2008-07-31 17:15:21 +00:00
|
|
|
fprintf(trussinfo->outfile, " = %ld (0x%lx)\n", retval, retval);
|
|
|
|
}
|
1997-12-06 05:23:12 +00:00
|
|
|
}
|
2009-05-12 20:42:12 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
print_summary(struct trussinfo *trussinfo)
|
|
|
|
{
|
|
|
|
struct timespec total = {0, 0};
|
2012-09-02 11:03:18 +00:00
|
|
|
struct syscall *sc;
|
2009-05-12 20:42:12 +00:00
|
|
|
int ncall, nerror;
|
|
|
|
|
|
|
|
fprintf(trussinfo->outfile, "%-20s%15s%8s%8s\n",
|
2012-09-02 11:03:18 +00:00
|
|
|
"syscall", "seconds", "calls", "errors");
|
2009-05-12 20:42:12 +00:00
|
|
|
ncall = nerror = 0;
|
|
|
|
for (sc = syscalls; sc->name != NULL; sc++)
|
|
|
|
if (sc->ncalls) {
|
2009-12-21 17:41:57 +00:00
|
|
|
fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
|
|
|
|
sc->name, (intmax_t)sc->time.tv_sec,
|
|
|
|
sc->time.tv_nsec, sc->ncalls, sc->nerror);
|
2013-02-26 19:46:59 +00:00
|
|
|
timespecadd(&total, &sc->time, &total);
|
2009-05-12 20:42:12 +00:00
|
|
|
ncall += sc->ncalls;
|
|
|
|
nerror += sc->nerror;
|
|
|
|
}
|
|
|
|
fprintf(trussinfo->outfile, "%20s%15s%8s%8s\n",
|
2012-09-02 11:03:18 +00:00
|
|
|
"", "-------------", "-------", "-------");
|
2009-12-21 17:41:57 +00:00
|
|
|
fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
|
2012-09-02 11:03:18 +00:00
|
|
|
"", (intmax_t)total.tv_sec, total.tv_nsec, ncall, nerror);
|
2009-05-12 20:42:12 +00:00
|
|
|
}
|