home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / strace / part02 < prev    next >
Encoding:
Internet Message Format  |  1994-07-09  |  60.5 KB

  1. From: jrs@world.std.com (Rick Sladkey)
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i076:  strace - system call tracer for sunos, linux, svr4, solaris2, Part02/10
  4. Date: 9 Jul 1994 15:48:46 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2vn2fe$997@sparky.sterling.com>
  9. X-Md4-Signature: f01ce4e31f90db38ca98c1c201107df8
  10.  
  11. Submitted-by: jrs@world.std.com (Rick Sladkey)
  12. Posting-number: Volume 43, Issue 76
  13. Archive-name: strace/part02
  14. Environment: sunos, linux, svr4, solaris
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  strace-3.0/strace.c strace-3.0/sunos4/ioctlent.h
  21. #   strace-3.0/syscallent.sh
  22. # Wrapped by kent@sparky on Sat Jul  9 15:42:55 1994
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 2 (of 10)."'
  26. if test -f 'strace-3.0/strace.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'strace-3.0/strace.c'\"
  28. else
  29.   echo shar: Extracting \"'strace-3.0/strace.c'\" \(31363 characters\)
  30.   sed "s/^X//" >'strace-3.0/strace.c' <<'END_OF_FILE'
  31. X/*
  32. X * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  33. X * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  34. X * Copyright (c) 1993, 1994 Rick Sladkey <jrs@world.std.com>
  35. X * All rights reserved.
  36. X *
  37. X * Redistribution and use in source and binary forms, with or without
  38. X * modification, are permitted provided that the following conditions
  39. X * are met:
  40. X * 1. Redistributions of source code must retain the above copyright
  41. X *    notice, this list of conditions and the following disclaimer.
  42. X * 2. Redistributions in binary form must reproduce the above copyright
  43. X *    notice, this list of conditions and the following disclaimer in the
  44. X *    documentation and/or other materials provided with the distribution.
  45. X * 3. All advertising materials mentioning features or use of this software
  46. X *    must display the following acknowledgement:
  47. X *      This product includes software developed by Paul Kranenburg,
  48. X *      Branko Lankester and Rick Sladkey.
  49. X * 4. The name of the author may not be used to endorse or promote products
  50. X *    derived from this software without specific prior written permission.
  51. X *
  52. X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  53. X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  54. X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  55. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  56. X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  57. X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  58. X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  59. X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  60. X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  61. X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  62. X *
  63. X *    strace.c,v 2.28 1994/06/29 04:43:25 jrs Exp
  64. X */
  65. X
  66. X#include "defs.h"
  67. X
  68. X#include <signal.h>
  69. X#include <errno.h>
  70. X#include <sys/param.h>
  71. X#include <fcntl.h>
  72. X#include <sys/resource.h>
  73. X#include <sys/wait.h>
  74. X#include <sys/stat.h>
  75. X#ifdef SVR4
  76. X#include <sys/stropts.h>
  77. X#include <poll.h>
  78. X#endif
  79. X
  80. Xint debug = 0, followfork = 0, followvfork = 0, interactive = 0;
  81. Xint rflag = 0, tflag = 0, dtime = 0, cflag = 0;
  82. Xint iflag = 0, xflag = 0, qflag = 0;
  83. Xint pflag_seen = 0;
  84. Xint acolumn = DEFAULT_ACOLUMN;
  85. Xint max_strlen = DEFAULT_STRLEN;
  86. Xchar *outfname;
  87. XFILE *outf;
  88. Xstruct tcb tcbtab[MAX_PROCS];
  89. Xint nprocs;
  90. Xchar *progname;
  91. Xextern char version[];
  92. X
  93. Xstatic struct tcb *pid2tcb P((int pid));
  94. Xstatic int trace P((void));
  95. Xstatic void cleanup P((void));
  96. Xstatic void interrupt P((int sig));
  97. Xstatic sigset_t empty_set, blocked_set;
  98. X
  99. X#ifdef HAVE_SIG_ATOMIC_T
  100. Xstatic volatile sig_atomic_t interrupted;
  101. X#else /* !HAVE_SIG_ATOMIC_T */
  102. X#ifdef __STDC__
  103. Xstatic volatile int interrupted;
  104. X#else /* !__STDC__ */
  105. Xstatic int interrupted;
  106. X#endif /* !__STDC__ */
  107. X#endif /* !HAVE_SIG_ATOMIC_T */
  108. X
  109. X#ifdef SVR4
  110. X
  111. Xstatic struct tcb *pfd2tcb P((int pfd));
  112. Xstatic void reaper P((int sig));
  113. Xstatic void rebuild_pollv P((void));
  114. Xstruct pollfd pollv[MAX_PROCS];
  115. X
  116. X#ifndef HAVE_POLLABLE_PROCFS
  117. X
  118. Xstatic void proc_poll_open P((void));
  119. Xstatic void proc_poller P((int pfd));
  120. X
  121. Xstruct proc_pollfd {
  122. X    int fd;
  123. X    int revents;
  124. X    int pid;
  125. X};
  126. X
  127. Xstatic int poller_pid;
  128. Xstatic int proc_poll_pipe[2] = { -1, -1 };
  129. X
  130. X#endif /* !HAVE_POLLABLE_PROCFS */
  131. X
  132. X#endif /* SVR4 */
  133. X
  134. Xstatic void
  135. Xusage(ofp, exitval)
  136. XFILE *ofp;
  137. Xint exitval;
  138. X{
  139. X    fprintf(ofp, "\
  140. Xusage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]\n\
  141. X              [-p pid] ... [-s strsize] [command [arg ...]]\n\
  142. X   or: strace -c [-e expr] ... [-O overhead] [-S sortby] [command [arg ...]]\n\
  143. X-c -- count time, calls, and errors for each syscall and report summary\n\
  144. X-f -- follow forks, -ff -- with output into separate files\n\
  145. X-F -- attempt to follow vforks, -h -- print help message\n\
  146. X-i -- print instruction pointer at time of syscall\n\
  147. X-q -- suppress messages about attaching, detaching, etc.\n\
  148. X-r -- print relative timestamp, -t -- absolute timestamp, -tt -- with usecs\n\
  149. X-T -- print time spent in each syscall, -V -- print version\n\
  150. X-v -- verbose mode: print unabbreviated argv, stat, termio[s], etc. args\n\
  151. X-x -- print non-ascii strings in hex, -xx -- print all strings in hex\n\
  152. X-a column -- alignment COLUMN for printing syscall results (default %d)\n\
  153. X-e expr -- a qualifying expression: option=[!]all or option=[!]val1[,val2]...\n\
  154. X   options: trace, abbrev, verbose, raw, signal, read, or write\n\
  155. X-o file -- send trace output to FILE instead of stderr\n\
  156. X-O overhead -- set overhead for tracing syscalls to OVERHEAD usecs\n\
  157. X-p pid -- trace process with process id PID, may be repeated\n\
  158. X-s strsize -- limit length of print strings to STRSIZE chars (default %d)\n\
  159. X-S sortby -- sort syscall counts by: time, calls, name, nothing (default %s)\n\
  160. X", DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);
  161. X    exit(exitval);
  162. X}
  163. X
  164. Xint
  165. Xmain(argc, argv)
  166. Xint argc;
  167. Xchar *argv[];
  168. X{
  169. X    extern int optind;
  170. X    extern char *optarg;
  171. X    struct tcb *tcp;
  172. X    int c, pid = 0;
  173. X    struct sigaction sa;
  174. X
  175. X    static char buf[BUFSIZ];
  176. X
  177. X    progname = argv[0];
  178. X    outf = stderr;
  179. X    interactive = 1;
  180. X    qualify("trace=all");
  181. X    qualify("abbrev=all");
  182. X    qualify("verbose=all");
  183. X    qualify("signal=all");
  184. X    set_sortby(DEFAULT_SORTBY);
  185. X    while ((c = getopt(argc, argv,
  186. X        "+cdfFhiqrtTvVxa:e:o:O:p:s:S:")) != EOF) {
  187. X        switch (c) {
  188. X        case 'c':
  189. X            cflag++;
  190. X            dtime++;
  191. X            break;
  192. X        case 'd':
  193. X            debug++;
  194. X            break;
  195. X        case 'f':
  196. X            followfork++;
  197. X            break;
  198. X        case 'F':
  199. X            followvfork++;
  200. X            break;
  201. X        case 'h':
  202. X            usage(stdout, 0);
  203. X            break;
  204. X        case 'i':
  205. X            iflag++;
  206. X            break;
  207. X        case 'q':
  208. X            qflag++;
  209. X            break;
  210. X        case 'r':
  211. X            rflag++;
  212. X            tflag++;
  213. X            break;
  214. X        case 't':
  215. X            tflag++;
  216. X            break;
  217. X        case 'T':
  218. X            dtime++;
  219. X            break;
  220. X        case 'x':
  221. X            xflag++;
  222. X            break;
  223. X        case 'v':
  224. X            qualify("abbrev=none");
  225. X            break;
  226. X        case 'V':
  227. X            printf("%s\n", version);
  228. X            exit(0);
  229. X            break;
  230. X        case 'a':
  231. X            acolumn = atoi(optarg);
  232. X            break;
  233. X        case 'e':
  234. X            qualify(optarg);
  235. X            break;
  236. X        case 'o':
  237. X            outfname = strdup(optarg);
  238. X            if ((outf = fopen(outfname, "w")) == NULL) {
  239. X                perror("strace: fopen");
  240. X                exit(1);
  241. X            }
  242. X            break;
  243. X        case 'O':
  244. X            set_overhead(atoi(optarg));
  245. X            break;
  246. X        case 'p':
  247. X            if ((pid = atoi(optarg)) == 0) {
  248. X                fprintf(stderr, "%s: Invalid process id: %s\n",
  249. X                    progname, optarg);
  250. X                break;
  251. X            }
  252. X            if ((tcp = alloctcb(pid)) == NULL) {
  253. X                fprintf(stderr, "%s: tcb table full\n",
  254. X                    progname);
  255. X                exit(1);
  256. X            }
  257. X            tcp->flags |= TCB_ATTACHED;
  258. X            pflag_seen++;
  259. X            break;
  260. X        case 's':
  261. X            max_strlen = atoi(optarg);
  262. X            break;
  263. X        case 'S':
  264. X            set_sortby(optarg);
  265. X            break;
  266. X        default:
  267. X            usage(stderr, 1);
  268. X            break;
  269. X        }
  270. X    }
  271. X
  272. X    if (outf == stderr) {
  273. X        qflag = 1;
  274. X        setvbuf(outf, buf, _IOLBF, BUFSIZ);
  275. X    }
  276. X    else if (optind < argc)
  277. X        interactive = 0;
  278. X    else
  279. X        qflag = 1;
  280. X
  281. X    for (c = 0, tcp = tcbtab; c < MAX_PROCS; c++, tcp++) {
  282. X        if (!(tcp->flags & TCB_INUSE) || !(tcp->flags & TCB_ATTACHED))
  283. X            continue;
  284. X#ifdef SVR4
  285. X        if (proc_open(tcp, 1) < 0) {
  286. X            fprintf(stderr, "trouble opening proc file\n");
  287. X            droptcb(tcp);
  288. X            continue;
  289. X        }
  290. X#else /* !SVR4 */
  291. X        if (ptrace(PTRACE_ATTACH, tcp->pid, (char *) 1, 0) < 0) {
  292. X            perror("attach: ptrace(PTRACE_ATTACH, ...)");
  293. X            droptcb(tcp);
  294. X            continue;
  295. X        }
  296. X#endif /* !SVR4 */
  297. X        if (!qflag)
  298. X            fprintf(stderr,
  299. X                "Process %u attached - interrupt to quit\n",
  300. X                pid);
  301. X    }
  302. X
  303. X    if (optind < argc) {
  304. X        struct stat statbuf;
  305. X        char *filename;
  306. X        char pathname[MAXPATHLEN];
  307. X
  308. X        filename = argv[optind];
  309. X        if (strchr(filename, '/'))
  310. X            strcpy(pathname, filename);
  311. X#ifdef USE_DEBUGGING_EXEC
  312. X        /*
  313. X         * Debuggers customarily check the current directory
  314. X         * first regardless of the path but doing that gives
  315. X         * security geeks a panic attack.
  316. X         */
  317. X        else if (stat(filename, &statbuf) == 0)
  318. X            strcpy(pathname, filename);
  319. X#endif /* USE_DEBUGGING_EXEC */
  320. X        else {
  321. X            char *path;
  322. X            int m, n, len;
  323. X
  324. X            for (path = getenv("PATH"); path && *path; path += m) {
  325. X                if (strchr(path, ':')) {
  326. X                    n = strchr(path, ':') - path;
  327. X                    m = n + 1;
  328. X                }
  329. X                else
  330. X                    m = n = strlen(path);
  331. X                if (n == 0) {
  332. X                    getcwd(pathname, MAXPATHLEN);
  333. X                    len = strlen(pathname);
  334. X                }
  335. X                else {
  336. X                    strncpy(pathname, path, n);
  337. X                    len = n;
  338. X                }
  339. X                if (len && pathname[len - 1] != '/')
  340. X                    pathname[len++] = '/';
  341. X                strcpy(pathname + len, filename);
  342. X                if (stat(pathname, &statbuf) == 0)
  343. X                    break;
  344. X            }
  345. X        }
  346. X        if (stat(pathname, &statbuf) < 0) {
  347. X            fprintf(stderr, "%s: %s: command not found\n",
  348. X                progname, filename);
  349. X            exit(1);
  350. X        }
  351. X        switch (pid = fork()) {
  352. X        case -1:
  353. X            perror("strace: fork");
  354. X            cleanup();
  355. X            exit(1);
  356. X            break;
  357. X        case 0: {
  358. X#ifdef SVR4
  359. X            pause();
  360. X#else /* !SVR4 */
  361. X            if (ptrace(PTRACE_TRACEME, 0, (char *) 1, 0) < 0) {
  362. X                perror("strace: ptrace(PTRACE_TRACEME, ...)");
  363. X                return -1;
  364. X            }
  365. X            if (debug)
  366. X                kill(getpid(), SIGSTOP);
  367. X#endif /* !SVR4 */
  368. X            execv(pathname, &argv[optind]);
  369. X            perror("strace: exec");
  370. X            _exit(1);
  371. X            break;
  372. X        }
  373. X        default:
  374. X            if ((tcp = alloctcb(pid)) == NULL) {
  375. X                fprintf(stderr, "tcb table full\n");
  376. X                cleanup();
  377. X                exit(1);
  378. X            }
  379. X#ifdef SVR4
  380. X            if (proc_open(tcp, 0) < 0) {
  381. X                fprintf(stderr, "trouble opening proc file\n");
  382. X                cleanup();
  383. X                exit(1);
  384. X            }
  385. X#endif /* SVR4 */
  386. X            break;
  387. X        }
  388. X    }
  389. X    else if (pflag_seen == 0)
  390. X        usage(stderr, 1);
  391. X
  392. X    sigemptyset(&empty_set);
  393. X    sigemptyset(&blocked_set);
  394. X    sa.sa_handler = SIG_IGN;
  395. X    sigemptyset(&sa.sa_mask);
  396. X    sa.sa_flags = 0;
  397. X    sigaction(SIGTTOU, &sa, NULL);
  398. X    sigaction(SIGTTIN, &sa, NULL);
  399. X    if (interactive) {
  400. X        sigaddset(&blocked_set, SIGHUP);
  401. X        sigaddset(&blocked_set, SIGINT);
  402. X        sigaddset(&blocked_set, SIGQUIT);
  403. X        sigaddset(&blocked_set, SIGTERM);
  404. X        sa.sa_handler = interrupt;
  405. X#ifdef SUNOS4
  406. X        /* POSIX signals on sunos4.1 are a little broken. */
  407. X        sa.sa_flags = SA_INTERRUPT;
  408. X#endif /* SUNOS4 */
  409. X    }
  410. X    sigaction(SIGHUP, &sa, NULL);
  411. X    sigaction(SIGINT, &sa, NULL);
  412. X    sigaction(SIGQUIT, &sa, NULL);
  413. X    sigaction(SIGTERM, &sa, NULL);
  414. X#ifdef SVR4
  415. X    sa.sa_handler = reaper;
  416. X    sigaction(SIGCHLD, &sa, NULL);
  417. X#endif /* SVR4 */
  418. X
  419. X    if (trace() < 0)
  420. X        exit(1);
  421. X    cleanup();
  422. X    exit(0);
  423. X}
  424. X
  425. Xvoid
  426. Xnewoutf(tcp)
  427. Xstruct tcb *tcp;
  428. X{
  429. X    char name[MAXPATHLEN];
  430. X    FILE *fp;
  431. X
  432. X    if (outfname && followfork > 1) {
  433. X        sprintf(name, "%s.%u", outfname, tcp->pid);
  434. X        if ((fp = fopen(name, "w")) == NULL) {
  435. X            perror("fopen");
  436. X            return;
  437. X        }
  438. X        tcp->outf = fp;
  439. X    }
  440. X    return;
  441. X}
  442. X
  443. Xstruct tcb *
  444. Xalloctcb(pid)
  445. Xint pid;
  446. X{
  447. X    int i;
  448. X    struct tcb *tcp;
  449. X
  450. X    for (i = 0, tcp = tcbtab; i < MAX_PROCS; i++, tcp++) {
  451. X        if ((tcp->flags & TCB_INUSE) == 0) {
  452. X            tcp->pid = pid;
  453. X            tcp->parent = NULL;
  454. X            tcp->nchildren = 0;
  455. X            tcp->flags = TCB_INUSE | TCB_STARTUP;
  456. X            tcp->outf = outf; /* Initialise to current out file */
  457. X            tcp->stime.tv_sec = 0;
  458. X            tcp->stime.tv_usec = 0;
  459. X            tcp->pfd = -1;
  460. X            nprocs++;
  461. X            return tcp;
  462. X        }
  463. X    }
  464. X    return NULL;
  465. X}
  466. X
  467. X#ifdef SVR4
  468. X
  469. Xint
  470. Xproc_open(tcp, attaching)
  471. Xstruct tcb *tcp;
  472. Xint attaching;
  473. X{
  474. X    char proc[32];
  475. X    long arg;
  476. X    sysset_t sc_enter, sc_exit;
  477. X    sigset_t signals;
  478. X    fltset_t faults;
  479. X    prrun_t run;
  480. X#ifndef HAVE_POLLABLE_PROCFS
  481. X    static int last_pfd;
  482. X#endif /* !HAVE_POLLABLE_PROCFS */
  483. X
  484. X    /* Open the process pseudo-file in /proc. */
  485. X    sprintf(proc, "/proc/%d", tcp->pid);
  486. X    if ((tcp->pfd = open(proc, O_RDWR|O_EXCL)) < 0) {
  487. X        perror("strace: open(\"/proc/...\", ...)");
  488. X        return -1;
  489. X    }
  490. X    rebuild_pollv();
  491. X    if (!attaching) {
  492. X        /*
  493. X         * Wait for the child to pause.  Because of a race
  494. X         * condition we have to poll for the event.
  495. X         */
  496. X        for (;;) {
  497. X            if (ioctl(tcp->pfd, PIOCSTATUS, &tcp->status) < 0) {
  498. X                perror("strace: PIOCSTATUS");
  499. X                return -1;
  500. X            }
  501. X            if (tcp->status.pr_flags & PR_ASLEEP)
  502. X                break;
  503. X        }
  504. X    }
  505. X    /* Stop the process so that we own the stop. */
  506. X    if (ioctl(tcp->pfd, PIOCSTOP, &tcp->status) < 0) {
  507. X        perror("strace: PIOCSTOP");
  508. X        return -1;
  509. X    }
  510. X    if ((arg = fcntl(tcp->pfd, F_GETFD)) < 0) {
  511. X        perror("F_GETFD");
  512. X        return -1;
  513. X    }
  514. X    if (fcntl(tcp->pfd, F_SETFD, arg|FD_CLOEXEC) < 0) {
  515. X        perror("F_SETFD");
  516. X        return -1;
  517. X    }
  518. X#ifdef PIOCSET
  519. X    /* Set Run-on-Last-Close. */
  520. X    arg = PR_RLC;
  521. X    if (ioctl(tcp->pfd, PIOCSET, &arg) < 0) {
  522. X        perror("PIOCSET PR_RLC");
  523. X        return -1;
  524. X    }
  525. X    /* Set or Reset Inherit-on-Fork. */
  526. X    arg = PR_FORK;
  527. X    if (ioctl(tcp->pfd, followfork ? PIOCSET : PIOCRESET, &arg) < 0) {
  528. X        perror("PIOC{SET,RESET} PR_FORK");
  529. X        return -1;
  530. X    }
  531. X#else  /* !PIOCSET */
  532. X    if (ioctl(tcp->pfd, PIOCSRLC) < 0) {
  533. X        perror("PIOCSRLC");
  534. X        return -1;
  535. X    }
  536. X    if (ioctl(tcp->pfd, followfork ? PIOCSFORK : PIOCRFORK) < 0) {
  537. X        perror("PIOC{S,R}FORK");
  538. X        return -1;
  539. X    }
  540. X#endif /* !PIOCSET */
  541. X    /* Enable all syscall enties. */
  542. X    prfillset(&sc_enter);
  543. X    if (ioctl(tcp->pfd, PIOCSENTRY, &sc_enter) < 0) {
  544. X        perror("PIOCSENTRY");
  545. X        return -1;
  546. X    }
  547. X    /* Enable all syscall exits. */
  548. X    prfillset(&sc_exit);
  549. X    if (ioctl(tcp->pfd, PIOCSEXIT, &sc_exit) < 0) {
  550. X        perror("PIOSEXIT");
  551. X        return -1;
  552. X    }
  553. X    /* Enable all signals. */
  554. X    prfillset(&signals);
  555. X    if (ioctl(tcp->pfd, PIOCSTRACE, &signals) < 0) {
  556. X        perror("PIOCSTRACE");
  557. X        return -1;
  558. X    }
  559. X    /* Enable all faults. */
  560. X    prfillset(&faults);
  561. X    if (ioctl(tcp->pfd, PIOCSFAULT, &faults) < 0) {
  562. X        perror("PIOCSFAULT");
  563. X        return -1;
  564. X    }
  565. X    if (!attaching) {
  566. X        /* The child is in a pause(), abort it. */
  567. X        run.pr_flags = PRSABORT;
  568. X        if (ioctl(tcp->pfd, PIOCRUN, &run) < 0) {
  569. X            perror("PIOCRUN");
  570. X            return -1;
  571. X        }
  572. X        /* Wait for the child to come out of the system call. */
  573. X        if (ioctl(tcp->pfd, PIOCWSTOP, &tcp->status) < 0) {
  574. X            perror("PIOCWSTOP");
  575. X            return -1;
  576. X        }
  577. X        /* Then set it running: execve should be next. */
  578. X        if (ioctl(tcp->pfd, PIOCRUN, NULL) < 0) {
  579. X            perror("PIOCRUN");
  580. X            return -1;
  581. X        }
  582. X    }
  583. X#ifndef HAVE_POLLABLE_PROCFS
  584. X    if (proc_poll_pipe[0] != -1)
  585. X        proc_poller(tcp->pfd);
  586. X    else if (nprocs > 1) {
  587. X        proc_poll_open();
  588. X        proc_poller(last_pfd);
  589. X        proc_poller(tcp->pfd);
  590. X    }
  591. X    last_pfd = tcp->pfd;
  592. X#endif /* !HAVE_POLLABLE_PROCFS */
  593. X    return 0;
  594. X}
  595. X
  596. X#endif /* SVR4 */
  597. X
  598. Xstatic struct tcb *
  599. Xpid2tcb(pid)
  600. Xint pid;
  601. X{
  602. X    int i;
  603. X    struct tcb *tcp;
  604. X
  605. X    for (i = 0, tcp = tcbtab; i < MAX_PROCS; i++, tcp++) {
  606. X        if (pid && tcp->pid != pid)
  607. X            continue;
  608. X        if (tcp->flags & TCB_INUSE)
  609. X            return tcp;
  610. X    }
  611. X    return NULL;
  612. X}
  613. X
  614. X#ifdef SVR4
  615. X
  616. Xstatic struct tcb *
  617. Xpfd2tcb(pfd)
  618. Xint pfd;
  619. X{
  620. X    int i;
  621. X    struct tcb *tcp;
  622. X
  623. X    for (i = 0, tcp = tcbtab; i < MAX_PROCS; i++, tcp++) {
  624. X        if (tcp->pfd != pfd)
  625. X            continue;
  626. X        if (tcp->flags & TCB_INUSE)
  627. X            return tcp;
  628. X    }
  629. X    return NULL;
  630. X}
  631. X
  632. X#endif /* SVR4 */
  633. X
  634. Xvoid
  635. Xdroptcb(tcp)
  636. Xstruct tcb *tcp;
  637. X{
  638. X    if (tcp->pid == 0)
  639. X        return;
  640. X    nprocs--;
  641. X    tcp->pid = 0;
  642. X    tcp->flags = 0;
  643. X    if (tcp->pfd != -1) {
  644. X        close(tcp->pfd);
  645. X        tcp->pfd = -1;
  646. X#ifdef SVR4
  647. X        rebuild_pollv();
  648. X#endif /* SVR4 */
  649. X    }
  650. X    if (tcp->parent != NULL) {
  651. X        tcp->parent->nchildren--;
  652. X        tcp->parent = NULL;
  653. X    }
  654. X#if 0
  655. X    if (tcp->outf != stderr)
  656. X        fclose(tcp->outf);
  657. X#endif
  658. X    tcp->outf = stderr;
  659. X}
  660. X
  661. X#ifndef SVR4
  662. X
  663. Xstatic int
  664. Xresume(tcp)
  665. Xstruct tcb *tcp;
  666. X{
  667. X    if (tcp == NULL)
  668. X        return -1;
  669. X
  670. X    if (!(tcp->flags & TCB_SUSPENDED)) {
  671. X        fprintf(stderr, "PANIC: pid %u not suspended\n", tcp->pid);
  672. X        return -1;
  673. X    }
  674. X    tcp->flags &= ~TCB_SUSPENDED;
  675. X
  676. X    if (ptrace(PTRACE_SYSCALL, tcp->pid, (char *) 1, 0) < 0) {
  677. X        perror("resume: ptrace(PTRACE_SYSCALL, ...)");
  678. X        return -1;
  679. X    }
  680. X
  681. X    if (!qflag)
  682. X        fprintf(stderr, "Process %u resumed\n", tcp->pid);
  683. X    return 0;
  684. X}
  685. X
  686. X#endif /* !SVR4 */
  687. X
  688. Xstatic int
  689. Xdetach(tcp, sig)
  690. Xstruct tcb *tcp;
  691. Xint sig;
  692. X{
  693. X    /* detach traced process; continue with sig */
  694. X    int error;
  695. X    int status;
  696. X
  697. X    if (tcp->flags & TCB_BPTSET)
  698. X        sig = SIGKILL;
  699. X
  700. X#ifdef LINUX
  701. X    /*
  702. X     * Linux wrongly insists the child be stopped
  703. X     * before detaching.  Arghh.  We go through hoops
  704. X     * to make a clean break of things.
  705. X     */
  706. X    if ((error = ptrace(PTRACE_DETACH, tcp->pid, (char *) 1, sig)) == 0) {
  707. X        /* On a clear day, you can see forever. */
  708. X    }
  709. X    else if (errno != ESRCH) {
  710. X        /* Shouldn't happen. */
  711. X        perror("detach: ptrace(PTRACE_DETACH, ...)");
  712. X    }
  713. X    else if (kill(tcp->pid, 0) < 0) {
  714. X        if (errno != ESRCH)
  715. X            perror("detach: checking sanity");
  716. X    }
  717. X    else if (kill(tcp->pid, SIGSTOP) < 0) {
  718. X        if (errno != ESRCH)
  719. X            perror("detach: stopping child");
  720. X    }
  721. X    else {
  722. X        for (;;) {
  723. X            if (waitpid(tcp->pid, &status, 0) < 0) {
  724. X                if (errno != ECHILD)
  725. X                    perror("detach: waiting");
  726. X                break;
  727. X            }
  728. X            if (!WIFSTOPPED(status)) {
  729. X                /* Au revoir, mon ami. */    
  730. X                break;
  731. X            }
  732. X            if (WSTOPSIG(status) == SIGSTOP) {
  733. X                if ((error = ptrace(PTRACE_DETACH,
  734. X                    tcp->pid, (char *) 1, sig)) < 0) {
  735. X                    if (errno != ESRCH)
  736. X                        perror("detach: ptrace(PTRACE_DETACH, ...)");
  737. X                    /* I died trying. */
  738. X                }
  739. X                break;
  740. X            }
  741. X            if ((error = ptrace(PTRACE_CONT, tcp->pid, (char *) 1,
  742. X                WSTOPSIG(status) == SIGTRAP ?
  743. X                0 : WSTOPSIG(status))) < 0) {
  744. X                if (errno != ESRCH)
  745. X                    perror("detach: ptrace(PTRACE_CONT, ...)");
  746. X                break;
  747. X            }
  748. X        }
  749. X    }
  750. X#endif /* LINUX */
  751. X
  752. X#ifdef SUNOS4
  753. X    /* PTRACE_DETACH won't respect `sig' argument, so we post it here. */
  754. X    if (sig && kill(tcp->pid, sig) < 0)
  755. X        perror("detach: kill");
  756. X    sig = 0;
  757. X    if ((error = ptrace(PTRACE_DETACH, tcp->pid, (char *) 1, sig)) < 0)
  758. X        perror("detach: ptrace(PTRACE_DETACH, ...)");
  759. X#endif /* SUNOS4 */
  760. X
  761. X#ifndef SVR4
  762. X    if (waiting_parent(tcp))
  763. X        error = resume(tcp->parent);
  764. X#endif /* !SVR4 */
  765. X
  766. X    if (!qflag)
  767. X        fprintf(stderr, "Process %u detached\n", tcp->pid);
  768. X
  769. X    droptcb(tcp);
  770. X    return error;
  771. X}
  772. X
  773. X#ifdef SVR4
  774. X
  775. Xstatic void
  776. Xreaper(sig)
  777. Xint sig;
  778. X{
  779. X    int pid;
  780. X    int status;
  781. X
  782. X    while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
  783. X#if 0
  784. X    struct tcb *tcp;
  785. X
  786. X        tcp = pid2tcb(pid);
  787. X        if (tcp)
  788. X            droptcb(tcp);
  789. X#endif
  790. X    }
  791. X}
  792. X
  793. X#endif /* SVR4 */
  794. X
  795. Xstatic void
  796. Xcleanup()
  797. X{
  798. X    int i;
  799. X    struct tcb *tcp;
  800. X
  801. X    for (i = 0, tcp = tcbtab; i < MAX_PROCS; i++, tcp++) {
  802. X        if (!(tcp->flags & TCB_INUSE))
  803. X            continue;
  804. X        if (debug)
  805. X            fprintf(stderr,
  806. X                "cleanup: looking at pid %u\n", tcp->pid);
  807. X        if (tcp_last &&
  808. X            (!outfname || followfork < 2 || tcp_last == tcp)) {
  809. X            tprintf(" <unfinished ...>\n");
  810. X            tcp_last = NULL;
  811. X        }
  812. X        if (tcp->flags & TCB_ATTACHED)
  813. X            detach(tcp, 0);
  814. X        else
  815. X            kill(tcp->pid, SIGTERM);
  816. X    }
  817. X    if (cflag)
  818. X        call_summary(outf);
  819. X}
  820. X
  821. Xstatic void
  822. Xinterrupt(sig)
  823. Xint sig;
  824. X{
  825. X    interrupted = 1;
  826. X}
  827. X
  828. X#ifndef HAVE_STRSIGNAL
  829. X
  830. Xchar *
  831. Xstrsignal(sig)
  832. Xint sig;
  833. X{
  834. X    static char buf[64];
  835. X#ifdef HAVE__SYS_SIGLIST
  836. X    extern char *_sys_siglist[];
  837. X#else
  838. X    extern char *sys_siglist[];
  839. X#endif
  840. X
  841. X    if (sig < 1 || sig >= NSIG) {
  842. X        sprintf(buf, "Unknown signal %d", sig);
  843. X        return buf;
  844. X    }
  845. X#ifdef HAVE__SYS_SIGLIST
  846. X    return _sys_siglist[sig];
  847. X#else
  848. X    return sys_siglist[sig];
  849. X#endif
  850. X}
  851. X
  852. X#endif /* HAVE_STRSIGNAL */
  853. X
  854. X#ifdef SVR4
  855. X
  856. Xstatic void
  857. Xrebuild_pollv()
  858. X{
  859. X    int i, j;
  860. X    struct tcb *tcp;
  861. X
  862. X    for (i = j = 0, tcp = tcbtab; i < MAX_PROCS; i++, tcp++) {
  863. X        if (!(tcp->flags & TCB_INUSE))
  864. X            continue;
  865. X        pollv[j].fd = tcp->pfd;
  866. X        pollv[j].events = POLLPRI;
  867. X        j++;
  868. X    }
  869. X    if (j != nprocs) {
  870. X        fprintf(stderr, "strace: proc miscount\n");
  871. X        exit(1);
  872. X    }
  873. X}
  874. X
  875. X#ifndef HAVE_POLLABLE_PROCFS
  876. X
  877. Xstatic void
  878. Xproc_poll_open()
  879. X{
  880. X    int arg;
  881. X    int i;
  882. X
  883. X    if (pipe(proc_poll_pipe) < 0) {
  884. X        perror("pipe");
  885. X        exit(1);
  886. X    }
  887. X    for (i = 0; i < 2; i++) {
  888. X        if ((arg = fcntl(proc_poll_pipe[i], F_GETFD)) < 0) {
  889. X            perror("F_GETFD");
  890. X            exit(1);
  891. X        }
  892. X        if (fcntl(proc_poll_pipe[i], F_SETFD, arg|FD_CLOEXEC) < 0) {
  893. X            perror("F_SETFD");
  894. X            exit(1);
  895. X        }
  896. X    }
  897. X}
  898. X
  899. Xstatic int
  900. Xproc_poll(pollv, nfds, timeout)
  901. Xstruct pollfd *pollv;
  902. Xint nfds;
  903. Xint timeout;
  904. X{
  905. X    int i;
  906. X    int n;
  907. X    struct proc_pollfd pollinfo;
  908. X
  909. X    if ((n = read(proc_poll_pipe[0], &pollinfo, sizeof(pollinfo))) < 0)
  910. X        return n;
  911. X    if (n != sizeof(struct proc_pollfd)) {
  912. X        fprintf(stderr, "panic: short read: %d\n", n);
  913. X        exit(1);
  914. X    }
  915. X    for (i = 0; i < nprocs; i++) {
  916. X        if (pollv[i].fd == pollinfo.fd)
  917. X            pollv[i].revents = pollinfo.revents;
  918. X        else
  919. X            pollv[i].revents = 0;
  920. X    }
  921. X    poller_pid = pollinfo.pid;
  922. X    return 1;
  923. X}
  924. X
  925. Xstatic void
  926. Xwakeup_handler(sig)
  927. Xint sig;
  928. X{
  929. X}
  930. X
  931. Xstatic void
  932. Xproc_poller(pfd)
  933. Xint pfd;
  934. X{
  935. X    struct proc_pollfd pollinfo;
  936. X    struct sigaction sa;
  937. X    sigset_t blocked_set, empty_set;
  938. X    int i;
  939. X    int n;
  940. X    struct rlimit rl;
  941. X
  942. X    switch (fork()) {
  943. X    case -1:
  944. X        perror("fork");
  945. X        _exit(0);
  946. X    case 0:
  947. X        break;
  948. X    default:
  949. X        return;
  950. X    }
  951. X
  952. X    sa.sa_handler = interactive ? SIG_DFL : SIG_IGN;
  953. X    sa.sa_flags = 0;
  954. X    sigemptyset(&sa.sa_mask);
  955. X    sigaction(SIGHUP, &sa, NULL);
  956. X    sigaction(SIGINT, &sa, NULL);
  957. X    sigaction(SIGQUIT, &sa, NULL);
  958. X    sigaction(SIGTERM, &sa, NULL);
  959. X    sa.sa_handler = wakeup_handler;
  960. X    sigaction(SIGUSR1, &sa, NULL);
  961. X    sigemptyset(&blocked_set);
  962. X    sigaddset(&blocked_set, SIGUSR1);
  963. X    sigprocmask(SIG_BLOCK, &blocked_set, NULL);
  964. X    sigemptyset(&empty_set);
  965. X
  966. X    if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
  967. X        perror("getrlimit(RLIMIT_NOFILE, ...)");
  968. X        _exit(0);
  969. X    }
  970. X    n = rl.rlim_cur;
  971. X    for (i = 0; i < n; i++) {
  972. X        if (i != pfd && i != proc_poll_pipe[1])
  973. X            close(i);
  974. X    }
  975. X            
  976. X    pollinfo.fd = pfd;
  977. X    pollinfo.pid = getpid();
  978. X    for (;;) {
  979. X        if (ioctl(pfd, PIOCWSTOP, NULL) < 0) {
  980. X            switch (errno) {
  981. X            case EINTR:
  982. X                continue;
  983. X            case EBADF:
  984. X                pollinfo.revents = POLLERR;
  985. X                break;
  986. X            case ENOENT:
  987. X                pollinfo.revents = POLLHUP;
  988. X                break;
  989. X            default:
  990. X                perror("proc_poller: PIOCWSTOP");
  991. X            }
  992. X            write(proc_poll_pipe[1], &pollinfo, sizeof(pollinfo));
  993. X            _exit(0);
  994. X        }
  995. X        pollinfo.revents = POLLPRI;
  996. X        write(proc_poll_pipe[1], &pollinfo, sizeof(pollinfo));
  997. X        sigsuspend(&empty_set);
  998. X    }
  999. X}
  1000. X
  1001. X#endif /* !HAVE_POLLABLE_PROCFS */
  1002. X
  1003. Xstatic int
  1004. Xchoose_pfd()
  1005. X{
  1006. X    int i, j;
  1007. X    struct tcb *tcp;
  1008. X
  1009. X    static int last;
  1010. X
  1011. X    if (followfork < 2 &&
  1012. X        last < nprocs && (pollv[last].revents & POLLPRI)) {
  1013. X        /*
  1014. X         * The previous process is ready to run again.  We'll
  1015. X         * let it do so if it is currently in a syscall.  This
  1016. X         * heuristic improves the readability of the trace.
  1017. X         */
  1018. X        tcp = pfd2tcb(pollv[last].fd);
  1019. X        if (tcp && (tcp->flags & TCB_INSYSCALL))
  1020. X            return pollv[last].fd;
  1021. X    }
  1022. X
  1023. X    for (i = 0; i < nprocs; i++) {
  1024. X        /* Let competing children run round robin. */
  1025. X        j = (i + last + 1) % nprocs;
  1026. X        if (pollv[j].revents & (POLLHUP | POLLERR)) {
  1027. X            tcp = pfd2tcb(pollv[j].fd);
  1028. X            if (!tcp) {
  1029. X                fprintf(stderr, "strace: lost proc\n");
  1030. X                exit(1);
  1031. X            }
  1032. X            droptcb(tcp);
  1033. X            return -1;
  1034. X        }
  1035. X        if (pollv[j].revents & POLLPRI) {
  1036. X            last = j;
  1037. X            return pollv[j].fd;
  1038. X        }
  1039. X    }
  1040. X    fprintf(stderr, "strace: nothing ready\n");
  1041. X    exit(1);
  1042. X}
  1043. X
  1044. Xstatic int
  1045. Xtrace()
  1046. X{
  1047. X    struct tcb *tcp;
  1048. X    int pfd;
  1049. X    int what;
  1050. X    int ioctl_result, ioctl_errno;
  1051. X
  1052. X    for (;;) {
  1053. X        if (interactive)
  1054. X            sigprocmask(SIG_SETMASK, &empty_set, NULL);
  1055. X
  1056. X        switch (nprocs) {
  1057. X        case 0:
  1058. X            return 0;
  1059. X        case 1:
  1060. X#ifndef HAVE_POLLABLE_PROCFS
  1061. X            if (proc_poll_pipe[0] == -1) {
  1062. X#endif /* !HAVE_POLLABLE_PROCFS */
  1063. X                tcp = pid2tcb(0);
  1064. X                if (!tcp)
  1065. X                    continue;
  1066. X                pfd = tcp->pfd;
  1067. X                if (pfd == -1)
  1068. X                    continue;
  1069. X                break;
  1070. X#ifndef HAVE_POLLABLE_PROCFS
  1071. X            }
  1072. X            /* fall through ... */
  1073. X#endif /* !HAVE_POLLABLE_PROCFS */
  1074. X        default:
  1075. X#ifdef HAVE_POLLABLE_PROCFS
  1076. X            if (poll(pollv, nprocs, INFTIM) < 0) {
  1077. X                if (interrupted)
  1078. X                    return 0;
  1079. X                continue;
  1080. X            }
  1081. X#else /* !HAVE_POLLABLE_PROCFS */
  1082. X            if (proc_poll(pollv, nprocs, INFTIM) < 0) {
  1083. X                if (interrupted)
  1084. X                    return 0;
  1085. X                continue;
  1086. X            }
  1087. X#endif /* !HAVE_POLLABLE_PROCFS */
  1088. X            pfd = choose_pfd();
  1089. X            if (pfd == -1)
  1090. X                continue;
  1091. X            break;
  1092. X        }
  1093. X
  1094. X        /* Look up `pfd' in our table. */
  1095. X        if ((tcp = pfd2tcb(pfd)) == NULL) {
  1096. X            fprintf(stderr, "unknown pfd: %u\n", pfd);
  1097. X            exit(1);
  1098. X        }
  1099. X        /* Get the status of the process. */
  1100. X        if (!interrupted) {
  1101. X            ioctl_result = ioctl(tcp->pfd, PIOCWSTOP,
  1102. X                &tcp->status);
  1103. X            ioctl_errno = errno;
  1104. X#ifndef HAVE_POLLABLE_PROCFS
  1105. X            if (proc_poll_pipe[0] != -1) {
  1106. X                if (ioctl_result < 0)
  1107. X                    kill(poller_pid, SIGKILL);
  1108. X                else
  1109. X                    kill(poller_pid, SIGUSR1);
  1110. X            }
  1111. X#endif /* !HAVE_POLLABLE_PROCFS */
  1112. X        }
  1113. X        if (interrupted)
  1114. X            return 0;
  1115. X
  1116. X        if (interactive)
  1117. X            sigprocmask(SIG_BLOCK, &blocked_set, NULL);
  1118. X
  1119. X        if (ioctl_result < 0) {
  1120. X            /* Find out what happened if it failed. */
  1121. X            switch (ioctl_errno) {
  1122. X            case EINTR:
  1123. X            case EBADF:
  1124. X                continue;
  1125. X            case ENOENT:
  1126. X                droptcb(tcp);
  1127. X                continue;
  1128. X            default:
  1129. X                perror("PIOCWSTOP");
  1130. X                exit(1);
  1131. X            }
  1132. X        }
  1133. X
  1134. X        /* clear the just started flag */
  1135. X        tcp->flags &= ~TCB_STARTUP;
  1136. X
  1137. X        /* set current output file */
  1138. X        outf = tcp->outf;
  1139. X
  1140. X        if (cflag) {
  1141. X            struct timeval stime;
  1142. X
  1143. X            stime.tv_sec = tcp->status.pr_stime.tv_sec;
  1144. X            stime.tv_usec = tcp->status.pr_stime.tv_nsec/1000;
  1145. X            tv_sub(&tcp->dtime, &stime, &tcp->stime);
  1146. X            tcp->stime = stime;
  1147. X        }
  1148. X
  1149. X        what = tcp->status.pr_what;
  1150. X        switch (tcp->status.pr_why) {
  1151. X        case PR_REQUESTED:
  1152. X            if (tcp->status.pr_flags & PR_ASLEEP) {
  1153. X                tcp->status.pr_why = PR_SYSENTRY;
  1154. X                if (syscall(tcp) < 0) {
  1155. X                    fprintf(stderr, "syscall trouble\n");
  1156. X                    exit(1);
  1157. X                }
  1158. X            }
  1159. X            break;
  1160. X        case PR_SYSENTRY:
  1161. X        case PR_SYSEXIT:
  1162. X            if (syscall(tcp) < 0) {
  1163. X                fprintf(stderr, "syscall trouble\n");
  1164. X                exit(1);
  1165. X            }
  1166. X            break;
  1167. X        case PR_SIGNALLED:
  1168. X            if (!cflag && (qual_flags[what] & QUAL_SIGNAL)) {
  1169. X                printleader(tcp);
  1170. X                tprintf("--- %s (%s) ---",
  1171. X                    signalent[what], strsignal(what));
  1172. X                printtrailer(tcp);
  1173. X            }
  1174. X            break;
  1175. X        case PR_FAULTED:
  1176. X            if (!cflag && (qual_flags[what] & QUAL_FAULT)) {
  1177. X                printleader(tcp);
  1178. X                tprintf("=== FAULT %d ===", what);
  1179. X                printtrailer(tcp);
  1180. X            }
  1181. X            break;
  1182. X        default:
  1183. X            fprintf(stderr, "odd stop %d\n", tcp->status.pr_why);
  1184. X            exit(1);
  1185. X            break;
  1186. X        }
  1187. X        if (ioctl(tcp->pfd, PIOCRUN, NULL) < 0) {
  1188. X            perror("PIOCRUN");
  1189. X            exit(1);
  1190. X        }
  1191. X    }
  1192. X    return 0;
  1193. X}
  1194. X
  1195. X#else /* !SVR4 */
  1196. X
  1197. Xstatic int
  1198. Xtrace()
  1199. X{
  1200. X    int pid;
  1201. X    int wait_errno;
  1202. X    int status;
  1203. X    struct tcb *tcp;
  1204. X#ifdef LINUX
  1205. X    struct rusage ru;
  1206. X#endif /* LINUX */
  1207. X
  1208. X    for (;;) {
  1209. X        if (interactive)
  1210. X            sigprocmask(SIG_SETMASK, &empty_set, NULL);
  1211. X#ifdef LINUX
  1212. X        pid = wait4(-1, &status, 0, cflag ? &ru : NULL);
  1213. X#endif /* LINUX */
  1214. X#ifdef SUNOS4
  1215. X        pid = wait(&status);
  1216. X#endif /* SUNOS4 */
  1217. X        wait_errno = errno;
  1218. X        if (interactive)
  1219. X            sigprocmask(SIG_BLOCK, &blocked_set, NULL);
  1220. X
  1221. X        if (interrupted)
  1222. X            return 0;
  1223. X
  1224. X        if (pid == -1) {
  1225. X            switch (wait_errno) {
  1226. X            case EINTR:
  1227. X                continue;
  1228. X            case ECHILD:
  1229. X                /*
  1230. X                 * We would like to verify this case
  1231. X                 * but sometimes a race in Solbourne's
  1232. X                 * version of SunOS sometimes reports
  1233. X                 * ECHILD before sending us SIGCHILD.
  1234. X                 */
  1235. X#if 0
  1236. X                if (nprocs == 0)
  1237. X                    return 0;
  1238. X                fprintf(stderr, "strace: proc miscount\n");
  1239. X                exit(1);
  1240. X#endif
  1241. X                return 0;
  1242. X            default:
  1243. X                errno = wait_errno;
  1244. X                perror("strace: wait");
  1245. X                return -1;
  1246. X            }
  1247. X        }
  1248. X        if (debug)
  1249. X            fprintf(stderr, " [wait(%#x) = %u]\n", status, pid);
  1250. X
  1251. X        /* Look up `pid' in our table. */
  1252. X        if ((tcp = pid2tcb(pid)) == NULL) {
  1253. X            fprintf(stderr, "unknown pid: %u\n", pid);
  1254. X            if (WIFSTOPPED(status))
  1255. X                ptrace(PTRACE_CONT, pid, (char *) 1, 0);
  1256. X            exit(1);
  1257. X        }
  1258. X        /* set current output file */
  1259. X        outf = tcp->outf;
  1260. X        if (cflag) {
  1261. X#ifdef LINUX
  1262. X            tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime);
  1263. X            tcp->stime = ru.ru_stime;
  1264. X#endif /* !LINUX */
  1265. X        }
  1266. X
  1267. X        if (tcp->flags & TCB_SUSPENDED) {
  1268. X            /*
  1269. X             * Apparently, doing any ptrace() call on a stopped
  1270. X             * process, provokes the kernel to report the process
  1271. X             * status again on a subsequent wait(), even if the
  1272. X             * process has not been actually restarted.
  1273. X             * Since we have inspected the arguments of suspended
  1274. X             * processes we end up here testing for this case.
  1275. X             */
  1276. X            continue;
  1277. X        }
  1278. X        if (WIFSIGNALED(status)) {
  1279. X            if (!cflag
  1280. X                && (qual_flags[WTERMSIG(status)] & QUAL_SIGNAL)) {
  1281. X                printleader(tcp);
  1282. X                tprintf("+++ killed by %s +++",
  1283. X                    signalent[WTERMSIG(status)]);
  1284. X                printtrailer(tcp);
  1285. X            }
  1286. X            droptcb(tcp);
  1287. X            continue;
  1288. X        }
  1289. X        if (WIFEXITED(status)) {
  1290. X            if (debug)
  1291. X                fprintf(stderr, "pid %u exited\n", pid);
  1292. X            if (tcp->flags & TCB_ATTACHED)
  1293. X                fprintf(stderr,
  1294. X                    "PANIC: attached pid %u exited\n",
  1295. X                    pid);
  1296. X            droptcb(tcp);
  1297. X            continue;
  1298. X        }
  1299. X        if (!WIFSTOPPED(status)) {
  1300. X            fprintf(stderr, "PANIC: pid %u not stopped\n", pid);
  1301. X            droptcb(tcp);
  1302. X            continue;
  1303. X        }
  1304. X        if (debug)
  1305. X            fprintf(stderr, "pid %u stopped, [%s]\n",
  1306. X                pid, signalent[WSTOPSIG(status)]);
  1307. X
  1308. X        if (tcp->flags & TCB_STARTUP) {
  1309. X            /*
  1310. X             * This flag is there to keep us in sync
  1311. X             * Next time this process stops it should
  1312. X             * really be entering a system call.
  1313. X             */
  1314. X            tcp->flags &= ~TCB_STARTUP;
  1315. X            if (tcp->flags & TCB_ATTACHED) {
  1316. X                /*
  1317. X                 * Interestingly, the process may stop
  1318. X                 * with STOPSIG equal to some other signal
  1319. X                 * than SIGSTOP if we happend to attach
  1320. X                 * just before the process takes a signal.
  1321. X                 */
  1322. X                if (!WIFSTOPPED(status)) {
  1323. X                    fprintf(stderr,
  1324. X                        "pid %u not stopped\n", pid);
  1325. X                    detach(tcp, WSTOPSIG(status));
  1326. X                    continue;
  1327. X                }
  1328. X            }
  1329. X            else {
  1330. X#ifdef SUNOS4
  1331. X                /* A child of us stopped at exec */
  1332. X                if (WSTOPSIG(status) == SIGTRAP && followvfork)
  1333. X                    fixvfork(tcp);
  1334. X#endif /* SUNOS4 */
  1335. X            }
  1336. X            if (tcp->flags & TCB_BPTSET) {
  1337. X                if (clearbpt(tcp) < 0) /* Pretty fatal */ {
  1338. X                    droptcb(tcp);
  1339. X                    cleanup();
  1340. X                    return -1;
  1341. X                }
  1342. X            }
  1343. X            goto tracing;
  1344. X        }
  1345. X
  1346. X        if (WSTOPSIG(status) != SIGTRAP) {
  1347. X            if (WSTOPSIG(status) == SIGSTOP &&
  1348. X                    (tcp->flags & TCB_SIGTRAPPED)) {
  1349. X                /*
  1350. X                 * Trapped attempt to block SIGTRAP
  1351. X                 * Hope we are back in control now.
  1352. X                 */
  1353. X                tcp->flags &= ~(TCB_INSYSCALL | TCB_SIGTRAPPED);
  1354. X                if (ptrace(PTRACE_SYSCALL,
  1355. X                        pid, (char *) 1, 0) < 0) {
  1356. X                    perror("trace: ptrace(PTRACE_SYSCALL, ...)");
  1357. X                    cleanup();
  1358. X                    return -1;
  1359. X                }
  1360. X                continue;
  1361. X            }
  1362. X            if (!cflag
  1363. X                && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
  1364. X                printleader(tcp);
  1365. X                tprintf("--- %s (%s) ---",
  1366. X                    signalent[WSTOPSIG(status)],
  1367. X                    strsignal(WSTOPSIG(status)));
  1368. X                printtrailer(tcp);
  1369. X            }
  1370. X            if ((tcp->flags & TCB_ATTACHED) &&
  1371. X                !sigishandled(tcp, WSTOPSIG(status))) {
  1372. X                detach(tcp, WSTOPSIG(status));
  1373. X                continue;
  1374. X            }
  1375. X            if (ptrace(PTRACE_SYSCALL, pid, (char *) 1,
  1376. X                   WSTOPSIG(status)) < 0) {
  1377. X                perror("trace: ptrace(PTRACE_SYSCALL, ...)");
  1378. X                cleanup();
  1379. X                return -1;
  1380. X            }
  1381. X            tcp->flags &= ~TCB_SUSPENDED;
  1382. X            continue;
  1383. X        }
  1384. X        if (syscall(tcp) < 0) {
  1385. X            if (tcp->flags & TCB_ATTACHED)
  1386. X                detach(tcp, 0);
  1387. X            else {
  1388. X                ptrace(PTRACE_KILL,
  1389. X                    tcp->pid, (char *) 1, SIGTERM);
  1390. X                droptcb(tcp);
  1391. X            }
  1392. X            continue;
  1393. X        }
  1394. X        if (tcp->flags & TCB_EXITING) {
  1395. X            if (tcp->flags & TCB_ATTACHED)
  1396. X                detach(tcp, 0);
  1397. X            else if (ptrace(PTRACE_CONT, pid, (char *) 1, 0) < 0) {
  1398. X                perror("strace: ptrace(PTRACE_CONT, ...)");
  1399. X                cleanup();
  1400. X                return -1;
  1401. X            }
  1402. X            continue;
  1403. X        }
  1404. X        if (tcp->flags & TCB_SUSPENDED) {
  1405. X            if (!qflag)
  1406. X                fprintf(stderr, "Process %u suspended\n", pid);
  1407. X            continue;
  1408. X        }
  1409. X    tracing:
  1410. X        if (ptrace(PTRACE_SYSCALL, pid, (char *) 1, 0) < 0) {
  1411. X            perror("trace: ptrace(PTRACE_SYSCALL, ...)");
  1412. X            cleanup();
  1413. X            return -1;
  1414. X        }
  1415. X    }
  1416. X    return 0;
  1417. X}
  1418. X
  1419. X#endif /* !SVR4 */
  1420. X
  1421. Xstatic int curcol;
  1422. X
  1423. X#ifdef __STDC__
  1424. X#include <stdarg.h>
  1425. X#define VA_START(a, b) va_start(a, b)
  1426. X#else
  1427. X#include <varargs.h>
  1428. X#define VA_START(a, b) va_start(a)
  1429. X#endif
  1430. X
  1431. Xvoid
  1432. X#ifdef __STDC__
  1433. Xtprintf(const char *fmt, ...)
  1434. X#else
  1435. Xtprintf(fmt, va_alist)
  1436. Xchar *fmt;
  1437. Xva_dcl
  1438. X#endif
  1439. X{
  1440. X    va_list args;
  1441. X
  1442. X    VA_START(args, fmt);
  1443. X    curcol += vfprintf(outf, fmt, args);
  1444. X    va_end(args);
  1445. X    return;
  1446. X}
  1447. X
  1448. Xvoid
  1449. Xprintleader(tcp)
  1450. Xstruct tcb *tcp;
  1451. X{
  1452. X    if (tcp_last && (!outfname || followfork < 2 || tcp_last == tcp)) {
  1453. X        tcp_last->flags |= TCB_REPRINT;
  1454. X        tprintf(" <unfinished ...>\n");
  1455. X    }
  1456. X    curcol = 0;
  1457. X    if (followfork == 1 && outfname)
  1458. X        tprintf("%-5d ", tcp->pid);
  1459. X    else if (nprocs > 1 && !outfname)
  1460. X        tprintf("[pid %5u] ", tcp->pid);
  1461. X    if (tflag) {
  1462. X        char str[sizeof("HH:MM:SS")];
  1463. X        struct timeval tv, dtv;
  1464. X        static struct timeval otv;
  1465. X
  1466. X        gettimeofday(&tv, NULL);
  1467. X        if (rflag) {
  1468. X            if (otv.tv_sec == 0)
  1469. X                otv = tv;
  1470. X            tv_sub(&dtv, &tv, &otv);
  1471. X            tprintf("%6ld.%06ld ", dtv.tv_sec, dtv.tv_usec);
  1472. X            otv = tv;
  1473. X        }
  1474. X        else if (tflag > 2)
  1475. X            tprintf("%ld.%06ld ", tv.tv_sec, tv.tv_usec);
  1476. X        else {
  1477. X            strftime(str, sizeof(str), "%T", localtime(&tv.tv_sec));
  1478. X            if (tflag > 1)
  1479. X                tprintf("%s.%06ld ", str, tv.tv_usec);
  1480. X            else
  1481. X                tprintf("%s ", str);
  1482. X        }
  1483. X    }
  1484. X    if (iflag)
  1485. X        printcall(tcp);
  1486. X}
  1487. X
  1488. Xvoid
  1489. Xtabto(col)
  1490. Xint col;
  1491. X{
  1492. X    if (curcol < col)
  1493. X        tprintf("%*s", col - curcol, "");
  1494. X}
  1495. X
  1496. Xvoid
  1497. Xprinttrailer(tcp)
  1498. Xstruct tcb *tcp;
  1499. X{
  1500. X    tprintf("\n");
  1501. X    tcp_last = NULL;
  1502. X}
  1503. END_OF_FILE
  1504.   if test 31363 -ne `wc -c <'strace-3.0/strace.c'`; then
  1505.     echo shar: \"'strace-3.0/strace.c'\" unpacked with wrong size!
  1506.   fi
  1507.   # end of 'strace-3.0/strace.c'
  1508. fi
  1509. if test -f 'strace-3.0/sunos4/ioctlent.h' -a "${1}" != "-c" ; then 
  1510.   echo shar: Will not clobber existing file \"'strace-3.0/sunos4/ioctlent.h'\"
  1511. else
  1512.   echo shar: Extracting \"'strace-3.0/sunos4/ioctlent.h'\" \(22969 characters\)
  1513.   sed "s/^X//" >'strace-3.0/sunos4/ioctlent.h' <<'END_OF_FILE'
  1514. X{"sun/audioio.h",    "AUDIO_DRAIN",    0x20004103},
  1515. X{"sun/isdnio.h",    "ISDN_PH_ACTIVATE_REQ",    0x2000410a},
  1516. X{"sun/isdnio.h",    "ISDN_MPH_DEACTIVATE_REQ",    0x2000410b},
  1517. X{"sun/fbio.h",    "FBIO_WID_DBL_SET",    0x20004625},
  1518. X{"pixrect/gp1var.h",    "GP1IO_SCMAP",    0x20004766},
  1519. X{"sun/mem.h",    "MM_HRCNT",    0x20004d02},
  1520. X{"sundev/openpromio.h",    "OPROMGETOPT",    0x20004f01},
  1521. X{"sundev/openpromio.h",    "OPROMSETOPT",    0x20004f02},
  1522. X{"sundev/openpromio.h",    "OPROMNXTOPT",    0x20004f03},
  1523. X{"sundev/openpromio.h",    "OPROMSETOPT2",    0x20004f04},
  1524. X{"sundev/openpromio.h",    "OPROMNEXT",    0x20004f05},
  1525. X{"sundev/openpromio.h",    "OPROMCHILD",    0x20004f06},
  1526. X{"sundev/openpromio.h",    "OPROMGETPROP",    0x20004f07},
  1527. X{"sundev/openpromio.h",    "OPROMNXTPROP",    0x20004f08},
  1528. X{"sundev/openpromio.h",    "OPROMU2P",    0x20004f09},
  1529. X{"sundev/openpromio.h",    "OPROMGETCONS",    0x20004f0a},
  1530. X{"stropts.h",    "I_POP",    0x20005303},
  1531. X{"sys/stropts.h",    "I_POP",    0x20005303},
  1532. X{"stropts.h",    "I_FLUSH",    0x20005305},
  1533. X{"sys/stropts.h",    "I_FLUSH",    0x20005305},
  1534. X{"sys/stropts.h",    "I_SRDOPT",    0x20005306},
  1535. X{"stropts.h",    "I_SRDOPT",    0x20005306},
  1536. X{"sys/stropts.h",    "I_SETSIG",    0x20005309},
  1537. X{"stropts.h",    "I_SETSIG",    0x20005309},
  1538. X{"sys/stropts.h",    "I_LINK",    0x2000530c},
  1539. X{"stropts.h",    "I_LINK",    0x2000530c},
  1540. X{"sys/stropts.h",    "I_UNLINK",    0x2000530d},
  1541. X{"stropts.h",    "I_UNLINK",    0x2000530d},
  1542. X{"sys/stropts.h",    "I_SENDFD",    0x20005311},
  1543. X{"stropts.h",    "I_SENDFD",    0x20005311},
  1544. X{"sys/stropts.h",    "I_PLINK",    0x20005313},
  1545. X{"stropts.h",    "I_PLINK",    0x20005313},
  1546. X{"stropts.h",    "I_PUNLINK",    0x20005314},
  1547. X{"sys/stropts.h",    "I_PUNLINK",    0x20005314},
  1548. X{"termio.h",    "TCSBRK",    0x20005405},
  1549. X{"sys/termio.h",    "TCSBRK",    0x20005405},
  1550. X{"termios.h",    "TCXONC",    0x20005406},
  1551. X{"sys/termios.h",    "TCXONC",    0x20005406},
  1552. X{"sys/termios.h",    "TCFLSH",    0x20005407},
  1553. X{"termios.h",    "TCFLSH",    0x20005407},
  1554. X{"sun/tvio.h",    "TVIOGRAB",    0x2000581d},
  1555. X{"sun/tvio.h",    "TVIORELEASE",    0x2000581e},
  1556. X{"sun/tvio.h",    "TVIOREDIRECT",    0x20005822},
  1557. X{"sun/tvio.h",    "TVIOSYNC",    0x20005825},
  1558. X{"sun/tvio.h",    "TVIOVWAIT",    0x2000582d},
  1559. X{"sun/tvio.h",    "TVIOSLOOPBACKCAL",    0x2000583d},
  1560. X{"sbusdev/bpp_io.h",    "BPPIOC_TESTIO",    0x20006206},
  1561. X{"scsi/targets/srdef.h",    "CDROMPAUSE",    0x2000630a},
  1562. X{"sundev/srreg.h",    "CDROMPAUSE",    0x2000630a},
  1563. X{"sundev/srreg.h",    "CDROMRESUME",    0x2000630b},
  1564. X{"sundev/srreg.h",    "CDROMSTOP",    0x20006369},
  1565. X{"scsi/targets/srdef.h",    "CDROMSTOP",    0x20006369},
  1566. X{"scsi/targets/srdef.h",    "CDROMSTART",    0x2000636a},
  1567. X{"sundev/srreg.h",    "CDROMSTART",    0x2000636a},
  1568. X{"scsi/targets/srdef.h",    "CDROMEJECT",    0x2000636b},
  1569. X{"sundev/srreg.h",    "CDROMEJECT",    0x2000636b},
  1570. X{"sun/dkio.h",    "FDKEJECT",    0x20006470},
  1571. X{"sys/filio.h",    "FIOCLEX",    0x20006601},
  1572. X{"sys/filio.h",    "FIONCLEX",    0x20006602},
  1573. X{"sys/filio.h",    "FIOLFS",    0x20006640},
  1574. X{"sys/filio.h",    "FIOLFSS",    0x20006641},
  1575. X{"sys/filio.h",    "FIOFFS",    0x20006642},
  1576. X{"sys/filio.h",    "FIOAI",    0x20006643},
  1577. X{"sys/filio.h",    "FIODUTIMES",    0x20006644},
  1578. X{"sys/filio.h",    "FIODIO",    0x20006645},
  1579. X{"sys/filio.h",    "FIODIOS",    0x20006646},
  1580. X{"sunwindow/win_ioctl.h",    "WININSERT",    0x20006703},
  1581. X{"sunwindow/win_ioctl.h",    "WINREMOVE",    0x20006704},
  1582. X{"sunwindow/win_ioctl.h",    "WINCOMPUTECLIPPING",    0x20006712},
  1583. X{"sunwindow/win_ioctl.h",    "WINLOCKDATA",    0x20006715},
  1584. X{"sunwindow/win_ioctl.h",    "WINUNLOCKDATA",    0x20006716},
  1585. X{"sunwindow/win_ioctl.h",    "WINGRABIO",    0x20006717},
  1586. X{"sunwindow/win_ioctl.h",    "WINRELEASEIO",    0x20006718},
  1587. X{"sunwindow/win_ioctl.h",    "WINUNLOCKEVENT",    0x2000671c},
  1588. X{"sunwindow/win_ioctl.h",    "WINUNLOCKSCREEN",    0x2000671e},
  1589. X{"sunwindow/win_ioctl.h",    "WINSCREENDESTROY",    0x2000672a},
  1590. X{"sunwindow/win_ioctl.h",    "WINPRINT",    0x2000672c},
  1591. X{"sunwindow/win_ioctl.h",    "WINREFUSEKBDFOCUS",    0x2000673a},
  1592. X{"sunwindow/win_ioctl.h",    "WINDBLACCESS",    0x20006747},
  1593. X{"sunwindow/win_ioctl.h",    "WINDBLFLIP",    0x20006748},
  1594. X{"sunwindow/win_ioctl.h",    "WINDBLABSORB",    0x20006749},
  1595. X{"sunwindow/win_ioctl.h",    "WINDBLRLSE",    0x2000674a},
  1596. X{"sunwindow/win_ioctl.h",    "WINSHAREQUEUE",    0x20006750},
  1597. X{"sunwindow/win_ioctl.h",    "WINDISCONNECT",    0x20006798},
  1598. X{"sunwindow/win_ioctl.h",    "WINRECONNECT",    0x20006799},
  1599. X{"sun/ndio.h",    "NDIOCSON",    0x20006e00},
  1600. X{"sun/ndio.h",    "NDIOCSOFF",    0x20006e01},
  1601. X{"sun/ndio.h",    "NDIOCCLEAR",    0x20006e05},
  1602. X{"net/nit_buf.h",    "NIOCCTIME",    0x20007008},
  1603. X{"sys/ttold.h",    "TIOCHPCL",    0x20007402},
  1604. X{"sbusdev/gtreg.h",    "FB_SETSERVER",    0x20007407},
  1605. X{"sys/ttold.h",    "TIOCEXCL",    0x2000740d},
  1606. X{"sys/ttold.h",    "TIOCNXCL",    0x2000740e},
  1607. X{"sbusdev/gtreg.h",    "FB_DISCONNECT",    0x20007410},
  1608. X{"sbusdev/gtreg.h",    "FB_UNGRABHW",    0x20007414},
  1609. X{"sys/ttycom.h",    "TIOCCONS",    0x20007424},
  1610. X{"sys/ttold.h",    "_O_TIOCCONS",    0x20007468},
  1611. X{"sys/ttold.h",    "TIOCSTART",    0x2000746e},
  1612. X{"sys/ttold.h",    "TIOCSTOP",    0x2000746f},
  1613. X{"sys/ttycom.h",    "TIOCNOTTY",    0x20007471},
  1614. X{"sys/ttold.h",    "TIOCCDTR",    0x20007478},
  1615. X{"sys/ttold.h",    "TIOCSDTR",    0x20007479},
  1616. X{"sys/ttold.h",    "TIOCCBRK",    0x2000747a},
  1617. X{"sys/ttold.h",    "TIOCSBRK",    0x2000747b},
  1618. X{"sys/ttycom.h",    "TIOCSCTTY",    0x20007484},
  1619. X{"sun/gpio.h",    "GP1IO_GET_TRUMINORDEV",    0x40014708},
  1620. X{"sundev/kbio.h",    "KIOCGLED",    0x40016b0f},
  1621. X{"sundev/ppreg.h",    "PPIOCGETS",    0x40017000},
  1622. X{"sundev/ppreg.h",    "PPIOCGETC",    0x40017001},
  1623. X{"sun/gpio.h",    "GP1IO_GET_REQDEV",    0x40024707},
  1624. X{"sun/tvio.h",    "TVIOGBIND",    0x4002581f},
  1625. X{"sbusdev/bpp_io.h",    "BPPIOC_GETOUTPINS",    0x40026204},
  1626. X{"sundev/srreg.h",    "CDROMREADTOCHDR",    0x40026367},
  1627. X{"sbusdev/bpp_io.h",    "BPPIOC_GETERR",    0x40036205},
  1628. X{"sun/audioio.h",    "AUDIO_GETDEV",    0x40044104},
  1629. X{"sun/fbio.h",    "FBIOGVIDEO",    0x40044608},
  1630. X{"sun/fbio.h",    "GRABPAGEALLOC",    0x4004460a},
  1631. X{"sun/fbio.h",    "FBIOGPLNGRP",    0x4004460d},
  1632. X{"sun/fbio.h",    "FBIOGCMSIZE",    0x4004460e},
  1633. X{"sun/fbio.h",    "FBIOAVAILPLNGRP",    0x40044611},
  1634. X{"sun/fbio.h",    "FBIOSWINFD",    0x40044614},
  1635. X{"sun/fbio.h",    "FBIOSAVWINFD",    0x40044615},
  1636. X{"sun/fbio.h",    "FBIORESWINFD",    0x40044616},
  1637. X{"sun/fbio.h",    "FBIOSRWINFD",    0x40044617},
  1638. X{"sun/fbio.h",    "FBIOGCURMAX",    0x4004461c},
  1639. X{"sun/fbio.h",    "GRABLOCKINFO",    0x4004461d},
  1640. X{"sun/fbio.h",    "FBIO_DEVID",    0x40044622},
  1641. X{"sun/fbio.h",    "FBIO_FULLSCREEN_ELIMINATION_GROUPS",    0x40044624},
  1642. X{"sun/fbio.h",    "FBIOVRTOFFSET",    0x40044626},
  1643. X{"sun/gpio.h",    "GP1IO_GET_STATIC_BLOCK",    0x40044701},
  1644. X{"sun/gpio.h",    "GP1IO_GET_GBUFFER_STATE",    0x40044703},
  1645. X{"sun/gpio.h",    "GP1IO_GET_RESTART_COUNT",    0x40044705},
  1646. X{"sun/gpio.h",    "GP1IO_CHK_FOR_GBUFFER",    0x40044709},
  1647. X{"stropts.h",    "I_NREAD",    0x40045301},
  1648. X{"sys/stropts.h",    "I_NREAD",    0x40045301},
  1649. X{"sys/stropts.h",    "I_GRDOPT",    0x40045307},
  1650. X{"stropts.h",    "I_GRDOPT",    0x40045307},
  1651. X{"sys/stropts.h",    "I_GETSIG",    0x4004530a},
  1652. X{"stropts.h",    "I_GETSIG",    0x4004530a},
  1653. X{"sun/tvio.h",    "TVIOGFORMAT",    0x40045801},
  1654. X{"sun/tvio.h",    "TVIOGCOMPOUT",    0x40045803},
  1655. X{"sun/tvio.h",    "TVIOGSYNC",    0x40045805},
  1656. X{"pixrect/cg8var.h",    "PIPIO_G_PIP_ON_OFF",    0x40045805},
  1657. X{"sun/tvio.h",    "TVIOGOUT",    0x40045807},
  1658. X{"sun/tvio.h",    "TVIOGCOMPRESS",    0x40045809},
  1659. X{"pixrect/cg8var.h",    "PIPIO_G_PIP_ON_OFF_RESUME",    0x40045809},
  1660. X{"pixrect/cg8var.h",    "PIPIO_G_PIP_ON_OFF_SUSPEND",    0x4004580a},
  1661. X{"sun/tvio.h",    "TVIOGCHROMAGAIN",    0x4004580b},
  1662. X{"sun/tvio.h",    "TVIOGREDGAIN",    0x4004580d},
  1663. X{"sun/tvio.h",    "TVIOGREDBLACK",    0x4004580f},
  1664. X{"sun/tvio.h",    "TVIOGGREENGAIN",    0x40045811},
  1665. X{"sun/tvio.h",    "TVIOGGREENBLACK",    0x40045813},
  1666. X{"sun/tvio.h",    "TVIOGBLUEGAIN",    0x40045815},
  1667. X{"sun/tvio.h",    "TVIOGBLUEBLACK",    0x40045817},
  1668. X{"sun/tvio.h",    "TVIOGLUMAGAIN",    0x40045819},
  1669. X{"sun/tvio.h",    "TVIOGBTYPE",    0x40045821},
  1670. X{"sun/tvio.h",    "TVIOGLIVE",    0x40045823},
  1671. X{"sun/tvio.h",    "TVIOGCHROMASEP",    0x40045827},
  1672. X{"pixrect/cg8var.h",    "PIPIO_G_CURSOR_COLOR_FREEZE",    0x40045828},
  1673. X{"sun/tvio.h",    "TVIOGCHROMADEMOD",    0x40045829},
  1674. X{"pixrect/cg8var.h",    "PIPIO_G_TEST",    0x4004582b},
  1675. X{"sun/tvio.h",    "TVIOGGENLOCK",    0x4004582b},
  1676. X{"sun/tvio.h",    "TVIOGSYNCABSENT",    0x4004582e},
  1677. X{"sun/tvio.h",    "TVIOGBURSTABSENT",    0x4004582f},
  1678. X{"sun/tvio.h",    "TVIOGIBSTATE",    0x40045837},
  1679. X{"sun/tvio.h",    "TVIOGABSTATE",    0x40045839},
  1680. X{"sun/tvio.h",    "TVIOGCONTROL",    0x4004583b},
  1681. X{"sun/dkio.h",    "FDKGETCHANGE",    0x4004646f},
  1682. X{"sys/filio.h",    "FIOGETOWN",    0x4004667b},
  1683. X{"sys/filio.h",    "FIONREAD",    0x4004667f},
  1684. X{"sunwindow/win_ioctl.h",    "WINGETUSERFLAGS",    0x4004670e},
  1685. X{"sunwindow/win_ioctl.h",    "WINGETOWNER",    0x40046710},
  1686. X{"sunwindow/win_ioctl.h",    "WINGETBUTTONORDER",    0x40046724},
  1687. X{"sunwindow/win_ioctl.h",    "WINGETNEXTINPUT",    0x40046739},
  1688. X{"sunwindow/win_ioctl.h",    "WINGETPLANEGROUP",    0x40046740},
  1689. X{"sunwindow/win_ioctl.h",    "WINGETNOTIFYALL",    0x40046751},
  1690. X{"sundev/kbio.h",    "KIOCGTRANS",    0x40046b05},
  1691. X{"sundev/kbio.h",    "KIOCGTRANSABLE",    0x40046b07},
  1692. X{"sundev/kbio.h",    "KIOCTYPE",    0x40046b09},
  1693. X{"sundev/kbio.h",    "KIOCGDIRECT",    0x40046b0b},
  1694. X{"sundev/kbio.h",    "KIOCGCOMPAT",    0x40046b11},
  1695. X{"sundev/kbio.h",    "KIOCLAYOUT",    0x40046b14},
  1696. X{"sys/sockio.h",    "SIOCGHIWAT",    0x40047301},
  1697. X{"sys/sockio.h",    "SIOCGLOWAT",    0x40047303},
  1698. X{"sys/sockio.h",    "SIOCATMARK",    0x40047307},
  1699. X{"sys/sockio.h",    "SIOCGPGRP",    0x40047309},
  1700. X{"sys/ttold.h",    "TIOCGETD",    0x40047400},
  1701. X{"sys/ttold.h",    "TIOCMODG",    0x40047403},
  1702. X{"sbusdev/gtreg.h",    "FB_GETWPART",    0x4004740a},
  1703. X{"sbusdev/gtreg.h",    "FB_GETMONITOR",    0x4004740c},
  1704. X{"sbusdev/gtreg.h",    "FB_GRABHW",    0x40047413},
  1705. X{"sbusdev/gtreg.h",    "FB_GETCLUTPART",    0x40047418},
  1706. X{"sys/ttold.h",    "TIOCGETX",    0x40047423},
  1707. X{"sys/ttycom.h",    "TIOCGSOFTCAR",    0x40047464},
  1708. X{"sys/ttycom.h",    "TIOCMGET",    0x4004746a},
  1709. X{"sys/ttycom.h",    "TIOCOUTQ",    0x40047473},
  1710. X{"sys/ttycom.h",    "TIOCGPGRP",    0x40047477},
  1711. X{"sys/ttold.h",    "TIOCLGET",    0x4004747c},
  1712. X{"sys/ttycom.h",    "TIOCISPACE",    0x40047480},
  1713. X{"sys/ttycom.h",    "TIOCISIZE",    0x40047481},
  1714. X{"sys/ttycom.h",    "TIOCGETPGRP",    0x40047483},
  1715. X{"sys/vcmd.h",    "VGETSTATE",    0x40047600},
  1716. X{"sundev/vuid_event.h",    "VUIDGFORMAT",    0x40047602},
  1717. X{"sun/dkio.h",    "DKIOCGTYPE",    0x4006647c},
  1718. X{"sys/ttold.h",    "TIOCGETP",    0x40067408},
  1719. X{"sys/ttold.h",    "TIOCGETC",    0x40067412},
  1720. X{"sys/ttold.h",    "TIOCGLTC",    0x40067474},
  1721. X{"sun/tvio.h",    "TVIOGPOS",    0x4008581b},
  1722. X{"sun/dkio.h",    "DKIOCGPART",    0x40086404},
  1723. X{"sun/dkio.h",    "FDKGETSEARCH",    0x4008646c},
  1724. X{"sunwindow/win_ioctl.h",    "WINNEXTFREE",    0x40086705},
  1725. X{"sunwindow/win_ioctl.h",    "WINGETRECT",    0x4008670a},
  1726. X{"sunwindow/win_ioctl.h",    "WINGETSAVEDRECT",    0x4008670d},
  1727. X{"sunwindow/win_ioctl.h",    "WINGETEVENTTIMEOUT",    0x4008673c},
  1728. X{"sunwindow/win_ioctl.h",    "WINDBLCURRENT",    0x4008674d},
  1729. X{"sun/sqz.h",    "SQZGET",    0x40087102},
  1730. X{"sbusdev/gtreg.h",    "FB_GETLIGHTPENPARAM",    0x4008741b},
  1731. X{"sbusdev/gtreg.h",    "FB_GETGAMMA",    0x40087420},
  1732. X{"sys/ttycom.h",    "TIOCGSIZE",    0x40087426},
  1733. X{"sys/ttold.h",    "_O_TIOCGSIZE",    0x40087466},
  1734. X{"sys/ttycom.h",    "TIOCGWINSZ",    0x40087468},
  1735. X{"sun/dkio.h",    "DKIOCINFO",    0x400c6408},
  1736. X{"sun/dkio.h",    "DKIOCGDIAG",    0x400c6474},
  1737. X{"sun/dkio.h",    "DKIOCGLOG",    0x400c6476},
  1738. X{"sunwindow/win_ioctl.h",    "WINGETFOCUSEVENT",    0x400c6747},
  1739. X{"sunwindow/win_ioctl.h",    "WINGETSWALLOWEVENT",    0x400c6749},
  1740. X{"pixrect/cg8var.h",    "PIPIO_G_EMULATION_MODE",    0x400e5803},
  1741. X{"sun/fbio.h",    "FBIOGXINFO",    0x40104627},
  1742. X{"sys/stropts.h",    "I_RECVFD",    0x40105312},
  1743. X{"stropts.h",    "I_RECVFD",    0x40105312},
  1744. X{"sunwindow/win_ioctl.h",    "WINGETSCREENPOSITIONS",    0x4010672d},
  1745. X{"scsi/targets/stdef.h",    "STIOCGET",    0x40106d02},
  1746. X{"sundev/streg.h",    "STIOCGET",    0x40106d02},
  1747. X{"sys/termio.h",    "TCGETA",    0x40125401},
  1748. X{"termio.h",    "TCGETA",    0x40125401},
  1749. X{"sunwindow/win_ioctl.h",    "WINGETAVAILPLANEGROUPS",    0x40146742},
  1750. X{"sun/fbio.h",    "FBIOGTYPE",    0x40184600},
  1751. X{"sun/fbio.h",    "FBIOGINFO",    0x40184602},
  1752. X{"sun/fbio.h",    "FBIODBLGINFO",    0x40184612},
  1753. X{"sys/mtio.h",    "MTIOCGET",    0x40186d02},
  1754. X{"sun/dkio.h",    "FDKIOGCHAR",    0x401c6472},
  1755. X{"sun/fbio.h",    "FBIOMONINFO",    0x40204628},
  1756. X{"sbusdev/bpp_io.h",    "BPPIOC_GETPARMS",    0x40206202},
  1757. X{"sbusdev/gtreg.h",    "FB_GT_GETVERSION",    0x40207429},
  1758. X{"sys/termios.h",    "TCGETS",    0x40245408},
  1759. X{"termios.h",    "TCGETS",    0x40245408},
  1760. X{"sun/dkio.h",    "DKIOCGGEOM",    0x40266402},
  1761. X{"sunwindow/win_ioctl.h",    "WINGETKBDMASK",    0x40346734},
  1762. X{"sunwindow/win_ioctl.h",    "WINGETPICKMASK",    0x40346735},
  1763. X{"sun/dkio.h",    "FDKGETDRIVECHAR",    0x4038646e},
  1764. X{"sun/dkio.h",    "DKIOCGCONF",    0x403c647e},
  1765. X{"sun/tvio.h",    "TVIOGVIDEOCAL",    0x40405831},
  1766. X{"sun/tvio.h",    "TVIONVREAD",    0x40405833},
  1767. X{"sun/dkio.h",    "DKIOCGAPART",    0x4040647a},
  1768. X{"sunwindow/win_ioctl.h",    "WINGETSCALING",    0x40406726},
  1769. X{"sun/fbio.h",    "FBIOGATTR",    0x40584606},
  1770. X{"sunwindow/win_ioctl.h",    "WINSCREENGET",    0x40646729},
  1771. X{"sunwindow/win_ioctl.h",    "WINGETINPUTMASK",    0x406c6713},
  1772. X{"sun/audioio.h",    "AUDIO_GETINFO",    0x40844101},
  1773. X{"pixrect/cg8var.h",    "PIPIO_G_FB_INFO",    0x40d05801},
  1774. X{"sundev/kbio.h",    "KIOCSLED",    0x80016b0e},
  1775. X{"sundev/ppreg.h",    "PPIOCSETC",    0x80017002},
  1776. X{"sys/ttycom.h",    "TIOCSTI",    0x80017472},
  1777. X{"sun/tvio.h",    "TVIOSBIND",    0x80025820},
  1778. X{"sbusdev/bpp_io.h",    "BPPIOC_SETOUTPINS",    0x80026203},
  1779. X{"sun/isdnio.h",    "ISDN_MESSAGE_SET",    0x8004410c},
  1780. X{"sun/fbio.h",    "FBIOSVIDEO",    0x80044607},
  1781. X{"sun/fbio.h",    "FBIOVERTICAL",    0x80044609},
  1782. X{"sun/fbio.h",    "GRABPAGEFREE",    0x8004460b},
  1783. X{"sun/fbio.h",    "GRABATTACH",    0x8004460c},
  1784. X{"sun/fbio.h",    "FBIOSCMSIZE",    0x8004460f},
  1785. X{"sun/fbio.h",    "FBIOSCMS",    0x80044610},
  1786. X{"sun/fbio.h",    "FBIOSCURPOS",    0x8004461a},
  1787. X{"sun/fbio.h",    "FBIOGCURPOS",    0x8004461b},
  1788. X{"sun/fbio.h",    "FBIO_U_RST",    0x80044623},
  1789. X{"sun/gpio.h",    "GP1IO_FREE_STATIC_BLOCK",    0x80044702},
  1790. X{"sun/gpio.h",    "GP1IO_CHK_GP",    0x80044704},
  1791. X{"sun/gpio.h",    "GP1IO_REDIRECT_DEVFB",    0x80044706},
  1792. X{"sun/gpio.h",    "GP1IO_SET_USING_GBUFFER",    0x8004470a},
  1793. X{"sun/mem.h",    "MM_CCRW",    0x80044d03},
  1794. X{"sun/mem.h",    "MM_PCNT0",    0x80044d04},
  1795. X{"sun/mem.h",    "MM_PCNT1",    0x80044d05},
  1796. X{"sun/vddrv.h",    "VDFREEVADDR",    0x80045604},
  1797. X{"sun/tvio.h",    "TVIOSFORMAT",    0x80045802},
  1798. X{"sun/tvio.h",    "TVIOSCOMPOUT",    0x80045804},
  1799. X{"sun/tvio.h",    "TVIOSSYNC",    0x80045806},
  1800. X{"pixrect/cg8var.h",    "PIPIO_S_PIP_ON_OFF",    0x80045807},
  1801. X{"sun/tvio.h",    "TVIOSOUT",    0x80045808},
  1802. X{"sun/tvio.h",    "TVIOSCOMPRESS",    0x8004580a},
  1803. X{"sun/tvio.h",    "TVIOSCHROMAGAIN",    0x8004580c},
  1804. X{"sun/tvio.h",    "TVIOSREDGAIN",    0x8004580e},
  1805. X{"sun/tvio.h",    "TVIOSREDBLACK",    0x80045810},
  1806. X{"sun/tvio.h",    "TVIOSGREENGAIN",    0x80045812},
  1807. X{"sun/tvio.h",    "TVIOSGREENBLACK",    0x80045814},
  1808. X{"sun/tvio.h",    "TVIOSBLUEGAIN",    0x80045816},
  1809. X{"sun/tvio.h",    "TVIOSBLUEBLACK",    0x80045818},
  1810. X{"sun/tvio.h",    "TVIOSLUMAGAIN",    0x8004581a},
  1811. X{"sun/tvio.h",    "TVIOSLIVE",    0x80045824},
  1812. X{"sun/tvio.h",    "TVIOSCHROMASEP",    0x80045828},
  1813. X{"pixrect/cg8var.h",    "PIPIO_S_CURSOR_COLOR_FREEZE",    0x80045829},
  1814. X{"pixrect/cg8var.h",    "PIPIO_S_MAP_SLOT",    0x8004582a},
  1815. X{"sun/tvio.h",    "TVIOSCHROMADEMOD",    0x8004582a},
  1816. X{"pixrect/cg8var.h",    "PIPIO_S_TEST",    0x8004582c},
  1817. X{"sun/tvio.h",    "TVIOSGENLOCK",    0x8004582c},
  1818. X{"sun/tvio.h",    "TVIOSIBADVANCE",    0x80045835},
  1819. X{"sun/tvio.h",    "TVIOSABSTATE",    0x80045838},
  1820. X{"sun/tvio.h",    "TVIOSCONTROL",    0x8004583c},
  1821. X{"sundev/srreg.h",    "CDROMPLAYTRKIND",    0x8004630d},
  1822. X{"scsi/targets/srdef.h",    "CDROMPLAYTRKIND",    0x8004630d},
  1823. X{"sundev/srreg.h",    "CDROMVOLCTRL",    0x8004630e},
  1824. X{"sun/dkio.h",    "DKIOCGBAD",    0x80046478},
  1825. X{"sun/dkio.h",    "DKIOCSBAD",    0x80046479},
  1826. X{"sys/filio.h",    "FIOSETOWN",    0x8004667c},
  1827. X{"sys/filio.h",    "FIOASYNC",    0x8004667d},
  1828. X{"sys/filio.h",    "FIONBIO",    0x8004667e},
  1829. X{"sunwindow/win_ioctl.h",    "WINSETMOUSE",    0x80046706},
  1830. X{"sunwindow/win_ioctl.h",    "WINSETUSERFLAGS",    0x8004670f},
  1831. X{"sunwindow/win_ioctl.h",    "WINSETOWNER",    0x80046711},
  1832. X{"sunwindow/win_ioctl.h",    "WINDONEDAMAGED",    0x80046721},
  1833. X{"sunwindow/win_ioctl.h",    "WINSETBUTTONORDER",    0x80046725},
  1834. X{"sunwindow/win_ioctl.h",    "WINSETNEXTINPUT",    0x80046738},
  1835. X{"sunwindow/win_ioctl.h",    "WINSETKBDFOCUS",    0x8004673d},
  1836. X{"sunwindow/win_ioctl.h",    "WINSETPLANEGROUP",    0x8004673f},
  1837. X{"sunwindow/win_ioctl.h",    "WINSETNOTIFYALL",    0x80046752},
  1838. X{"sunwindow/win_ioctl.h",    "WINSETRECQUE",    0x800467c8},
  1839. X{"sunwindow/win_ioctl.h",    "WINSETRECORD",    0x800467c9},
  1840. X{"sunwindow/win_ioctl.h",    "WINSETPLAYBACK",    0x800467cb},
  1841. X{"sys/sockio.h",    "SIOCSPROMISC",    0x80046930},
  1842. X{"sundev/kbio.h",    "KIOCTRANS",    0x80046b00},
  1843. X{"sundev/kbio.h",    "KIOCTRANSABLE",    0x80046b06},
  1844. X{"sundev/kbio.h",    "KIOCCMD",    0x80046b08},
  1845. X{"sundev/kbio.h",    "KIOCSDIRECT",    0x80046b0a},
  1846. X{"sundev/kbio.h",    "KIOCSCOMPAT",    0x80046b10},
  1847. X{"sun/ndio.h",    "NDIOCSAT",    0x80046e04},
  1848. X{"sun/ndio.h",    "NDIOCVER",    0x80046e07},
  1849. X{"net/nit_if.h",    "NIOCSFLAGS",    0x80047004},
  1850. X{"net/nit_if.h",    "NIOCSSNAP",    0x80047006},
  1851. X{"net/nit_buf.h",    "NIOCSCHUNK",    0x80047009},
  1852. X{"sun/sqz.h",    "SQZSET",    0x80047101},
  1853. X{"sys/sockio.h",    "SIOCSHIWAT",    0x80047300},
  1854. X{"sys/sockio.h",    "SIOCSLOWAT",    0x80047302},
  1855. X{"sys/sockio.h",    "SIOCSPGRP",    0x80047308},
  1856. X{"sys/ttold.h",    "TIOCSETD",    0x80047401},
  1857. X{"sys/ttold.h",    "TIOCMODS",    0x80047404},
  1858. X{"sbusdev/gtreg.h",    "FB_FCSFREE",    0x80047406},
  1859. X{"sbusdev/gtreg.h",    "FB_SETDIAGMODE",    0x80047408},
  1860. X{"sbusdev/gtreg.h",    "FB_SETWPART",    0x80047409},
  1861. X{"sbusdev/gtreg.h",    "FB_SETMONITOR",    0x8004740b},
  1862. X{"sys/ttold.h",    "TIOCFLUSH",    0x80047410},
  1863. X{"sbusdev/gtreg.h",    "FB_LOADKMCB",    0x80047411},
  1864. X{"sbusdev/gtreg.h",    "FB_SETCLUTPART",    0x80047417},
  1865. X{"sbusdev/gtreg.h",    "FB_LIGHTPENENABLE",    0x80047419},
  1866. X{"sys/ttycom.h",    "TIOCTCNTL",    0x80047420},
  1867. X{"sys/ttycom.h",    "TIOCSIGNAL",    0x80047421},
  1868. X{"sys/ttold.h",    "TIOCSETX",    0x80047422},
  1869. X{"sys/ttycom.h",    "TIOCSSOFTCAR",    0x80047465},
  1870. X{"sys/ttycom.h",    "TIOCUCNTL",    0x80047466},
  1871. X{"sys/ttycom.h",    "TIOCREMOTE",    0x80047469},
  1872. X{"sys/ttycom.h",    "TIOCMBIC",    0x8004746b},
  1873. X{"sys/ttycom.h",    "TIOCMBIS",    0x8004746c},
  1874. X{"sys/ttycom.h",    "TIOCMSET",    0x8004746d},
  1875. X{"sys/ttycom.h",    "TIOCPKT",    0x80047470},
  1876. X{"sys/ttycom.h",    "TIOCSPGRP",    0x80047476},
  1877. X{"sys/ttold.h",    "TIOCLSET",    0x8004747d},
  1878. X{"sys/ttold.h",    "TIOCLBIC",    0x8004747e},
  1879. X{"sys/ttold.h",    "TIOCLBIS",    0x8004747f},
  1880. X{"sys/ttycom.h",    "TIOCSETPGRP",    0x80047482},
  1881. X{"sundev/vuid_event.h",    "VUIDSFORMAT",    0x80047601},
  1882. X{"sys/vcmd.h",    "VSETSTATE",    0x80047601},
  1883. X{"sundev/vuid_event.h",    "VUIDSADDR",    0x80047603},
  1884. X{"scsi/targets/srdef.h",    "CDROMPLAYMSF",    0x8006630c},
  1885. X{"sundev/srreg.h",    "CDROMPLAYMSF",    0x8006630c},
  1886. X{"sun/dkio.h",    "DKIOCSTYPE",    0x8006647d},
  1887. X{"sys/ttold.h",    "TIOCSETP",    0x80067409},
  1888. X{"sys/ttold.h",    "TIOCSETN",    0x8006740a},
  1889. X{"sys/ttold.h",    "TIOCSETC",    0x80067411},
  1890. X{"sys/ttold.h",    "TIOCSLTC",    0x80067475},
  1891. X{"sun/isdnio.h",    "ISDN_SET_LOOPBACK",    0x8008410e},
  1892. X{"sun/isdnio.h",    "ISDN_RESET_LOOPBACK",    0x8008410f},
  1893. X{"sundev/lightpenreg.h",    "LIGHTPEN_CALIBRATE",    0x80084c01},
  1894. X{"sun/tvio.h",    "TVIOSPOS",    0x8008581c},
  1895. X{"sun/dkio.h",    "DKIOCSPART",    0x80086405},
  1896. X{"sun/dkio.h",    "FDKSETSEARCH",    0x8008646b},
  1897. X{"sunwindow/win_ioctl.h",    "WINSETLINK",    0x80086701},
  1898. X{"sunwindow/win_ioctl.h",    "WINSETRECT",    0x8008670b},
  1899. X{"sunwindow/win_ioctl.h",    "WINSETSAVEDRECT",    0x8008670c},
  1900. X{"sunwindow/win_ioctl.h",    "WINPARTIALREPAIR",    0x8008672b},
  1901. X{"sunwindow/win_ioctl.h",    "WINSETEVENTTIMEOUT",    0x8008673b},
  1902. X{"sunwindow/win_ioctl.h",    "WINDBLSET",    0x8008674b},
  1903. X{"sunwindow/win_ioctl.h",    "WINSETPLAYINTR",    0x800867cc},
  1904. X{"sys/mtio.h",    "MTIOCTOP",    0x80086d01},
  1905. X{"net/nit_buf.h",    "NIOCSTIME",    0x80087006},
  1906. X{"sbusdev/gtreg.h",    "FB_VMBACK",    0x80087415},
  1907. X{"sbusdev/gtreg.h",    "FB_VMUNBACK",    0x80087416},
  1908. X{"sbusdev/gtreg.h",    "FB_SETLIGHTPENPARAM",    0x8008741a},
  1909. X{"sbusdev/gtreg.h",    "FB_SETGAMMA",    0x8008741f},
  1910. X{"sys/ttycom.h",    "TIOCSSIZE",    0x80087425},
  1911. X{"sys/ttold.h",    "_O_TIOCSSIZE",    0x80087467},
  1912. X{"sys/ttycom.h",    "TIOCSWINSZ",    0x80087467},
  1913. X{"sun/isdnio.h",    "ISDN_SET_PARAM",    0x800c4110},
  1914. X{"sun/fbio.h",    "FBIO_WID_FREE",    0x800c461f},
  1915. X{"sun/fbio.h",    "FBIO_WID_PUT",    0x800c4620},
  1916. X{"sun/fbio.h",    "FBIO_WID_GET",    0x800c4621},
  1917. X{"sundev/lightpenreg.h",    "LIGHTPEN_FILTER",    0x800c4c02},
  1918. X{"sundev/fdreg.h",    "V_FORMAT",    0x800c5605},
  1919. X{"sundev/srreg.h",    "CDROMREADMODE2",    0x800c636e},
  1920. X{"sundev/srreg.h",    "CDROMREADMODE1",    0x800c636f},
  1921. X{"sunwindow/win_ioctl.h",    "WINSETCURSOR",    0x800c6707},
  1922. X{"sunwindow/win_ioctl.h",    "WINSETFOCUSEVENT",    0x800c6746},
  1923. X{"sunwindow/win_ioctl.h",    "WINSETSWALLOWEVENT",    0x800c6748},
  1924. X{"sundev/msio.h",    "MSIOSETPARMS",    0x800c6d03},
  1925. X{"sbusdev/gtreg.h",    "FB_CLUTFREE",    0x800c7402},
  1926. X{"sbusdev/gtreg.h",    "FB_VMCTL",    0x800c741e},
  1927. X{"pixrect/cg8var.h",    "PIPIO_S_EMULATION_MODE",    0x800e5804},
  1928. X{"sunwindow/win_ioctl.h",    "WINSCREENPOSITIONS",    0x8010672b},
  1929. X{"sundev/kbio.h",    "KIOCSETKEY",    0x80106b01},
  1930. X{"sun/ndio.h",    "NDIOCETHER",    0x80106e08},
  1931. X{"sys/termio.h",    "TCSETA",    0x80125402},
  1932. X{"termio.h",    "TCSETA",    0x80125402},
  1933. X{"sys/termio.h",    "TCSETAW",    0x80125403},
  1934. X{"termio.h",    "TCSETAW",    0x80125403},
  1935. X{"sys/termio.h",    "TCSETAF",    0x80125404},
  1936. X{"termio.h",    "TCSETAF",    0x80125404},
  1937. X{"sun/fbio.h",    "FBIOPUTCMAP",    0x80144603},
  1938. X{"sun/fbio.h",    "FBIOGETCMAP",    0x80144604},
  1939. X{"sunwindow/win_ioctl.h",    "WINSETAVAILPLANEGROUPS",    0x80146741},
  1940. X{"sunwindow/win_ioctl.h",    "WINSETSYNCPT",    0x801467cd},
  1941. X{"sundev/kbio.h",    "KIOCSKEY",    0x80146b0c},
  1942. X{"sun/fbio.h",    "FBIODBLSINFO",    0x80184613},
  1943. X{"sun/gpio.h",    "GP1IO_PUT_INFO",    0x80184700},
  1944. X{"sun/dkio.h",    "DKIOCSCMD",    0x80186477},
  1945. X{"sunwindow/win_ioctl.h",    "WINSETINPUTDEV",    0x80186732},
  1946. X{"sun/ndio.h",    "NDIOCUSER",    0x80186e03},
  1947. X{"sun/fbio.h",    "FBIOPUTCMAPI",    0x801c4629},
  1948. X{"sun/fbio.h",    "FBIOGETCMAPI",    0x801c462a},
  1949. X{"sun/dkio.h",    "FDKIOSCHAR",    0x801c6471},
  1950. X{"sbusdev/gtreg.h",    "FB_CLUTPOST",    0x801c7404},
  1951. X{"sbusdev/bpp_io.h",    "BPPIOC_SETPARMS",    0x80206201},
  1952. X{"sys/sockio.h",    "SIOCSIFADDR",    0x8020690c},
  1953. X{"sys/sockio.h",    "SIOCSIFDSTADDR",    0x8020690e},
  1954. X{"sys/sockio.h",    "SIOCSIFFLAGS",    0x80206910},
  1955. X{"sys/sockio.h",    "SIOCSIFMEM",    0x80206912},
  1956. X{"sys/sockio.h",    "SIOCSIFMTU",    0x80206915},
  1957. X{"sys/sockio.h",    "SIOCSIFBRDADDR",    0x80206918},
  1958. X{"sys/sockio.h",    "SIOCSIFNETMASK",    0x8020691a},
  1959. X{"sys/sockio.h",    "SIOCSIFMETRIC",    0x8020691c},
  1960. X{"sys/sockio.h",    "SIOCUPPER",    0x80206928},
  1961. X{"sys/sockio.h",    "SIOCLOWER",    0x80206929},
  1962. X{"sys/sockio.h",    "SIOCSETSYNC",    0x8020692c},
  1963. X{"sys/sockio.h",    "SIOCADDMULTI",    0x80206931},
  1964. X{"sys/sockio.h",    "SIOCDELMULTI",    0x80206932},
  1965. X{"sys/sockio.h",    "SIOCFDRESET",    0x80206933},
  1966. X{"sys/sockio.h",    "SIOCFDSLEEP",    0x80206934},
  1967. X{"sys/sockio.h",    "SIOCLDNSTRTFW",    0x80206936},
  1968. X{"sys/sockio.h",    "SIOCGETFDSTAT",    0x80206937},
  1969. X{"sys/sockio.h",    "SIOCFDNMIINT",    0x80206938},
  1970. X{"sys/sockio.h",    "SIOCFDEXUSER",    0x80206939},
  1971. X{"sys/sockio.h",    "SIOCFDGNETMAP",    0x8020693a},
  1972. X{"sys/sockio.h",    "SIOCFDGIOCTL",    0x8020693b},
  1973. X{"net/nit_if.h",    "NIOCBIND",    0x80207003},
  1974. X{"sbusdev/gtreg.h",    "FB_GT_SETVERSION",    0x80207428},
  1975. X{"sys/stropts.h",    "I_FDINSERT",    0x80245310},
  1976. X{"stropts.h",    "I_FDINSERT",    0x80245310},
  1977. X{"termios.h",    "TCSETS",    0x80245409},
  1978. X{"sys/termios.h",    "TCSETS",    0x80245409},
  1979. X{"termios.h",    "TCSETSW",    0x8024540a},
  1980. X{"sys/termios.h",    "TCSETSW",    0x8024540a},
  1981. X{"termios.h",    "TCSETSF",    0x8024540b},
  1982. X{"sys/termios.h",    "TCSETSF",    0x8024540b},
  1983. X{"sys/sockio.h",    "SIOCSARP",    0x8024691e},
  1984. X{"sys/sockio.h",    "SIOCDARP",    0x80246920},
  1985. X{"sys/sockio.h",    "SIOCSNIT",    0x80247000},
  1986. X{"sun/dkio.h",    "DKIOCSGEOM",    0x80266403},
  1987. X{"sun/fbio.h",    "FBIOSATTR",    0x80284605},
  1988. X{"sun/fbio.h",    "FBIOSCURSOR",    0x802c4618},
  1989. X{"sunwindow/win_ioctl.h",    "WINSETLOCATOR",    0x80306730},
  1990. X{"sunwindow/win_ioctl.h",    "WINSETCPCURSOR",    0x80306796},
  1991. X{"sbusdev/audio_79C30.h",    "AUDIOSETREG",    0x80306902},
  1992. X{"sys/sockio.h",    "SIOCADDRT",    0x8030720a},
  1993. X{"sys/sockio.h",    "SIOCDELRT",    0x8030720b},
  1994. X{"sunwindow/win_ioctl.h",    "WINSETKBDMASK",    0x80346736},
  1995. X{"sunwindow/win_ioctl.h",    "WINSETPICKMASK",    0x80346737},
  1996. X{"sun/dkio.h",    "FDKSETDRIVECHAR",    0x8038646d},
  1997. X{"sun/tvio.h",    "TVIOSVIDEOCAL",    0x80405832},
  1998. X{"sun/tvio.h",    "TVIONVWRITE",    0x80405834},
  1999. X{"sun/dkio.h",    "DKIOCSAPART",    0x8040647b},
  2000. X{"sunwindow/win_ioctl.h",    "WINSETSCALING",    0x80406727},
  2001. X{"net/nit_pf.h",    "NIOCSETF",    0x80527002},
  2002. X{"pixrect/gp1var.h",    "GP1IO_SATTR",    0x80584765},
  2003. X{"sunwindow/win_ioctl.h",    "WINSETINPUTMASK",    0x806c6714},
  2004. X{"sunwindow/win_ioctl.h",    "WINSCREENNEW",    0x80706728},
  2005. X{"sunwindow/win_ioctl.h",    "WINSETKBD",    0x8070672e},
  2006. X{"sunwindow/win_ioctl.h",    "WINSETMS",    0x8070672f},
  2007. END_OF_FILE
  2008.   if test 22969 -ne `wc -c <'strace-3.0/sunos4/ioctlent.h'`; then
  2009.     echo shar: \"'strace-3.0/sunos4/ioctlent.h'\" unpacked with wrong size!
  2010.   fi
  2011.   # end of 'strace-3.0/sunos4/ioctlent.h'
  2012. fi
  2013. if test -f 'strace-3.0/syscallent.sh' -a "${1}" != "-c" ; then 
  2014.   echo shar: Will not clobber existing file \"'strace-3.0/syscallent.sh'\"
  2015. else
  2016.   echo shar: Extracting \"'strace-3.0/syscallent.sh'\" \(2733 characters\)
  2017.   sed "s/^X//" >'strace-3.0/syscallent.sh' <<'END_OF_FILE'
  2018. X#!/bin/sh
  2019. X# Copyright (c) 1993, 1994 Rick Sladkey <jrs@world.std.com>
  2020. X# All rights reserved.
  2021. X#
  2022. X# Redistribution and use in source and binary forms, with or without
  2023. X# modification, are permitted provided that the following conditions
  2024. X# are met:
  2025. X# 1. Redistributions of source code must retain the above copyright
  2026. X#    notice, this list of conditions and the following disclaimer.
  2027. X# 2. Redistributions in binary form must reproduce the above copyright
  2028. X#    notice, this list of conditions and the following disclaimer in the
  2029. X#    documentation and/or other materials provided with the distribution.
  2030. X# 3. All advertising materials mentioning features or use of this software
  2031. X#    must display the following acknowledgement:
  2032. X#      This product includes software developed by Paul Kranenburg,
  2033. X#      Branko Lankester and Rick Sladkey.
  2034. X# 4. The name of the author may not be used to endorse or promote products
  2035. X#    derived from this software without specific prior written permission.
  2036. X#
  2037. X# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  2038. X# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  2039. X# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  2040. X# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  2041. X# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  2042. X# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2043. X# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2044. X# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2045. X# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  2046. X# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2047. X#
  2048. X#    syscallent.sh,v 2.18 1994/03/12 23:11:59 jrs Exp
  2049. X
  2050. Xcat $* |
  2051. X    sed -n 's/^#[     ]*define[     ][     ]*SYS_\([^     ]*\)[     ]*\([0-9]*\)/\1 \2/p' |
  2052. X    sort +1n |
  2053. X    awk '
  2054. X    BEGIN {
  2055. X        tabs = "\t\t\t\t\t\t\t\t"
  2056. X        call = -1;
  2057. X    }
  2058. X    {
  2059. X        while (++call < $2) {
  2060. X            f = "printargs"
  2061. X            n = "SYS_" call
  2062. X            s = "\t{ -1,\t"
  2063. X            s = s f ","
  2064. X            s = s substr(tabs, 1, 24/8 - int((length(f) + 1)/8))
  2065. X            s = s "\"" n "\""
  2066. X            s = s substr(tabs, 1, 16/8 - int((length(n) + 2)/8))
  2067. X            s = s "},\t/* " call " */"
  2068. X            print s
  2069. X        }
  2070. X        f = "sys_" $1
  2071. X        n = $1
  2072. X        s = "\t{ -1,\t"
  2073. X        s = s f ","
  2074. X        s = s substr(tabs, 1, 24/8 - int((length(f) + 1)/8))
  2075. X        s = s "\"" n "\""
  2076. X        s = s substr(tabs, 1, 16/8 - int((length(n) + 2)/8))
  2077. X        s = s "},\t/* " call " */"
  2078. X        print s
  2079. X    }
  2080. X    END {
  2081. X        limit = call + 100
  2082. X        while (++call < limit) {
  2083. X            f = "printargs"
  2084. X            n = "SYS_" call
  2085. X            s = "\t{ -1,\t"
  2086. X            s = s f ","
  2087. X            s = s substr(tabs, 1, 24/8 - int((length(f) + 1)/8))
  2088. X            s = s "\"" n "\""
  2089. X            s = s substr(tabs, 1, 16/8 - int((length(n) + 2)/8))
  2090. X            s = s "},\t/* " call " */"
  2091. X            print s
  2092. X        }
  2093. X    }
  2094. X    '
  2095. END_OF_FILE
  2096.   if test 2733 -ne `wc -c <'strace-3.0/syscallent.sh'`; then
  2097.     echo shar: \"'strace-3.0/syscallent.sh'\" unpacked with wrong size!
  2098.   fi
  2099.   # end of 'strace-3.0/syscallent.sh'
  2100. fi
  2101. echo shar: End of archive 2 \(of 10\).
  2102. cp /dev/null ark2isdone
  2103. MISSING=""
  2104. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  2105.     if test ! -f ark${I}isdone ; then
  2106.     MISSING="${MISSING} ${I}"
  2107.     fi
  2108. done
  2109. if test "${MISSING}" = "" ; then
  2110.     echo You have unpacked all 10 archives.
  2111.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2112. else
  2113.     echo You still must unpack the following archives:
  2114.     echo "        " ${MISSING}
  2115. fi
  2116. exit 0
  2117. exit 0 # Just in case...
  2118.