listopts.c revision 657b1f3d64bcf8eaa2385dba72a6047f089433b2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <memory.h>
#include <signal.h>
#include <libproc.h>
#include "ramdata.h"
#include "systable.h"
#include "proto.h"
/* XXX A bug in the <string.h> header file requires this */
/*
* option procesing ---
* Routines for scanning syscall, signal, fault
* and file descriptor lists.
*/
/*
* Function prototypes for static routines in this module.
*/
void upcase(char *);
/*
* Scan list of syscall names.
* Return 0 on success, != 0 on any failure.
*/
int
int *fp) /* first-time flag */
{
char *name;
int rc = 0;
char *lasts;
if (*++name == '\0')
} else if (!*fp) { /* first time, clear the set */
}
int sys;
int sysx;
int sysxx;
int sys64;
char *next;
while (*++name == '!')
/* empty */;
if (*name == '\0')
continue;
}
sys = 0;
if (sys == 0) {
}
if (sys == 0) {
}
switch (sys) {
case SYS_xstat: /* set all if any */
case SYS_stat:
case SYS_stat64:
sys64 = SYS_stat64;
goto def;
case SYS_lxstat: /* set all if any */
case SYS_lstat:
case SYS_lstat64:
sysx = SYS_lxstat;
sys64 = SYS_lstat64;
goto def;
case SYS_fxstat: /* set all if any */
case SYS_fstat:
case SYS_fstat64:
sysx = SYS_fxstat;
sys64 = SYS_fstat64;
goto def;
case SYS_getdents: /* set both if either */
case SYS_getdents64:
sys = SYS_getdents;
goto def;
case SYS_mmap: /* set both if either */
case SYS_mmap64:
sys64 = SYS_mmap64;
goto def;
case SYS_statvfs: /* set both if either */
case SYS_statvfs64:
sys = SYS_statvfs;
goto def;
case SYS_fstatvfs: /* set both if either */
case SYS_fstatvfs64:
sys = SYS_fstatvfs;
goto def;
case SYS_setrlimit: /* set both if either */
case SYS_setrlimit64:
sys = SYS_setrlimit;
goto def;
case SYS_getrlimit: /* set both if either */
case SYS_getrlimit64:
sys = SYS_getrlimit;
goto def;
case SYS_pread: /* set both if either */
case SYS_pread64:
sys64 = SYS_pread64;
goto def;
case SYS_pwrite: /* set both if either */
case SYS_pwrite64:
sys = SYS_pwrite;
goto def;
case SYS_creat: /* set both if either */
case SYS_creat64:
sys64 = SYS_creat64;
goto def;
case SYS_open: /* set both if either */
case SYS_open64:
sys64 = SYS_open64;
goto def;
case SYS_xmknod: /* set both if either */
case SYS_mknod:
sysx = SYS_xmknod;
goto def;
case SYS_forkall: /* set all if any */
case SYS_fork1:
case SYS_vfork:
case SYS_forksys:
sys = SYS_forkall;
sysxx = SYS_forksys;
goto def;
case SYS_exec: /* set both if either */
case SYS_execve:
sys = SYS_execve;
goto def;
case SYS_poll: /* set both if either */
case SYS_pollsys:
sys = SYS_pollsys;
goto def;
case SYS_sigprocmask: /* set both if either */
case SYS_lwp_sigmask:
goto def;
case SYS_wait: /* set both if either */
case SYS_waitsys:
sys = SYS_waitsys;
goto def;
case SYS_lseek: /* set both if either */
case SYS_llseek:
sys = SYS_llseek;
goto def;
case SYS_lwp_mutex_lock: /* set both if either */
case SYS_lwp_mutex_timedlock:
goto def;
case SYS_lwp_sema_wait: /* set both if either */
case SYS_lwp_sema_timedwait:
goto def;
default:
def:
if (exclude) {
if (sysx)
if (sysxx)
if (sys64)
} else {
if (sysx)
if (sysxx)
if (sys64)
}
break;
}
if (exclude) {
} else {
}
} else {
"%s: unrecognized syscall: %s\n",
rc = -1;
}
}
return (rc);
}
/*
* List of signals to trace.
* Return 0 on success, != 0 on any failure.
*/
int
char *str, /* string of signal names */
int *fp) /* first-time flag */
{
char *name;
int rc = 0;
char *lasts;
if (*++name == '\0')
} else if (!*fp) { /* first time, clear the set */
}
int sig;
char *next;
while (*++name == '!')
/* empty */;
if (*name == '\0')
continue;
}
continue;
break;
}
sig = 0;
}
if (exclude) {
} else {
}
if (exclude) {
} else {
}
} else {
rc = -1;
}
}
return (rc);
}
/*
* List of faults to trace.
* return 0 on success, != 0 on any failure.
*/
int
int *fp) /* first-time flag */
{
char *name;
int rc = 0;
char *lasts;
if (*++name == '\0')
} else if (!*fp) { /* first time, clear the set */
}
int flt;
char *next;
while (*++name == '!')
/* empty */;
if (*name == '\0')
continue;
}
char fname[32];
continue;
break;
}
if (flt > PRMAXFAULT)
flt = 0;
}
if (exclude) {
} else {
}
if (exclude) {
} else {
}
} else {
rc = -1;
}
}
return (rc);
}
/*
* Gather file descriptors to dump.
* Return 0 on success, != 0 on any failure.
*/
int
{
char *name;
int rc = 0;
char *lasts;
if (*++name == '\0')
}
int fd;
char *next;
while (*++name == '!')
/* empty */;
if (*name == '\0')
continue;
}
fd++;
if (exclude) {
} else {
}
if (exclude) {
} else {
}
} else {
"%s: filedescriptor not in range[0..%d]: %s\n",
rc = -1;
}
}
return (rc);
}
void
{
int c;
while ((c = *str) != '\0')
}
/*
* 'arg' points to a string like:
* libc,libnsl,... : printf,read,write,...
* or
* libc,libnsl,... :: printf,read,write,...
* with possible filename pattern-matching metacharacters.
*
* Assumption: No library or function name can contain ',' or ':'.
*/
int
{
const char *star = "*";
char *pat;
char *fpat;
char *lasts;
/* append a new dynpat structure to the end of the Dynpat list */
else {
}
Dyp->exclude_lib = 0;
/*
* Find the beginning of the filename patterns
* and null-terminate the library name patterns.
*/
*fpat++ = '\0';
/*
* Library name patterns.
*/
/* '!' introduces an exclusion list */
if (*pat == '\0')
/* force exclusion of all functions as well */
}
/* empty list means all libraries */
} else {
/*
* We are now at the library list.
* Generate the list and count the library name patterns.
*/
maxpat = 1;
maxpat *= 2;
}
}
}
/*
* Function name patterns.
*/
else {
/*
* We have already seen a ':'. Look for another.
* Double ':' means trace internal calls.
*/
if (*fpat == ':') {
*fpat++ = '\0';
}
}
/* '!' introduces an exclusion list */
if (*pat == '\0')
}
/* empty function list means exclude all functions */
} else {
/*
* We are now at the function list.
* Generate the list and count the symbol name patterns.
*/
maxpat = 1;
maxpat *= 2;
}
}
}
return (0);
}