📄 defs.h
字号:
/* * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> * All rights reserved. * * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. * * $Id: defs.h,v 1.24 2001/03/28 08:05:27 hughesj Exp $ */#ifdef linux#include <features.h>#endif#ifdef HAVE_CONFIG_H#include "config.h"#endif/* configuration section */#ifndef MAX_QUALS#if defined(linux) && defined(MIPS)#define MAX_QUALS 4999 /* maximum number of syscalls, signals, etc. */#else#define MAX_QUALS 2048 /* maximum number of syscalls, signals, etc. */#endif#endif#ifndef MAX_PROCS#define MAX_PROCS 64 /* maximum number of processes tracable */#endif#ifndef DEFAULT_STRLEN#define DEFAULT_STRLEN 32 /* default maximum # of bytes printed in `printstr', change with `-s' switch */#endif#ifndef DEFAULT_ACOLUMN#define DEFAULT_ACOLUMN 40 /* default alignment column for results */#endif#ifndef MAX_ARGS#define MAX_ARGS 32 /* maximum number of args to a syscall */#endif#ifndef DEFAULT_SORTBY#define DEFAULT_SORTBY "time" /* default sorting method for call profiling */#endif#include <sys/types.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <string.h>#include <time.h>#include <sys/time.h>#include <errno.h>#ifdef STDC_HEADERS#include <stddef.h>#endif /* STDC_HEADERS */#if defined(LINUX)# if defined(SPARC)# define LINUXSPARC# endif# if defined(ALPHA)# define LINUX_64BIT# endif#endif #if defined(SVR4) || defined(FREEBSD)#define USE_PROCFS#else#undef USE_PROCFS#endif#ifdef FREEBSD#ifndef I386#error "FreeBSD support is only for i386 arch right now."#endif#include <machine/psl.h>#include <machine/reg.h>#include <sys/syscall.h>#endif#ifdef USE_PROCFS#include <sys/procfs.h>#ifdef HAVE_MP_PROCFS#include <sys/uio.h>#endif#ifdef FREEBSD#include <sys/pioctl.h>#endif /* FREEBSD */#else /* !USE_PROCFS */#if defined(LINUXSPARC) && defined(__GLIBC__)#include <sys/ptrace.h>#else/* Work around awkward prototype in ptrace.h. */#define ptrace xptrace#include <sys/ptrace.h>#undef ptrace#ifdef POWERPC#define __KERNEL__#include <asm/ptrace.h>#undef __KERNEL__/* TEMP */#define UESP PT_R1#define EIP PT_NIP#define EAX PT_R3#define ORIG_EAX PT_ORIG_R3#endif#ifdef __STDC__#ifdef LINUXextern long ptrace(int, int, char *, long);#else /* !LINUX */extern int ptrace(int, int, char *, int, ...);#endif /* !LINUX */#else /* !__STDC__ */extern int ptrace();#endif /* !__STDC__ */#endif /* !LINUXSPARC */#endif /* !SVR4 */#ifdef LINUX#if !defined(__GLIBC__)#define PTRACE_PEEKUSER PTRACE_PEEKUSR#define PTRACE_POKEUSER PTRACE_POKEUSR#endif#ifdef ALPHA# define REG_R0 0# define REG_A0 16# define REG_A3 19# define REG_FP 30# define REG_PC 64#endif /* ALPHA */#ifdef MIPS# define REG_V0 2# define REG_A0 4# define REG_A3 7# define REG_SP 29# define REG_EPC 64#endif /* MIPS */#ifdef HPPA# define PT_GR20 (20*4)# define PT_GR26 (26*4)# define PT_GR28 (28*4)# define PT_IAOQ0 (106*4)# define PT_IAOQ1 (107*4)#endif /* HPPA */#endif /* LINUX */#define SUPPORTED_PERSONALITIES 1#define DEFAULT_PERSONALITY 0#ifdef LINUXSPARC#include <linux/a.out.h>#include <asm/psr.h>#undef SUPPORTED_PERSONALITIES#define SUPPORTED_PERSONALITIES 2#endif /* LINUXSPARC */#ifdef SVR4#ifdef HAVE_MP_PROCFSextern int mp_ioctl (int f, int c, void *a, int s);#define IOCTL(f,c,a) mp_ioctl (f, c, a, sizeof *a)#define IOCTL_STATUS(t) \ pread (t->pfd_stat, &t->status, sizeof t->status, 0)#define IOCTL_WSTOP(t) \ (IOCTL (t->pfd, PCWSTOP, (char *)NULL) < 0 ? -1 : \ IOCTL_STATUS (t))#define PR_WHY pr_lwp.pr_why#define PR_WHAT pr_lwp.pr_what#define PR_REG pr_lwp.pr_context.uc_mcontext.gregs#define PR_FLAGS pr_lwp.pr_flags#define PR_SYSCALL pr_lwp.pr_syscall#define PIOCSTIP PCSTOP#define PIOCSET PCSET#define PIOCRESET PCRESET#define PIOCSTRACE PCSTRACE#define PIOCSFAULT PCSFAULT#define PIOCWSTOP PCWSTOP#define PIOCSTOP PCSTOP#define PIOCSENTRY PCSENTRY#define PIOCSEXIT PCSEXIT#define PIOCRUN PCRUN#else#define IOCTL ioctl#define IOCTL_STATUS(t) ioctl (t->pfd, PIOCSTATUS, &t->status)#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWSTOP, &t->status) #define PR_WHY pr_why#define PR_WHAT pr_what#define PR_REG pr_reg#define PR_FLAGS pr_flags#define PR_SYSCALL pr_syscall#endif#endif#ifdef FREEBSD#define IOCTL ioctl#define IOCTL_STATUS(t) ioctl (t->pfd, PIOCSTATUS, &t->status)#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWAIT, &t->status)#define PIOCRUN PIOCCONT#define PIOCWSTOP PIOCWAIT#define PR_WHY why#define PR_WHAT val#define PR_FLAGS state/* from /usr/src/sys/miscfs/procfs/procfs_vnops.c, status.state = 0 for running, 1 for stopped */#define PR_ASLEEP 1#define PR_SYSENTRY S_SCE#define PR_SYSEXIT S_SCX#define PR_SIGNALLED S_SIG#define PR_FAULTED S_CORE#endif/* Trace Control Block */struct tcb { short flags; /* See below for TCB_ values */ int pid; /* Process Id of this entry */ long scno; /* System call number */ int u_nargs; /* System call arguments */ long u_arg[MAX_ARGS]; /* System call arguments */ int u_error; /* Error code */ long u_rval; /* (first) return value */#ifdef HAVE_LONG_LONG long long u_lrval; /* long long return value */#endif FILE *outf; /* Output file for this process */ const char *auxstr; /* Auxiliary info from syscall (see RVAL_STR) */ struct timeval stime; /* System time usage as of last process wait */ struct timeval dtime; /* Delta for system time usage */ struct timeval etime; /* Syscall entry time */ /* Support for tracing forked processes */ struct tcb *parent; /* Parent of this process */ int nchildren; /* # of traced children */ int waitpid; /* pid(s) this process is waiting for */ /* (1st arg of wait4()) */ long baddr; /* `Breakpoint' address */ long inst[2]; /* Instructions on above */ int pfd; /* proc file descriptor */#ifdef SVR4#ifdef HAVE_MP_PROCFS int pfd_stat; int pfd_as; pstatus_t status;#else prstatus_t status; /* procfs status structure */#endif#endif#ifdef FREEBSD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -