xref: /onnv-gate/usr/src/cmd/truss/ramdata.c (revision 1132)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*1132Sraf 
230Sstevel@tonic-gate /*
24*1132Sraf  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
290Sstevel@tonic-gate /*	  All Rights Reserved  	*/
300Sstevel@tonic-gate 
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.3	*/
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <stdio.h>
350Sstevel@tonic-gate #include <stdlib.h>
360Sstevel@tonic-gate #include <unistd.h>
370Sstevel@tonic-gate #include <sys/types.h>
380Sstevel@tonic-gate #include <libproc.h>
390Sstevel@tonic-gate #include "ramdata.h"
400Sstevel@tonic-gate #include "proto.h"
410Sstevel@tonic-gate #include "htbl.h"
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * ramdata.c -- read/write data definitions are collected here.
450Sstevel@tonic-gate  * Default initialization of zero applies in all cases.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate 
480Sstevel@tonic-gate thread_key_t private_key;	/* set by thr_keycreate() */
490Sstevel@tonic-gate char	*command;		/* name of command ("truss") */
500Sstevel@tonic-gate int	interrupt;		/* interrupt signal was received */
510Sstevel@tonic-gate int	sigusr1;		/* received SIGUSR1 (release process) */
520Sstevel@tonic-gate int	sfd;			/* shared tmp file descriptor */
530Sstevel@tonic-gate pid_t	created;		/* if process was created, its process id */
540Sstevel@tonic-gate uid_t	Euid;			/* truss's effective uid */
550Sstevel@tonic-gate uid_t	Egid;			/* truss's effective gid */
560Sstevel@tonic-gate uid_t	Ruid;			/* truss's real uid */
570Sstevel@tonic-gate uid_t	Rgid;			/* truss's real gid */
580Sstevel@tonic-gate prcred_t credentials;		/* traced process credentials */
590Sstevel@tonic-gate int	istty;			/* TRUE iff output is a tty */
600Sstevel@tonic-gate time_t	starttime;		/* start time */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate int	Fflag;			/* option flags from getopt() */
630Sstevel@tonic-gate int	fflag;
640Sstevel@tonic-gate int	cflag;
650Sstevel@tonic-gate int	aflag;
660Sstevel@tonic-gate int	eflag;
670Sstevel@tonic-gate int	iflag;
680Sstevel@tonic-gate int	lflag;
690Sstevel@tonic-gate int	tflag;
700Sstevel@tonic-gate int	pflag;
710Sstevel@tonic-gate int	sflag;
720Sstevel@tonic-gate int	mflag;
730Sstevel@tonic-gate int	oflag;
740Sstevel@tonic-gate int	vflag;
750Sstevel@tonic-gate int	xflag;
760Sstevel@tonic-gate int	hflag;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate int	dflag;
790Sstevel@tonic-gate int	Dflag;
800Sstevel@tonic-gate int	Eflag;
810Sstevel@tonic-gate int	Tflag;
820Sstevel@tonic-gate int	Sflag;
830Sstevel@tonic-gate int	Mflag;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate sysset_t trace;			/* sys calls to trace */
860Sstevel@tonic-gate sysset_t traceeven;		/* sys calls to trace even if not reported */
870Sstevel@tonic-gate sysset_t verbose;		/* sys calls to be verbose about */
880Sstevel@tonic-gate sysset_t rawout;		/* sys calls to show in raw mode */
890Sstevel@tonic-gate sigset_t signals;		/* signals to trace */
900Sstevel@tonic-gate fltset_t faults;		/* faults to trace */
910Sstevel@tonic-gate fileset_t readfd;		/* read() file descriptors to dump */
920Sstevel@tonic-gate fileset_t writefd;		/* write() file descriptors to dump */
930Sstevel@tonic-gate 
940Sstevel@tonic-gate mutex_t	truss_lock;		/* protects almost everything */
950Sstevel@tonic-gate cond_t	truss_cv;
960Sstevel@tonic-gate mutex_t count_lock;		/* lock protecting count struct Cp */
970Sstevel@tonic-gate 
980Sstevel@tonic-gate htbl_t	*fcall_tbl;		/* ptr to hash tbl counting function calls */
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate int	truss_nlwp;		/* number of truss lwps */
1010Sstevel@tonic-gate int	truss_maxlwp;		/* number of entries in truss_lwpid */
1020Sstevel@tonic-gate lwpid_t	*truss_lwpid;		/* array of truss lwpid's */
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate struct counts *Cp;		/* for counting: malloc() or shared memory */
1050Sstevel@tonic-gate struct global_psinfo *gps;	/* contains global process information */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate struct dynlib *Dyn;		/* for tracing functions in shared libraries */
1080Sstevel@tonic-gate struct dynpat *Dynpat;
1090Sstevel@tonic-gate struct dynpat *Lastpat;
1100Sstevel@tonic-gate struct bkpt **bpt_hashtable;	/* breakpoint hash table */
1110Sstevel@tonic-gate uint_t	nthr_create;		/* number of thr_create() calls seen so far */
1120Sstevel@tonic-gate struct callstack *callstack;	/* the callstack array */
1130Sstevel@tonic-gate uint_t	nstack;			/* number of detected stacks */
1140Sstevel@tonic-gate rd_agent_t *Rdb_agent;		/* run-time linker debug handle */
1150Sstevel@tonic-gate td_thragent_t *Thr_agent;	/* thread debug handle */
1160Sstevel@tonic-gate int	not_consist;		/* used while rebuilding breakpoint table */
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate pid_t	ancestor;		/* top-level parent process id */
1190Sstevel@tonic-gate int	descendent;		/* TRUE iff descendent of top level */
1200Sstevel@tonic-gate int	is_vfork_child;		/* TRUE iff process is a vfork()ed child */
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate int	ngrab;			/* number of pid's that were grabbed */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate struct ps_prochandle *Proc;	/* global reference to process */
1250Sstevel@tonic-gate int	data_model;		/* PR_MODEL_LP64 or PR_MODEL_ILP32 */
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate long	pagesize;		/* bytes per page; should be per-process */
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate int	exit_called;		/* _exit() syscall was seen */
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate lwpid_t	primary_lwp;		/* representative lwp on process grab */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate sysset_t syshang;		/* sys calls to make process hang */
1340Sstevel@tonic-gate sigset_t sighang;		/* signals to make process hang */
1350Sstevel@tonic-gate fltset_t flthang;		/* faults to make process hang */
1360Sstevel@tonic-gate 
137*1132Sraf sigset_t emptyset;		/* no signals, for thr_sigsetmask() */
138*1132Sraf sigset_t fillset;		/* all signals, for thr_sigsetmask() */
139*1132Sraf 
1400Sstevel@tonic-gate int	leave_hung;		/* if TRUE, leave the process hung */
141