Home | History | Annotate | Download | only in truss
      1     0  stevel /*
      2     0  stevel  * CDDL HEADER START
      3     0  stevel  *
      4     0  stevel  * The contents of this file are subject to the terms of the
      5  2192     raf  * Common Development and Distribution License (the "License").
      6  2192     raf  * You may not use this file except in compliance with the License.
      7     0  stevel  *
      8     0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9     0  stevel  * or http://www.opensolaris.org/os/licensing.
     10     0  stevel  * See the License for the specific language governing permissions
     11     0  stevel  * and limitations under the License.
     12     0  stevel  *
     13     0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     14     0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15     0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     16     0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     17     0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     18     0  stevel  *
     19     0  stevel  * CDDL HEADER END
     20     0  stevel  */
     21  1132     raf 
     22     0  stevel /*
     23  7675  Edward  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24     0  stevel  * Use is subject to license terms.
     25     0  stevel  */
     26     0  stevel 
     27     0  stevel /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
     28     0  stevel /*	  All Rights Reserved  	*/
     29     0  stevel 
     30     0  stevel #include <stdio.h>
     31     0  stevel #include <stdlib.h>
     32     0  stevel #include <unistd.h>
     33     0  stevel #include <sys/types.h>
     34     0  stevel #include <libproc.h>
     35     0  stevel #include "ramdata.h"
     36     0  stevel #include "proto.h"
     37     0  stevel #include "htbl.h"
     38     0  stevel 
     39     0  stevel /*
     40     0  stevel  * ramdata.c -- read/write data definitions are collected here.
     41     0  stevel  * Default initialization of zero applies in all cases.
     42     0  stevel  */
     43     0  stevel 
     44     0  stevel thread_key_t private_key;	/* set by thr_keycreate() */
     45     0  stevel char	*command;		/* name of command ("truss") */
     46     0  stevel int	interrupt;		/* interrupt signal was received */
     47     0  stevel int	sigusr1;		/* received SIGUSR1 (release process) */
     48     0  stevel int	sfd;			/* shared tmp file descriptor */
     49     0  stevel pid_t	created;		/* if process was created, its process id */
     50     0  stevel uid_t	Euid;			/* truss's effective uid */
     51     0  stevel uid_t	Egid;			/* truss's effective gid */
     52     0  stevel uid_t	Ruid;			/* truss's real uid */
     53     0  stevel uid_t	Rgid;			/* truss's real gid */
     54     0  stevel prcred_t credentials;		/* traced process credentials */
     55     0  stevel int	istty;			/* TRUE iff output is a tty */
     56     0  stevel time_t	starttime;		/* start time */
     57     0  stevel 
     58     0  stevel int	Fflag;			/* option flags from getopt() */
     59     0  stevel int	fflag;
     60     0  stevel int	cflag;
     61     0  stevel int	aflag;
     62     0  stevel int	eflag;
     63     0  stevel int	iflag;
     64     0  stevel int	lflag;
     65     0  stevel int	tflag;
     66     0  stevel int	pflag;
     67     0  stevel int	sflag;
     68     0  stevel int	mflag;
     69     0  stevel int	oflag;
     70     0  stevel int	vflag;
     71     0  stevel int	xflag;
     72     0  stevel int	hflag;
     73     0  stevel 
     74     0  stevel int	dflag;
     75     0  stevel int	Dflag;
     76     0  stevel int	Eflag;
     77     0  stevel int	Tflag;
     78     0  stevel int	Sflag;
     79     0  stevel int	Mflag;
     80     0  stevel 
     81     0  stevel sysset_t trace;			/* sys calls to trace */
     82     0  stevel sysset_t traceeven;		/* sys calls to trace even if not reported */
     83     0  stevel sysset_t verbose;		/* sys calls to be verbose about */
     84     0  stevel sysset_t rawout;		/* sys calls to show in raw mode */
     85     0  stevel sigset_t signals;		/* signals to trace */
     86     0  stevel fltset_t faults;		/* faults to trace */
     87     0  stevel fileset_t readfd;		/* read() file descriptors to dump */
     88     0  stevel fileset_t writefd;		/* write() file descriptors to dump */
     89     0  stevel 
     90     0  stevel mutex_t	truss_lock;		/* protects almost everything */
     91     0  stevel cond_t	truss_cv;
     92     0  stevel mutex_t count_lock;		/* lock protecting count struct Cp */
     93     0  stevel 
     94     0  stevel htbl_t	*fcall_tbl;		/* ptr to hash tbl counting function calls */
     95     0  stevel 
     96     0  stevel int	truss_nlwp;		/* number of truss lwps */
     97     0  stevel int	truss_maxlwp;		/* number of entries in truss_lwpid */
     98     0  stevel lwpid_t	*truss_lwpid;		/* array of truss lwpid's */
     99     0  stevel 
    100     0  stevel struct counts *Cp;		/* for counting: malloc() or shared memory */
    101     0  stevel struct global_psinfo *gps;	/* contains global process information */
    102     0  stevel 
    103  7675  Edward struct dynlib *Dynlib;		/* for tracing functions in shared libraries */
    104     0  stevel struct dynpat *Dynpat;
    105     0  stevel struct dynpat *Lastpat;
    106     0  stevel struct bkpt **bpt_hashtable;	/* breakpoint hash table */
    107     0  stevel uint_t	nthr_create;		/* number of thr_create() calls seen so far */
    108     0  stevel struct callstack *callstack;	/* the callstack array */
    109     0  stevel uint_t	nstack;			/* number of detected stacks */
    110     0  stevel rd_agent_t *Rdb_agent;		/* run-time linker debug handle */
    111     0  stevel td_thragent_t *Thr_agent;	/* thread debug handle */
    112     0  stevel int	not_consist;		/* used while rebuilding breakpoint table */
    113  2192     raf int	delete_library;		/* used while rebuilding breakpoint table */
    114     0  stevel 
    115     0  stevel pid_t	ancestor;		/* top-level parent process id */
    116     0  stevel int	descendent;		/* TRUE iff descendent of top level */
    117     0  stevel int	is_vfork_child;		/* TRUE iff process is a vfork()ed child */
    118     0  stevel 
    119     0  stevel int	ngrab;			/* number of pid's that were grabbed */
    120     0  stevel 
    121     0  stevel struct ps_prochandle *Proc;	/* global reference to process */
    122     0  stevel int	data_model;		/* PR_MODEL_LP64 or PR_MODEL_ILP32 */
    123     0  stevel 
    124     0  stevel long	pagesize;		/* bytes per page; should be per-process */
    125     0  stevel 
    126     0  stevel int	exit_called;		/* _exit() syscall was seen */
    127     0  stevel 
    128     0  stevel lwpid_t	primary_lwp;		/* representative lwp on process grab */
    129     0  stevel 
    130     0  stevel sysset_t syshang;		/* sys calls to make process hang */
    131     0  stevel sigset_t sighang;		/* signals to make process hang */
    132     0  stevel fltset_t flthang;		/* faults to make process hang */
    133     0  stevel 
    134  1132     raf sigset_t emptyset;		/* no signals, for thr_sigsetmask() */
    135  1132     raf sigset_t fillset;		/* all signals, for thr_sigsetmask() */
    136  1132     raf 
    137     0  stevel int	leave_hung;		/* if TRUE, leave the process hung */
    138