/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#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_fstatat: /* set both if either */
case SYS_fstatat64:
sys = SYS_fstatat;
goto def;
case SYS_stat: /* set all if either */
case SYS_stat64:
sys64 = SYS_stat64;
sysx = SYS_fstatat;
goto def;
case SYS_lstat: /* set all if either */
case SYS_lstat64:
sys64 = SYS_lstat64;
sysx = SYS_fstatat;
goto def;
case SYS_fstat: /* set all if either */
case SYS_fstat64:
sys64 = SYS_fstat64;
sysx = SYS_fstatat;
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_openat: /* set all if any */
case SYS_openat64:
case SYS_open:
case SYS_open64:
sys = SYS_openat;
sysxx = SYS_open64;
goto def;
case SYS_forksys: /* set both if either */
case SYS_vfork:
sysx = SYS_forksys;
goto def;
case SYS_sigprocmask: /* set both if either */
case SYS_lwp_sigmask:
goto def;
case SYS_lseek: /* set both if either */
case SYS_llseek:
sys = SYS_llseek;
goto def;
case SYS_rename: /* set both */
sysx = SYS_renameat;
goto def;
case SYS_link: /* set both */
sysx = SYS_linkat;
goto def;
case SYS_unlink: /* set both */
case SYS_rmdir: /* set both */
sysx = SYS_unlinkat;
goto def;
case SYS_symlink: /* set both */
goto def;
case SYS_readlink: /* set both */
goto def;
case SYS_chmod: /* set both */
case SYS_fchmod: /* set both */
sysx = SYS_fchmodat;
goto def;
case SYS_chown: /* set both */
case SYS_lchown: /* set both */
case SYS_fchown: /* set both */
sysx = SYS_fchownat;
goto def;
case SYS_mkdir: /* set both */
sysx = SYS_mkdirat;
goto def;
case SYS_mknod: /* set both */
sysx = SYS_mknodat;
goto def;
case SYS_access: /* set both */
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;
}
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
{
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);
}