<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - strace-5.15.0.11.7c5c-dirty - src/strace.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - strace.c<span style="font-size: 80%;"> (source / <a href="strace.c.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">strace-5.15.0.11.7c5c-dirty</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">1468</td>
            <td class="headerCovTableEntry">1632</td>
            <td class="headerCovTableEntryMed">89.95 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2021-12-29 11:55:56</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">73</td>
            <td class="headerCovTableEntry">74</td>
            <td class="headerCovTableEntryHi">98.65 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
            | Branches:
            <span class="coverLegendCov">+</span> taken
            <span class="coverLegendNoCov">-</span> not taken
            <span class="coverLegendNoCov">#</span> not executed
</td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">887</td>
            <td class="headerCovTableEntry">1132</td>
            <td class="headerCovTableEntryMed">78.36 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /*</a>
<a name="2"><span class="lineNum">       2 </span>                :            :  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl></a>
<a name="3"><span class="lineNum">       3 </span>                :            :  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl></a>
<a name="4"><span class="lineNum">       4 </span>                :            :  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com></a>
<a name="5"><span class="lineNum">       5 </span>                :            :  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl></a>
<a name="6"><span class="lineNum">       6 </span>                :            :  * Copyright (c) 1999-2021 The strace developers.</a>
<a name="7"><span class="lineNum">       7 </span>                :            :  * All rights reserved.</a>
<a name="8"><span class="lineNum">       8 </span>                :            :  *</a>
<a name="9"><span class="lineNum">       9 </span>                :            :  * SPDX-License-Identifier: LGPL-2.1-or-later</a>
<a name="10"><span class="lineNum">      10 </span>                :            :  */</a>
<a name="11"><span class="lineNum">      11 </span>                :            : </a>
<a name="12"><span class="lineNum">      12 </span>                :            : #include "defs.h"</a>
<a name="13"><span class="lineNum">      13 </span>                :            : #include <stdarg.h></a>
<a name="14"><span class="lineNum">      14 </span>                :            : #include <limits.h></a>
<a name="15"><span class="lineNum">      15 </span>                :            : #include <fcntl.h></a>
<a name="16"><span class="lineNum">      16 </span>                :            : #include "ptrace.h"</a>
<a name="17"><span class="lineNum">      17 </span>                :            : #include <signal.h></a>
<a name="18"><span class="lineNum">      18 </span>                :            : #include <sys/resource.h></a>
<a name="19"><span class="lineNum">      19 </span>                :            : #include <sys/stat.h></a>
<a name="20"><span class="lineNum">      20 </span>                :            : #ifdef HAVE_PATHS_H</a>
<a name="21"><span class="lineNum">      21 </span>                :            : # include <paths.h></a>
<a name="22"><span class="lineNum">      22 </span>                :            : #endif</a>
<a name="23"><span class="lineNum">      23 </span>                :            : #include <getopt.h></a>
<a name="24"><span class="lineNum">      24 </span>                :            : #include <pwd.h></a>
<a name="25"><span class="lineNum">      25 </span>                :            : #include <grp.h></a>
<a name="26"><span class="lineNum">      26 </span>                :            : #include <dirent.h></a>
<a name="27"><span class="lineNum">      27 </span>                :            : #include <locale.h></a>
<a name="28"><span class="lineNum">      28 </span>                :            : #include <sys/utsname.h></a>
<a name="29"><span class="lineNum">      29 </span>                :            : #include <sys/prctl.h></a>
<a name="30"><span class="lineNum">      30 </span>                :            : </a>
<a name="31"><span class="lineNum">      31 </span>                :            : #include "kill_save_errno.h"</a>
<a name="32"><span class="lineNum">      32 </span>                :            : #include "filter_seccomp.h"</a>
<a name="33"><span class="lineNum">      33 </span>                :            : #include "largefile_wrappers.h"</a>
<a name="34"><span class="lineNum">      34 </span>                :            : #include "mmap_cache.h"</a>
<a name="35"><span class="lineNum">      35 </span>                :            : #include "number_set.h"</a>
<a name="36"><span class="lineNum">      36 </span>                :            : #include "ptrace_syscall_info.h"</a>
<a name="37"><span class="lineNum">      37 </span>                :            : #include "scno.h"</a>
<a name="38"><span class="lineNum">      38 </span>                :            : #include "printsiginfo.h"</a>
<a name="39"><span class="lineNum">      39 </span>                :            : #include "trace_event.h"</a>
<a name="40"><span class="lineNum">      40 </span>                :            : #include "xstring.h"</a>
<a name="41"><span class="lineNum">      41 </span>                :            : #include "delay.h"</a>
<a name="42"><span class="lineNum">      42 </span>                :            : #include "wait.h"</a>
<a name="43"><span class="lineNum">      43 </span>                :            : #include "secontext.h"</a>
<a name="44"><span class="lineNum">      44 </span>                :            : </a>
<a name="45"><span class="lineNum">      45 </span>                :            : /* In some libc, these aren't declared. Do it ourself: */</a>
<a name="46"><span class="lineNum">      46 </span>                :            : extern char **environ;</a>
<a name="47"><span class="lineNum">      47 </span>                :            : extern int optind;</a>
<a name="48"><span class="lineNum">      48 </span>                :            : extern char *optarg;</a>
<a name="49"><span class="lineNum">      49 </span>                :            : </a>
<a name="50"><span class="lineNum">      50 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="51"><span class="lineNum">      51 </span>                :            : /* if this is true do the stack trace for every system call */</a>
<a name="52"><span class="lineNum">      52 </span>                :            : bool stack_trace_enabled;</a>
<a name="53"><span class="lineNum">      53 </span>                :            : #endif</a>
<a name="54"><span class="lineNum">      54 </span>                :            : </a>
<a name="55"><span class="lineNum">      55 </span>                :            : #define my_tkill(tid, sig) syscall(__NR_tkill, (tid), (sig))</a>
<a name="56"><span class="lineNum">      56 </span>                :            : </a>
<a name="57"><span class="lineNum">      57 </span>                :            : /* Glue for systems without a MMU that cannot provide fork() */</a>
<a name="58"><span class="lineNum">      58 </span>                :            : #if !defined(HAVE_FORK)</a>
<a name="59"><span class="lineNum">      59 </span>                :            : # undef NOMMU_SYSTEM</a>
<a name="60"><span class="lineNum">      60 </span>                :            : # define NOMMU_SYSTEM 1</a>
<a name="61"><span class="lineNum">      61 </span>                :            : #endif</a>
<a name="62"><span class="lineNum">      62 </span>                :            : #if NOMMU_SYSTEM</a>
<a name="63"><span class="lineNum">      63 </span>                :            : # define fork() vfork()</a>
<a name="64"><span class="lineNum">      64 </span>                :            : #endif</a>
<a name="65"><span class="lineNum">      65 </span>                :            : </a>
<a name="66"><span class="lineNum">      66 </span>                :            : const unsigned int syscall_trap_sig = SIGTRAP | 0x80;</a>
<a name="67"><span class="lineNum">      67 </span>                :            : </a>
<a name="68"><span class="lineNum">      68 </span>                :            : cflag_t cflag = CFLAG_NONE;</a>
<a name="69"><span class="lineNum">      69 </span>                :            : bool followfork;</a>
<a name="70"><span class="lineNum">      70 </span>                :            : bool output_separately;</a>
<a name="71"><span class="lineNum">      71 </span>                :            : unsigned int ptrace_setoptions = PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC</a>
<a name="72"><span class="lineNum">      72 </span>                :            :                                  | PTRACE_O_TRACEEXIT;</a>
<a name="73"><span class="lineNum">      73 </span>                :            : static struct xlat_data xflag_str[] = {</a>
<a name="74"><span class="lineNum">      74 </span>                :            :         { HEXSTR_NONE,                  "none" },</a>
<a name="75"><span class="lineNum">      75 </span>                :            :         { HEXSTR_NON_ASCII_CHARS,       "non-ascii-chars" },</a>
<a name="76"><span class="lineNum">      76 </span>                :            :         { HEXSTR_NON_ASCII,             "non-ascii" },</a>
<a name="77"><span class="lineNum">      77 </span>                :            :         { HEXSTR_ALL,                   "all" },</a>
<a name="78"><span class="lineNum">      78 </span>                :            : };</a>
<a name="79"><span class="lineNum">      79 </span>                :            : unsigned int xflag;</a>
<a name="80"><span class="lineNum">      80 </span>                :            : bool debug_flag;</a>
<a name="81"><span class="lineNum">      81 </span>                :            : bool Tflag;</a>
<a name="82"><span class="lineNum">      82 </span>                :            : int Tflag_scale = 1000;</a>
<a name="83"><span class="lineNum">      83 </span>                :            : int Tflag_width = 6;</a>
<a name="84"><span class="lineNum">      84 </span>                :            : bool iflag;</a>
<a name="85"><span class="lineNum">      85 </span>                :            : bool nflag;</a>
<a name="86"><span class="lineNum">      86 </span>                :            : bool count_wallclock;</a>
<a name="87"><span class="lineNum">      87 </span>                :            : static int tflag_scale = 1000000000;</a>
<a name="88"><span class="lineNum">      88 </span>                :            : static unsigned tflag_width = 0;</a>
<a name="89"><span class="lineNum">      89 </span>                :            : static const char *tflag_format = NULL;</a>
<a name="90"><span class="lineNum">      90 </span>                :            : static bool rflag;</a>
<a name="91"><span class="lineNum">      91 </span>                :            : static int rflag_scale = 1000;</a>
<a name="92"><span class="lineNum">      92 </span>                :            : static int rflag_width = 6;</a>
<a name="93"><span class="lineNum">      93 </span>                :            : static bool print_pid_pfx;</a>
<a name="94"><span class="lineNum">      94 </span>                :            : </a>
<a name="95"><span class="lineNum">      95 </span>                :            : /* -I n */</a>
<a name="96"><span class="lineNum">      96 </span>                :            : enum {</a>
<a name="97"><span class="lineNum">      97 </span>                :            :         INTR_NOT_SET        = 0,</a>
<a name="98"><span class="lineNum">      98 </span>                :            :         INTR_ANYWHERE       = 1, /* don't block/ignore any signals */</a>
<a name="99"><span class="lineNum">      99 </span>                :            :         INTR_WHILE_WAIT     = 2, /* block fatal signals while decoding syscall. default */</a>
<a name="100"><span class="lineNum">     100 </span>                :            :         INTR_NEVER          = 3, /* block fatal signals. default if '-o FILE PROG' */</a>
<a name="101"><span class="lineNum">     101 </span>                :            :         INTR_BLOCK_TSTP_TOO = 4, /* block fatal signals and SIGTSTP (^Z); default if -D */</a>
<a name="102"><span class="lineNum">     102 </span>                :            :         NUM_INTR_OPTS</a>
<a name="103"><span class="lineNum">     103 </span>                :            : };</a>
<a name="104"><span class="lineNum">     104 </span>                :            : static int opt_intr;</a>
<a name="105"><span class="lineNum">     105 </span>                :            : /* We play with signal mask only if this mode is active: */</a>
<a name="106"><span class="lineNum">     106 </span>                :            : #define interactive (opt_intr == INTR_WHILE_WAIT)</a>
<a name="107"><span class="lineNum">     107 </span>                :            : </a>
<a name="108"><span class="lineNum">     108 </span>                :            : enum {</a>
<a name="109"><span class="lineNum">     109 </span>                :            :         DAEMONIZE_NONE        = 0,</a>
<a name="110"><span class="lineNum">     110 </span>                :            :         DAEMONIZE_GRANDCHILD  = 1,</a>
<a name="111"><span class="lineNum">     111 </span>                :            :         DAEMONIZE_NEW_PGROUP  = 2,</a>
<a name="112"><span class="lineNum">     112 </span>                :            :         DAEMONIZE_NEW_SESSION = 3,</a>
<a name="113"><span class="lineNum">     113 </span>                :            : </a>
<a name="114"><span class="lineNum">     114 </span>                :            :         DAEMONIZE_OPTS_GUARD__,</a>
<a name="115"><span class="lineNum">     115 </span>                :            :         MAX_DAEMONIZE_OPTS    = DAEMONIZE_OPTS_GUARD__ - 1</a>
<a name="116"><span class="lineNum">     116 </span>                :            : };</a>
<a name="117"><span class="lineNum">     117 </span>                :            : static struct xlat_data daemonize_str[] = {</a>
<a name="118"><span class="lineNum">     118 </span>                :            :         { DAEMONIZE_GRANDCHILD,         "grandchild" },</a>
<a name="119"><span class="lineNum">     119 </span>                :            :         { DAEMONIZE_NEW_PGROUP,         "pgroup" },</a>
<a name="120"><span class="lineNum">     120 </span>                :            :         { DAEMONIZE_NEW_PGROUP,         "pgrp" },</a>
<a name="121"><span class="lineNum">     121 </span>                :            :         { DAEMONIZE_NEW_SESSION,        "session" },</a>
<a name="122"><span class="lineNum">     122 </span>                :            : };</a>
<a name="123"><span class="lineNum">     123 </span>                :            : /*</a>
<a name="124"><span class="lineNum">     124 </span>                :            :  * daemonized_tracer supports -D option.</a>
<a name="125"><span class="lineNum">     125 </span>                :            :  * With this option, strace forks twice.</a>
<a name="126"><span class="lineNum">     126 </span>                :            :  * Unlike normal case, with -D *grandparent* process exec's,</a>
<a name="127"><span class="lineNum">     127 </span>                :            :  * becoming a traced process. Child exits (this prevents traced process</a>
<a name="128"><span class="lineNum">     128 </span>                :            :  * from having children it doesn't expect to have), and grandchild</a>
<a name="129"><span class="lineNum">     129 </span>                :            :  * attaches to grandparent similarly to strace -p PID.</a>
<a name="130"><span class="lineNum">     130 </span>                :            :  * This allows for more transparent interaction in cases</a>
<a name="131"><span class="lineNum">     131 </span>                :            :  * when process and its parent are communicating via signals,</a>
<a name="132"><span class="lineNum">     132 </span>                :            :  * wait() etc. Without -D, strace process gets lodged in between,</a>
<a name="133"><span class="lineNum">     133 </span>                :            :  * disrupting parent<->child link.</a>
<a name="134"><span class="lineNum">     134 </span>                :            :  */</a>
<a name="135"><span class="lineNum">     135 </span>                :            : static unsigned int daemonized_tracer;</a>
<a name="136"><span class="lineNum">     136 </span>                :            : </a>
<a name="137"><span class="lineNum">     137 </span>                :            : static int post_attach_sigstop = TCB_IGNORE_ONE_SIGSTOP;</a>
<a name="138"><span class="lineNum">     138 </span>                :            : #define use_seize (post_attach_sigstop == 0)</a>
<a name="139"><span class="lineNum">     139 </span>                :            : </a>
<a name="140"><span class="lineNum">     140 </span>                :            : static bool detach_on_execve;</a>
<a name="141"><span class="lineNum">     141 </span>                :            : </a>
<a name="142"><span class="lineNum">     142 </span>                :            : static int exit_code;</a>
<a name="143"><span class="lineNum">     143 </span>                :            : static int strace_child;</a>
<a name="144"><span class="lineNum">     144 </span>                :            : static int strace_tracer_pid;</a>
<a name="145"><span class="lineNum">     145 </span>                :            : </a>
<a name="146"><span class="lineNum">     146 </span>                :            : static const char *username;</a>
<a name="147"><span class="lineNum">     147 </span>                :            : static uid_t run_uid;</a>
<a name="148"><span class="lineNum">     148 </span>                :            : static gid_t run_gid;</a>
<a name="149"><span class="lineNum">     149 </span>                :            : </a>
<a name="150"><span class="lineNum">     150 </span>                :            : unsigned int max_strlen = DEFAULT_STRLEN;</a>
<a name="151"><span class="lineNum">     151 </span>                :            : static int acolumn = DEFAULT_ACOLUMN;</a>
<a name="152"><span class="lineNum">     152 </span>                :            : static char *acolumn_spaces;</a>
<a name="153"><span class="lineNum">     153 </span>                :            : </a>
<a name="154"><span class="lineNum">     154 </span>                :            : /* Default output style for xlat entities */</a>
<a name="155"><span class="lineNum">     155 </span>                :            : enum xlat_style xlat_verbosity = XLAT_STYLE_ABBREV;</a>
<a name="156"><span class="lineNum">     156 </span>                :            : </a>
<a name="157"><span class="lineNum">     157 </span>                :            : static const char *outfname;</a>
<a name="158"><span class="lineNum">     158 </span>                :            : /* If -ff, points to stderr. Else, it's our common output log */</a>
<a name="159"><span class="lineNum">     159 </span>                :            : static FILE *shared_log;</a>
<a name="160"><span class="lineNum">     160 </span>                :            : static bool open_append;</a>
<a name="161"><span class="lineNum">     161 </span>                :            : </a>
<a name="162"><span class="lineNum">     162 </span>                :            : struct tcb *printing_tcp;</a>
<a name="163"><span class="lineNum">     163 </span>                :            : static struct tcb *current_tcp;</a>
<a name="164"><span class="lineNum">     164 </span>                :            : </a>
<a name="165"><span class="lineNum">     165 </span>                :            : struct tcb_wait_data {</a>
<a name="166"><span class="lineNum">     166 </span>                :            :         enum trace_event te; /**< Event passed to dispatch_event() */</a>
<a name="167"><span class="lineNum">     167 </span>                :            :         int status;          /**< status, returned by wait4() */</a>
<a name="168"><span class="lineNum">     168 </span>                :            :         unsigned long msg;   /**< Value returned by PTRACE_GETEVENTMSG */</a>
<a name="169"><span class="lineNum">     169 </span>                :            :         siginfo_t si;        /**< siginfo, returned by PTRACE_GETSIGINFO */</a>
<a name="170"><span class="lineNum">     170 </span>                :            : };</a>
<a name="171"><span class="lineNum">     171 </span>                :            : </a>
<a name="172"><span class="lineNum">     172 </span>                :            : static struct tcb **tcbtab;</a>
<a name="173"><span class="lineNum">     173 </span>                :            : static unsigned int nprocs;</a>
<a name="174"><span class="lineNum">     174 </span>                :            : static size_t tcbtabsize;</a>
<a name="175"><span class="lineNum">     175 </span>                :            : </a>
<a name="176"><span class="lineNum">     176 </span>                :            : static struct tcb_wait_data *tcb_wait_tab;</a>
<a name="177"><span class="lineNum">     177 </span>                :            : static size_t tcb_wait_tab_size;</a>
<a name="178"><span class="lineNum">     178 </span>                :            : </a>
<a name="179"><span class="lineNum">     179 </span>                :            : </a>
<a name="180"><span class="lineNum">     180 </span>                :            : #ifndef HAVE_PROGRAM_INVOCATION_NAME</a>
<a name="181"><span class="lineNum">     181 </span>                :            : char *program_invocation_name;</a>
<a name="182"><span class="lineNum">     182 </span>                :            : #endif</a>
<a name="183"><span class="lineNum">     183 </span>                :            : </a>
<a name="184"><span class="lineNum">     184 </span>                :            : unsigned os_release; /* generated from uname()'s u.release */</a>
<a name="185"><span class="lineNum">     185 </span>                :            : </a>
<a name="186"><span class="lineNum">     186 </span>                :            : static void detach(struct tcb *tcp);</a>
<a name="187"><span class="lineNum">     187 </span>                :            : static void cleanup(int sig);</a>
<a name="188"><span class="lineNum">     188 </span>                :            : static void interrupt(int sig);</a>
<a name="189"><span class="lineNum">     189 </span>                :            : </a>
<a name="190"><span class="lineNum">     190 </span>                :            : #ifdef HAVE_SIG_ATOMIC_T</a>
<a name="191"><span class="lineNum">     191 </span>                :            : static volatile sig_atomic_t interrupted, restart_failed;</a>
<a name="192"><span class="lineNum">     192 </span>                :            : #else</a>
<a name="193"><span class="lineNum">     193 </span>                :            : static volatile int interrupted, restart_failed;</a>
<a name="194"><span class="lineNum">     194 </span>                :            : #endif</a>
<a name="195"><span class="lineNum">     195 </span>                :            : </a>
<a name="196"><span class="lineNum">     196 </span>                :            : static sigset_t timer_set;</a>
<a name="197"><span class="lineNum">     197 </span>                :            : static void timer_sighandler(int);</a>
<a name="198"><span class="lineNum">     198 </span>                :            : </a>
<a name="199"><span class="lineNum">     199 </span>                :            : #ifndef HAVE_STRERROR</a>
<a name="200"><span class="lineNum">     200 </span>                :            : </a>
<a name="201"><span class="lineNum">     201 </span>                :            : # if !HAVE_DECL_SYS_ERRLIST</a>
<a name="202"><span class="lineNum">     202 </span>                :            : extern int sys_nerr;</a>
<a name="203"><span class="lineNum">     203 </span>                :            : extern char *sys_errlist[];</a>
<a name="204"><span class="lineNum">     204 </span>                :            : # endif</a>
<a name="205"><span class="lineNum">     205 </span>                :            : </a>
<a name="206"><span class="lineNum">     206 </span>                :            : const char *</a>
<a name="207"><span class="lineNum">     207 </span>                :            : strerror(int err_no)</a>
<a name="208"><span class="lineNum">     208 </span>                :            : {</a>
<a name="209"><span class="lineNum">     209 </span>                :            :         static char buf[sizeof("Unknown error %d") + sizeof(int)*3];</a>
<a name="210"><span class="lineNum">     210 </span>                :            : </a>
<a name="211"><span class="lineNum">     211 </span>                :            :         if (err_no < 1 || err_no >= sys_nerr) {</a>
<a name="212"><span class="lineNum">     212 </span>                :            :                 xsprintf(buf, "Unknown error %d", err_no);</a>
<a name="213"><span class="lineNum">     213 </span>                :            :                 return buf;</a>
<a name="214"><span class="lineNum">     214 </span>                :            :         }</a>
<a name="215"><span class="lineNum">     215 </span>                :            :         return sys_errlist[err_no];</a>
<a name="216"><span class="lineNum">     216 </span>                :            : }</a>
<a name="217"><span class="lineNum">     217 </span>                :            : </a>
<a name="218"><span class="lineNum">     218 </span>                :            : #endif /* HAVE_STERRROR */</a>
<a name="219"><span class="lineNum">     219 </span>                :            : </a>
<a name="220"><span class="lineNum">     220 </span>                :            : static void</a>
<a name="221"><span class="lineNum">     221 </span>                :<span class="lineCov">       1182 : print_version(void)</span></a>
<a name="222"><span class="lineNum">     222 </span>                :            : {</a>
<a name="223"><span class="lineNum">     223 </span>                :<span class="lineCov">       1182 :         static const char features[] =</span></a>
<a name="224"><span class="lineNum">     224 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="225"><span class="lineNum">     225 </span>                :            :                 " stack-trace=" USE_UNWINDER</a>
<a name="226"><span class="lineNum">     226 </span>                :            : #endif</a>
<a name="227"><span class="lineNum">     227 </span>                :            : #ifdef USE_DEMANGLE</a>
<a name="228"><span class="lineNum">     228 </span>                :            :                 " stack-demangle"</a>
<a name="229"><span class="lineNum">     229 </span>                :            : #endif</a>
<a name="230"><span class="lineNum">     230 </span>                :            : #if SUPPORTED_PERSONALITIES > 1</a>
<a name="231"><span class="lineNum">     231 </span>                :            : # if defined HAVE_M32_MPERS</a>
<a name="232"><span class="lineNum">     232 </span>                :            :                 " m32-mpers"</a>
<a name="233"><span class="lineNum">     233 </span>                :            : # else</a>
<a name="234"><span class="lineNum">     234 </span>                :            :                 " no-m32-mpers"</a>
<a name="235"><span class="lineNum">     235 </span>                :            : # endif</a>
<a name="236"><span class="lineNum">     236 </span>                :            : #endif /* SUPPORTED_PERSONALITIES > 1 */</a>
<a name="237"><span class="lineNum">     237 </span>                :            : #if SUPPORTED_PERSONALITIES > 2</a>
<a name="238"><span class="lineNum">     238 </span>                :            : # if defined HAVE_MX32_MPERS</a>
<a name="239"><span class="lineNum">     239 </span>                :            :                 " mx32-mpers"</a>
<a name="240"><span class="lineNum">     240 </span>                :            : # else</a>
<a name="241"><span class="lineNum">     241 </span>                :            :                 " no-mx32-mpers"</a>
<a name="242"><span class="lineNum">     242 </span>                :            : # endif</a>
<a name="243"><span class="lineNum">     243 </span>                :            : #endif /* SUPPORTED_PERSONALITIES > 2 */</a>
<a name="244"><span class="lineNum">     244 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="245"><span class="lineNum">     245 </span>                :            :                 " secontext"</a>
<a name="246"><span class="lineNum">     246 </span>                :            : #endif</a>
<a name="247"><span class="lineNum">     247 </span>                :            :                 "";</a>
<a name="248"><span class="lineNum">     248 </span>                :            : </a>
<a name="249"><span class="lineNum">     249 </span>                :<span class="lineCov">       1182 :         printf("%s -- version %s\n"</span></a>
<a name="250"><span class="lineNum">     250 </span>                :            :                "Copyright (c) 1991-%s The strace developers <%s>.\n"</a>
<a name="251"><span class="lineNum">     251 </span>                :            :                "This is free software; see the source for copying conditions.  There is NO\n"</a>
<a name="252"><span class="lineNum">     252 </span>                :            :                "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",</a>
<a name="253"><span class="lineNum">     253 </span>                :            :                PACKAGE_NAME, PACKAGE_VERSION, COPYRIGHT_YEAR, PACKAGE_URL);</a>
<a name="254"><span class="lineNum">     254 </span>                :<span class="lineCov">       1182 :         printf("\nOptional features enabled:%s\n",</span></a>
<a name="255"><span class="lineNum">     255 </span>                :            :                features[0] ? features : " (none)");</a>
<a name="256"><span class="lineNum">     256 </span>                :<span class="lineCov">       1182 : }</span></a>
<a name="257"><span class="lineNum">     257 </span>                :            : </a>
<a name="258"><span class="lineNum">     258 </span>                :            : static void</a>
<a name="259"><span class="lineNum">     259 </span>                :<span class="lineCov">         16 : usage(void)</span></a>
<a name="260"><span class="lineNum">     260 </span>                :            : {</a>
<a name="261"><span class="lineNum">     261 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="262"><span class="lineNum">     262 </span>                :            : # define K_OPT "k"</a>
<a name="263"><span class="lineNum">     263 </span>                :            : #else</a>
<a name="264"><span class="lineNum">     264 </span>                :            : # define K_OPT ""</a>
<a name="265"><span class="lineNum">     265 </span>                :            : #endif</a>
<a name="266"><span class="lineNum">     266 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="267"><span class="lineNum">     267 </span>                :            : # define SECONTEXT_OPT "              [--secontext[=FORMAT]]\n"</a>
<a name="268"><span class="lineNum">     268 </span>                :            : # define SECONTEXT_E_QUAL ", secontext"</a>
<a name="269"><span class="lineNum">     269 </span>                :            : #else</a>
<a name="270"><span class="lineNum">     270 </span>                :            : # define SECONTEXT_OPT ""</a>
<a name="271"><span class="lineNum">     271 </span>                :            : # define SECONTEXT_E_QUAL ""</a>
<a name="272"><span class="lineNum">     272 </span>                :            : #endif</a>
<a name="273"><span class="lineNum">     273 </span>                :            : </a>
<a name="274"><span class="lineNum">     274 </span>                :<span class="lineCov">         16 :         printf("\</span></a>
<a name="275"><span class="lineNum">     275 </span>                :            : Usage: strace [-ACdffhi" K_OPT "qqrtttTvVwxxyyzZ] [-I N] [-b execve] [-e EXPR]...\n\</a>
<a name="276"><span class="lineNum">     276 </span>                :            :               [-a COLUMN] [-o FILE] [-s STRSIZE] [-X FORMAT] [-O OVERHEAD]\n\</a>
<a name="277"><span class="lineNum">     277 </span>                :            :               [-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]\n"\</a>
<a name="278"><span class="lineNum">     278 </span>                :            :               SECONTEXT_OPT "\</a>
<a name="279"><span class="lineNum">     279 </span>                :            :               { -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }\n\</a>
<a name="280"><span class="lineNum">     280 </span>                :            :    or: strace -c[dfwzZ] [-I N] [-b execve] [-e EXPR]... [-O OVERHEAD]\n\</a>
<a name="281"><span class="lineNum">     281 </span>                :            :               [-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]\n\</a>
<a name="282"><span class="lineNum">     282 </span>                :            :               { -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }\n\</a>
<a name="283"><span class="lineNum">     283 </span>                :            : \n\</a>
<a name="284"><span class="lineNum">     284 </span>                :            : General:\n\</a>
<a name="285"><span class="lineNum">     285 </span>                :            :   -e EXPR        a qualifying expression: OPTION=[!]all or OPTION=[!]VAL1[,VAL2]...\n\</a>
<a name="286"><span class="lineNum">     286 </span>                :            :      options:    trace, abbrev, verbose, raw, signal, read, write, fault,\n\</a>
<a name="287"><span class="lineNum">     287 </span>                :            :                  inject, status, quiet, kvm, decode-fds" SECONTEXT_E_QUAL "\n\</a>
<a name="288"><span class="lineNum">     288 </span>                :            : \n\</a>
<a name="289"><span class="lineNum">     289 </span>                :            : Startup:\n\</a>
<a name="290"><span class="lineNum">     290 </span>                :            :   -E VAR=VAL, --env=VAR=VAL\n\</a>
<a name="291"><span class="lineNum">     291 </span>                :            :                  put VAR=VAL in the environment for command\n\</a>
<a name="292"><span class="lineNum">     292 </span>                :            :   -E VAR, --env=VAR\n\</a>
<a name="293"><span class="lineNum">     293 </span>                :            :                  remove VAR from the environment for command\n\</a>
<a name="294"><span class="lineNum">     294 </span>                :            :   -p PID, --attach=PID\n\</a>
<a name="295"><span class="lineNum">     295 </span>                :            :                  trace process with process id PID, may be repeated\n\</a>
<a name="296"><span class="lineNum">     296 </span>                :            :   -u USERNAME, --user=USERNAME\n\</a>
<a name="297"><span class="lineNum">     297 </span>                :            :                  run command as USERNAME handling setuid and/or setgid\n\</a>
<a name="298"><span class="lineNum">     298 </span>                :            : \n\</a>
<a name="299"><span class="lineNum">     299 </span>                :            : Tracing:\n\</a>
<a name="300"><span class="lineNum">     300 </span>                :            :   -b execve, --detach-on=execve\n\</a>
<a name="301"><span class="lineNum">     301 </span>                :            :                  detach on execve syscall\n\</a>
<a name="302"><span class="lineNum">     302 </span>                :            :   -D, --daemonize[=grandchild]\n\</a>
<a name="303"><span class="lineNum">     303 </span>                :            :                  run tracer process as a grandchild, not as a parent\n\</a>
<a name="304"><span class="lineNum">     304 </span>                :            :   -DD, --daemonize=pgroup\n\</a>
<a name="305"><span class="lineNum">     305 </span>                :            :                  run tracer process in a separate process group\n\</a>
<a name="306"><span class="lineNum">     306 </span>                :            :   -DDD, --daemonize=session\n\</a>
<a name="307"><span class="lineNum">     307 </span>                :            :                  run tracer process in a separate session\n\</a>
<a name="308"><span class="lineNum">     308 </span>                :            :   -f, --follow-forks\n\</a>
<a name="309"><span class="lineNum">     309 </span>                :            :                  follow forks\n\</a>
<a name="310"><span class="lineNum">     310 </span>                :            :   -ff, --follow-forks --output-separately\n\</a>
<a name="311"><span class="lineNum">     311 </span>                :            :                  follow forks with output into separate files\n\</a>
<a name="312"><span class="lineNum">     312 </span>                :            :   -I INTERRUPTIBLE, --interruptible=INTERRUPTIBLE\n\</a>
<a name="313"><span class="lineNum">     313 </span>                :            :      1, anywhere:   no signals are blocked\n\</a>
<a name="314"><span class="lineNum">     314 </span>                :            :      2, waiting:    fatal signals are blocked while decoding syscall (default)\n\</a>
<a name="315"><span class="lineNum">     315 </span>                :            :      3, never:      fatal signals are always blocked (default if '-o FILE PROG')\n\</a>
<a name="316"><span class="lineNum">     316 </span>                :            :      4, never_tstp: fatal signals and SIGTSTP (^Z) are always blocked\n\</a>
<a name="317"><span class="lineNum">     317 </span>                :            :                     (useful to make 'strace -o FILE PROG' not stop on ^Z)\n\</a>
<a name="318"><span class="lineNum">     318 </span>                :            : \n\</a>
<a name="319"><span class="lineNum">     319 </span>                :            : Filtering:\n\</a>
<a name="320"><span class="lineNum">     320 </span>                :            :   -e trace=[!]{[?]SYSCALL[@64|@32|@x32]|[?]/REGEX|GROUP|all|none},\n\</a>
<a name="321"><span class="lineNum">     321 </span>                :            :   --trace=[!]{[?]SYSCALL[@64|@32|@x32]|[?]/REGEX|GROUP|all|none}\n\</a>
<a name="322"><span class="lineNum">     322 </span>                :            :                  trace only specified syscalls.\n\</a>
<a name="323"><span class="lineNum">     323 </span>                :            :      groups:     %%clock, %%creds, %%desc, %%file, %%fstat, %%fstatfs %%ipc, %%lstat,\n\</a>
<a name="324"><span class="lineNum">     324 </span>                :            :                  %%memory, %%net, %%process, %%pure, %%signal, %%stat, %%%%stat,\n\</a>
<a name="325"><span class="lineNum">     325 </span>                :            :                  %%statfs, %%%%statfs\n\</a>
<a name="326"><span class="lineNum">     326 </span>                :            :   -e signal=SET, --signal=SET\n\</a>
<a name="327"><span class="lineNum">     327 </span>                :            :                  trace only the specified set of signals\n\</a>
<a name="328"><span class="lineNum">     328 </span>                :            :                  print only the signals from SET\n\</a>
<a name="329"><span class="lineNum">     329 </span>                :            :   -e status=SET, --status=SET\n\</a>
<a name="330"><span class="lineNum">     330 </span>                :            :                  print only system calls with the return statuses in SET\n\</a>
<a name="331"><span class="lineNum">     331 </span>                :            :      statuses:   successful, failed, unfinished, unavailable, detached\n\</a>
<a name="332"><span class="lineNum">     332 </span>                :            :   -P PATH, --trace-path=PATH\n\</a>
<a name="333"><span class="lineNum">     333 </span>                :            :                  trace accesses to PATH\n\</a>
<a name="334"><span class="lineNum">     334 </span>                :            :   -z, --successful-only\n\</a>
<a name="335"><span class="lineNum">     335 </span>                :            :                  print only syscalls that returned without an error code\n\</a>
<a name="336"><span class="lineNum">     336 </span>                :            :   -Z, --failed-only\n\</a>
<a name="337"><span class="lineNum">     337 </span>                :            :                  print only syscalls that returned with an error code\n\</a>
<a name="338"><span class="lineNum">     338 </span>                :            : \n\</a>
<a name="339"><span class="lineNum">     339 </span>                :            : Output format:\n\</a>
<a name="340"><span class="lineNum">     340 </span>                :            :   -a COLUMN, --columns=COLUMN\n\</a>
<a name="341"><span class="lineNum">     341 </span>                :            :                  alignment COLUMN for printing syscall results (default %d)\n\</a>
<a name="342"><span class="lineNum">     342 </span>                :            :   -e abbrev=SET, --abbrev=SET\n\</a>
<a name="343"><span class="lineNum">     343 </span>                :            :                  abbreviate output for the syscalls in SET\n\</a>
<a name="344"><span class="lineNum">     344 </span>                :            :   -e verbose=SET, --verbose=SET\n\</a>
<a name="345"><span class="lineNum">     345 </span>                :            :                  dereference structures for the syscall in SET\n\</a>
<a name="346"><span class="lineNum">     346 </span>                :            :   -e raw=SET, --raw=SET\n\</a>
<a name="347"><span class="lineNum">     347 </span>                :            :                  print undecoded arguments for the syscalls in SET\n\</a>
<a name="348"><span class="lineNum">     348 </span>                :            :   -e read=SET, --read=SET\n\</a>
<a name="349"><span class="lineNum">     349 </span>                :            :                  dump the data read from the file descriptors in SET\n\</a>
<a name="350"><span class="lineNum">     350 </span>                :            :   -e write=SET, --write=SET\n\</a>
<a name="351"><span class="lineNum">     351 </span>                :            :                  dump the data written to the file descriptors in SET\n\</a>
<a name="352"><span class="lineNum">     352 </span>                :            :   -e quiet=SET, --quiet=SET\n\</a>
<a name="353"><span class="lineNum">     353 </span>                :            :                  suppress various informational messages\n\</a>
<a name="354"><span class="lineNum">     354 </span>                :            :      messages:   attach, exit, path-resolution, personality, thread-execve\n\</a>
<a name="355"><span class="lineNum">     355 </span>                :            :   -e kvm=vcpu, --kvm=vcpu\n\</a>
<a name="356"><span class="lineNum">     356 </span>                :            :                  print exit reason of kvm vcpu\n\</a>
<a name="357"><span class="lineNum">     357 </span>                :            :   -e decode-fds=SET, --decode-fds=SET\n\</a>
<a name="358"><span class="lineNum">     358 </span>                :            :                  what kinds of file descriptor information details to decode\n\</a>
<a name="359"><span class="lineNum">     359 </span>                :            :      details:    dev (device major/minor for block/char device files)\n\</a>
<a name="360"><span class="lineNum">     360 </span>                :            :                  path (file path),\n\</a>
<a name="361"><span class="lineNum">     361 </span>                :            :                  pidfd (associated PID for pidfds),\n\</a>
<a name="362"><span class="lineNum">     362 </span>                :            :                  socket (protocol-specific information for socket descriptors)\n\</a>
<a name="363"><span class="lineNum">     363 </span>                :            : "</a>
<a name="364"><span class="lineNum">     364 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="365"><span class="lineNum">     365 </span>                :            : "\</a>
<a name="366"><span class="lineNum">     366 </span>                :            :   -e secontext=FORMAT, --secontext[=FORMAT]\n\</a>
<a name="367"><span class="lineNum">     367 </span>                :            :                  print SELinux contexts in square brackets\n\</a>
<a name="368"><span class="lineNum">     368 </span>                :            :      formats:    comma-separated list of all, full, mismatch, none\n\</a>
<a name="369"><span class="lineNum">     369 </span>                :            :                  all: equivalent to full,mismatch\n\</a>
<a name="370"><span class="lineNum">     370 </span>                :            :                  full: print the full context instead of the type only\n\</a>
<a name="371"><span class="lineNum">     371 </span>                :            :                  mismatch: print expected context when actual is not matching\n\</a>
<a name="372"><span class="lineNum">     372 </span>                :            :                  none: equivalent to not specifying the option at all\n\</a>
<a name="373"><span class="lineNum">     373 </span>                :            : "</a>
<a name="374"><span class="lineNum">     374 </span>                :            : #endif</a>
<a name="375"><span class="lineNum">     375 </span>                :            : "\</a>
<a name="376"><span class="lineNum">     376 </span>                :            :   -i, --instruction-pointer\n\</a>
<a name="377"><span class="lineNum">     377 </span>                :            :                  print instruction pointer at time of syscall\n\</a>
<a name="378"><span class="lineNum">     378 </span>                :            : "</a>
<a name="379"><span class="lineNum">     379 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="380"><span class="lineNum">     380 </span>                :            : "\</a>
<a name="381"><span class="lineNum">     381 </span>                :            :   -k, --stack-traces\n\</a>
<a name="382"><span class="lineNum">     382 </span>                :            :                  obtain stack trace between each syscall\n\</a>
<a name="383"><span class="lineNum">     383 </span>                :            : "</a>
<a name="384"><span class="lineNum">     384 </span>                :            : #endif</a>
<a name="385"><span class="lineNum">     385 </span>                :            : "\</a>
<a name="386"><span class="lineNum">     386 </span>                :            :   -n, --syscall-number\n\</a>
<a name="387"><span class="lineNum">     387 </span>                :            :                  print syscall number\n\</a>
<a name="388"><span class="lineNum">     388 </span>                :            :   -o FILE, --output=FILE\n\</a>
<a name="389"><span class="lineNum">     389 </span>                :            :                  send trace output to FILE instead of stderr\n\</a>
<a name="390"><span class="lineNum">     390 </span>                :            :   -A, --output-append-mode\n\</a>
<a name="391"><span class="lineNum">     391 </span>                :            :                  open the file provided in the -o option in append mode\n\</a>
<a name="392"><span class="lineNum">     392 </span>                :            :   --output-separately\n\</a>
<a name="393"><span class="lineNum">     393 </span>                :            :                  output into separate files (by appending pid to file names)\n\</a>
<a name="394"><span class="lineNum">     394 </span>                :            :   -q, --quiet=attach,personality\n\</a>
<a name="395"><span class="lineNum">     395 </span>                :            :                  suppress messages about attaching, detaching, etc.\n\</a>
<a name="396"><span class="lineNum">     396 </span>                :            :   -qq, --quiet=attach,personality,exit\n\</a>
<a name="397"><span class="lineNum">     397 </span>                :            :                  suppress messages about process exit status as well.\n\</a>
<a name="398"><span class="lineNum">     398 </span>                :            :   -qqq, --quiet=all\n\</a>
<a name="399"><span class="lineNum">     399 </span>                :            :                  suppress all suppressible messages.\n\</a>
<a name="400"><span class="lineNum">     400 </span>                :            :   -r, --relative-timestamps[=PRECISION]\n\</a>
<a name="401"><span class="lineNum">     401 </span>                :            :                  print relative timestamp\n\</a>
<a name="402"><span class="lineNum">     402 </span>                :            :      precision:  one of s, ms, us, ns; default is microseconds\n\</a>
<a name="403"><span class="lineNum">     403 </span>                :            :   -s STRSIZE, --string-limit=STRSIZE\n\</a>
<a name="404"><span class="lineNum">     404 </span>                :            :                  limit length of print strings to STRSIZE chars (default %d)\n\</a>
<a name="405"><span class="lineNum">     405 </span>                :            :   --absolute-timestamps=[[format:]FORMAT[,[precision:]PRECISION]]\n\</a>
<a name="406"><span class="lineNum">     406 </span>                :            :                  set the format of absolute timestamps\n\</a>
<a name="407"><span class="lineNum">     407 </span>                :            :      format:     none, time, or unix; default is time\n\</a>
<a name="408"><span class="lineNum">     408 </span>                :            :      precision:  one of s, ms, us, ns; default is seconds\n\</a>
<a name="409"><span class="lineNum">     409 </span>                :            :   -t, --absolute-timestamps[=time]\n\</a>
<a name="410"><span class="lineNum">     410 </span>                :            :                  print absolute timestamp\n\</a>
<a name="411"><span class="lineNum">     411 </span>                :            :   -tt, --absolute-timestamps=[time,]us\n\</a>
<a name="412"><span class="lineNum">     412 </span>                :            :                  print absolute timestamp with usecs\n\</a>
<a name="413"><span class="lineNum">     413 </span>                :            :   -ttt, --absolute-timestamps=unix,us\n\</a>
<a name="414"><span class="lineNum">     414 </span>                :            :                  print absolute UNIX time with usecs\n\</a>
<a name="415"><span class="lineNum">     415 </span>                :            :   -T, --syscall-times[=PRECISION]\n\</a>
<a name="416"><span class="lineNum">     416 </span>                :            :                  print time spent in each syscall\n\</a>
<a name="417"><span class="lineNum">     417 </span>                :            :      precision:  one of s, ms, us, ns; default is microseconds\n\</a>
<a name="418"><span class="lineNum">     418 </span>                :            :   -v, --no-abbrev\n\</a>
<a name="419"><span class="lineNum">     419 </span>                :            :                  verbose mode: print entities unabbreviated\n\</a>
<a name="420"><span class="lineNum">     420 </span>                :            :   --strings-in-hex=non-ascii-chars\n\</a>
<a name="421"><span class="lineNum">     421 </span>                :            :                  use hex instead of octal in escape sequences\n\</a>
<a name="422"><span class="lineNum">     422 </span>                :            :   -x, --strings-in-hex=non-ascii\n\</a>
<a name="423"><span class="lineNum">     423 </span>                :            :                  print non-ASCII strings in hex\n\</a>
<a name="424"><span class="lineNum">     424 </span>                :            :   -xx, --strings-in-hex[=all]\n\</a>
<a name="425"><span class="lineNum">     425 </span>                :            :                  print all strings in hex\n\</a>
<a name="426"><span class="lineNum">     426 </span>                :            :   -X FORMAT, --const-print-style=FORMAT\n\</a>
<a name="427"><span class="lineNum">     427 </span>                :            :                  set the FORMAT for printing of named constants and flags\n\</a>
<a name="428"><span class="lineNum">     428 </span>                :            :      formats:    raw, abbrev, verbose\n\</a>
<a name="429"><span class="lineNum">     429 </span>                :            :   -y, --decode-fds[=path]\n\</a>
<a name="430"><span class="lineNum">     430 </span>                :            :                  print paths associated with file descriptor arguments\n\</a>
<a name="431"><span class="lineNum">     431 </span>                :            :   -yy, --decode-fds=all\n\</a>
<a name="432"><span class="lineNum">     432 </span>                :            :                  print all available information associated with file\n\</a>
<a name="433"><span class="lineNum">     433 </span>                :            :                  descriptors in addition to paths\n\</a>
<a name="434"><span class="lineNum">     434 </span>                :            :   --decode-pids=pidns\n\</a>
<a name="435"><span class="lineNum">     435 </span>                :            :                  print PIDs in strace's namespace, too\n\</a>
<a name="436"><span class="lineNum">     436 </span>                :            :   -Y, --decode-pids=comm\n\</a>
<a name="437"><span class="lineNum">     437 </span>                :            :                  print command names associated with PIDs\n\</a>
<a name="438"><span class="lineNum">     438 </span>                :            : \n\</a>
<a name="439"><span class="lineNum">     439 </span>                :            : Statistics:\n\</a>
<a name="440"><span class="lineNum">     440 </span>                :            :   -c, --summary-only\n\</a>
<a name="441"><span class="lineNum">     441 </span>                :            :                  count time, calls, and errors for each syscall and report\n\</a>
<a name="442"><span class="lineNum">     442 </span>                :            :                  summary\n\</a>
<a name="443"><span class="lineNum">     443 </span>                :            :   -C, --summary  like -c, but also print the regular output\n\</a>
<a name="444"><span class="lineNum">     444 </span>                :            :   -O OVERHEAD[UNIT], --summary-syscall-overhead=OVERHEAD[UNIT]\n\</a>
<a name="445"><span class="lineNum">     445 </span>                :            :                  set overhead for tracing syscalls to OVERHEAD UNITs\n\</a>
<a name="446"><span class="lineNum">     446 </span>                :            :      units:      one of s, ms, us, ns; default is microseconds\n\</a>
<a name="447"><span class="lineNum">     447 </span>                :            :   -S SORTBY, --summary-sort-by=SORTBY\n\</a>
<a name="448"><span class="lineNum">     448 </span>                :            :                  sort syscall counts by: time, min-time, max-time, avg-time,\n\</a>
<a name="449"><span class="lineNum">     449 </span>                :            :                  calls, errors, name, nothing (default %s)\n\</a>
<a name="450"><span class="lineNum">     450 </span>                :            :   -U COLUMNS, --summary-columns=COLUMNS\n\</a>
<a name="451"><span class="lineNum">     451 </span>                :            :                  show specific columns in the summary report: comma-separated\n\</a>
<a name="452"><span class="lineNum">     452 </span>                :            :                  list of time-percent, total-time, min-time, max-time, \n\</a>
<a name="453"><span class="lineNum">     453 </span>                :            :                  avg-time, calls, errors, name\n\</a>
<a name="454"><span class="lineNum">     454 </span>                :            :                  (default time-percent,total-time,avg-time,calls,errors,name)\n\</a>
<a name="455"><span class="lineNum">     455 </span>                :            :   -w, --summary-wall-clock\n\</a>
<a name="456"><span class="lineNum">     456 </span>                :            :                  summarise syscall latency (default is system time)\n\</a>
<a name="457"><span class="lineNum">     457 </span>                :            : \n\</a>
<a name="458"><span class="lineNum">     458 </span>                :            : Tampering:\n\</a>
<a name="459"><span class="lineNum">     459 </span>                :            :   -e inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]\n\</a>
<a name="460"><span class="lineNum">     460 </span>                :            :             [:delay_enter=DELAY][:delay_exit=DELAY]\n\</a>
<a name="461"><span class="lineNum">     461 </span>                :            :             [:poke_enter=@argN=DATAN,@argM=DATAM...]\n\</a>
<a name="462"><span class="lineNum">     462 </span>                :            :             [:poke_exit=@argN=DATAN,@argM=DATAM...]\n\</a>
<a name="463"><span class="lineNum">     463 </span>                :            :             [:when=WHEN],\n\</a>
<a name="464"><span class="lineNum">     464 </span>                :            :   --inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]\n\</a>
<a name="465"><span class="lineNum">     465 </span>                :            :            [:delay_enter=DELAY][:delay_exit=DELAY]\n\</a>
<a name="466"><span class="lineNum">     466 </span>                :            :            [:poke_enter=@argN=DATAN,@argM=DATAM...]\n\</a>
<a name="467"><span class="lineNum">     467 </span>                :            :            [:poke_exit=@argN=DATAN,@argM=DATAM...]\n\</a>
<a name="468"><span class="lineNum">     468 </span>                :            :            [:when=WHEN],\n\</a>
<a name="469"><span class="lineNum">     469 </span>                :            :                  perform syscall tampering for the syscalls in SET\n\</a>
<a name="470"><span class="lineNum">     470 </span>                :            :      delay:      microseconds or NUMBER{s|ms|us|ns}\n\</a>
<a name="471"><span class="lineNum">     471 </span>                :            :      when:       FIRST[..LAST][+[STEP]]\n\</a>
<a name="472"><span class="lineNum">     472 </span>                :            :   -e fault=SET[:error=ERRNO][:when=WHEN], --fault=SET[:error=ERRNO][:when=WHEN]\n\</a>
<a name="473"><span class="lineNum">     473 </span>                :            :                  synonym for -e inject with default ERRNO set to ENOSYS.\n\</a>
<a name="474"><span class="lineNum">     474 </span>                :            : \n\</a>
<a name="475"><span class="lineNum">     475 </span>                :            : Miscellaneous:\n\</a>
<a name="476"><span class="lineNum">     476 </span>                :            :   -d, --debug    enable debug output to stderr\n\</a>
<a name="477"><span class="lineNum">     477 </span>                :            :   -h, --help     print help message\n\</a>
<a name="478"><span class="lineNum">     478 </span>                :            :   --seccomp-bpf  enable seccomp-bpf filtering\n\</a>
<a name="479"><span class="lineNum">     479 </span>                :            :   -V, --version  print version\n\</a>
<a name="480"><span class="lineNum">     480 </span>                :            : "</a>
<a name="481"><span class="lineNum">     481 </span>                :            : /* ancient, no one should use it</a>
<a name="482"><span class="lineNum">     482 </span>                :            : -F -- attempt to follow vforks (deprecated, use -f)\n\</a>
<a name="483"><span class="lineNum">     483 </span>                :            :  */</a>
<a name="484"><span class="lineNum">     484 </span>                :            : , DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);</a>
<a name="485"><span class="lineNum">     485 </span>                :<span class="lineCov">         16 :         exit(0);</span></a>
<a name="486"><span class="lineNum">     486 </span>                :            : </a>
<a name="487"><span class="lineNum">     487 </span>                :            : #undef K_OPT</a>
<a name="488"><span class="lineNum">     488 </span>                :            : }</a>
<a name="489"><span class="lineNum">     489 </span>                :            : </a>
<a name="490"><span class="lineNum">     490 </span>                :            : void ATTRIBUTE_NORETURN</a>
<a name="491"><span class="lineNum">     491 </span>                :<span class="lineCov">       5292 : die(void)</span></a>
<a name="492"><span class="lineNum">     492 </span>                :            : {</a>
<a name="493"><span class="lineNum">     493 </span>        [<span class="branchCov" title="Branch 0 was taken 5292 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">       5292 :         if (strace_tracer_pid == getpid()) {</span></a>
<a name="494"><span class="lineNum">     494 </span>                :<span class="lineCov">       5292 :                 cleanup(0);</span></a>
<a name="495"><span class="lineNum">     495 </span>                :<span class="lineCov">       5292 :                 exit(1);</span></a>
<a name="496"><span class="lineNum">     496 </span>                :            :         }</a>
<a name="497"><span class="lineNum">     497 </span>                :            : </a>
<a name="498"><span class="lineNum">     498 </span>                :<span class="lineNoCov">          0 :         _exit(1);</span></a>
<a name="499"><span class="lineNum">     499 </span>                :            : }</a>
<a name="500"><span class="lineNum">     500 </span>                :            : </a>
<a name="501"><span class="lineNum">     501 </span>                :            : static void</a>
<a name="502"><span class="lineNum">     502 </span>                :<span class="lineCov">         35 : error_opt_arg(int opt, const struct option *lopt, const char *arg)</span></a>
<a name="503"><span class="lineNum">     503 </span>                :            : {</a>
<a name="504"><span class="lineNum">     504 </span>  [<span class="branchCov" title="Branch 0 was taken 22 times"> + </span><span class="branchCov" title="Branch 1 was taken 13 times"> + </span><span class="branchCov" title="Branch 2 was taken 22 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">         35 :         if (lopt && lopt->name) {</span></a>
<a name="505"><span class="lineNum">     505 </span>                :<span class="lineCov">         22 :                 error_msg_and_help("invalid --%s argument: '%s'",</span></a>
<a name="506"><span class="lineNum">     506 </span>                :            :                                    lopt->name, arg);</a>
<a name="507"><span class="lineNum">     507 </span>                :            :         } else {</a>
<a name="508"><span class="lineNum">     508 </span>                :<span class="lineCov">         13 :                 error_msg_and_help("invalid -%c argument: '%s'", opt, arg);</span></a>
<a name="509"><span class="lineNum">     509 </span>                :            :         }</a>
<a name="510"><span class="lineNum">     510 </span>                :            : }</a>
<a name="511"><span class="lineNum">     511 </span>                :            : </a>
<a name="512"><span class="lineNum">     512 </span>                :            : static int</a>
<a name="513"><span class="lineNum">     513 </span>                :<span class="lineCov">      17344 : ptrace_attach_or_seize(int pid, const char **ptrace_attach_cmd)</span></a>
<a name="514"><span class="lineNum">     514 </span>                :            : {</a>
<a name="515"><span class="lineNum">     515 </span>                :<span class="lineCov">      17344 :         int r;</span></a>
<a name="516"><span class="lineNum">     516 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17344 times"> + </span>]:<span class="lineCov">      17344 :         if (!use_seize)</span></a>
<a name="517"><span class="lineNum">     517 </span>                :<span class="lineNoCov">          0 :                 return *ptrace_attach_cmd = "PTRACE_ATTACH",</span></a>
<a name="518"><span class="lineNum">     518 </span>                :<span class="lineNoCov">          0 :                        ptrace(PTRACE_ATTACH, pid, 0L, 0L);</span></a>
<a name="519"><span class="lineNum">     519 </span>                :<span class="lineCov">      17344 :         r = ptrace(PTRACE_SEIZE, pid, 0L, (unsigned long) ptrace_setoptions);</span></a>
<a name="520"><span class="lineNum">     520 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 17343 times"> + </span>]:<span class="lineCov">      17344 :         if (r)</span></a>
<a name="521"><span class="lineNum">     521 </span>                :<span class="lineCov">          1 :                 return *ptrace_attach_cmd = "PTRACE_SEIZE", r;</span></a>
<a name="522"><span class="lineNum">     522 </span>                :<span class="lineCov">      17343 :         r = ptrace(PTRACE_INTERRUPT, pid, 0L, 0L);</span></a>
<a name="523"><span class="lineNum">     523 </span>                :<span class="lineCov">      17343 :         return *ptrace_attach_cmd = "PTRACE_INTERRUPT", r;</span></a>
<a name="524"><span class="lineNum">     524 </span>                :            : }</a>
<a name="525"><span class="lineNum">     525 </span>                :            : </a>
<a name="526"><span class="lineNum">     526 </span>                :            : static const char *</a>
<a name="527"><span class="lineNum">     527 </span>                :<span class="lineNoCov">          0 : ptrace_op_str(unsigned int op)</span></a>
<a name="528"><span class="lineNum">     528 </span>                :            : {</a>
<a name="529"><span class="lineNum">     529 </span>                :<span class="lineNoCov">          0 :         const char *str = xlookup(ptrace_cmds, op);</span></a>
<a name="530"><span class="lineNum">     530 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (str)</span></a>
<a name="531"><span class="lineNum">     531 </span>                :            :                 return str;</a>
<a name="532"><span class="lineNum">     532 </span>                :            : </a>
<a name="533"><span class="lineNum">     533 </span>                :<span class="lineNoCov">          0 :         static char buf[sizeof(op) * 3];</span></a>
<a name="534"><span class="lineNum">     534 </span>                :<span class="lineNoCov">          0 :         xsprintf(buf, "%u", op);</span></a>
<a name="535"><span class="lineNum">     535 </span>                :<span class="lineNoCov">          0 :         return buf;</span></a>
<a name="536"><span class="lineNum">     536 </span>                :            : }</a>
<a name="537"><span class="lineNum">     537 </span>                :            : </a>
<a name="538"><span class="lineNum">     538 </span>                :            : /*</a>
<a name="539"><span class="lineNum">     539 </span>                :            :  * Used when we want to unblock stopped traced process.</a>
<a name="540"><span class="lineNum">     540 </span>                :            :  * Should be only used with PTRACE_CONT, PTRACE_DETACH and PTRACE_SYSCALL.</a>
<a name="541"><span class="lineNum">     541 </span>                :            :  * Returns 0 on success or if error was ESRCH</a>
<a name="542"><span class="lineNum">     542 </span>                :            :  * (presumably process was killed while we talk to it).</a>
<a name="543"><span class="lineNum">     543 </span>                :            :  * Otherwise prints error message and returns -1.</a>
<a name="544"><span class="lineNum">     544 </span>                :            :  */</a>
<a name="545"><span class="lineNum">     545 </span>                :            : static int</a>
<a name="546"><span class="lineNum">     546 </span>                :<span class="lineCov">  176291013 : ptrace_restart(const unsigned int op, struct tcb *const tcp, unsigned int sig)</span></a>
<a name="547"><span class="lineNum">     547 </span>                :            : {</a>
<a name="548"><span class="lineNum">     548 </span>                :<span class="lineCov">  176291013 :         int err;</span></a>
<a name="549"><span class="lineNum">     549 </span>                :            : </a>
<a name="550"><span class="lineNum">     550 </span>                :<span class="lineCov">  176291013 :         errno = 0;</span></a>
<a name="551"><span class="lineNum">     551 </span>                :<span class="lineCov">  176291013 :         ptrace(op, tcp->pid, 0L, (unsigned long) sig);</span></a>
<a name="552"><span class="lineNum">     552 </span>                :<span class="lineCov">  176291013 :         err = errno;</span></a>
<a name="553"><span class="lineNum">     553 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 176291013 times"> + </span>]:<span class="lineCov">  176291013 :         if (!err || err == ESRCH)</span></a>
<a name="554"><span class="lineNum">     554 </span>                :            :                 return 0;</a>
<a name="555"><span class="lineNum">     555 </span>                :            : </a>
<a name="556"><span class="lineNum">     556 </span>                :            :         /*</a>
<a name="557"><span class="lineNum">     557 </span>                :            :          * Why curcol != 0? Otherwise sometimes we get this:</a>
<a name="558"><span class="lineNum">     558 </span>                :            :          *</a>
<a name="559"><span class="lineNum">     559 </span>                :            :          * 10252 kill(10253, SIGKILL)              = 0</a>
<a name="560"><span class="lineNum">     560 </span>                :            :          *  <ptrace(SYSCALL,10252):No such process>10253 ...next decode...</a>
<a name="561"><span class="lineNum">     561 </span>                :            :          *</a>
<a name="562"><span class="lineNum">     562 </span>                :            :          * 10252 died after we retrieved syscall exit data,</a>
<a name="563"><span class="lineNum">     563 </span>                :            :          * but before we tried to restart it. Log looks ugly.</a>
<a name="564"><span class="lineNum">     564 </span>                :            :          */</a>
<a name="565"><span class="lineNum">     565 </span>  [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (current_tcp && current_tcp->curcol != 0) {</span></a>
<a name="566"><span class="lineNum">     566 </span>                :<span class="lineNoCov">          0 :                 tprintf(" <Cannot restart pid %d with ptrace(%s): %s>\n",</span></a>
<a name="567"><span class="lineNum">     567 </span>                :            :                         tcp->pid, ptrace_op_str(op), strerror(err));</a>
<a name="568"><span class="lineNum">     568 </span>                :<span class="lineNoCov">          0 :                 line_ended();</span></a>
<a name="569"><span class="lineNum">     569 </span>                :            :         }</a>
<a name="570"><span class="lineNum">     570 </span>                :<span class="lineNoCov">          0 :         errno = err;</span></a>
<a name="571"><span class="lineNum">     571 </span>                :<span class="lineNoCov">          0 :         perror_msg("ptrace(%s,pid:%d,sig:%u)",</span></a>
<a name="572"><span class="lineNum">     572 </span>                :            :                    ptrace_op_str(op), tcp->pid, sig);</a>
<a name="573"><span class="lineNum">     573 </span>                :<span class="lineNoCov">          0 :         return -1;</span></a>
<a name="574"><span class="lineNum">     574 </span>                :            : }</a>
<a name="575"><span class="lineNum">     575 </span>                :            : </a>
<a name="576"><span class="lineNum">     576 </span>                :            : static void</a>
<a name="577"><span class="lineNum">     577 </span>                :<span class="lineCov">      74602 : set_cloexec_flag(int fd)</span></a>
<a name="578"><span class="lineNum">     578 </span>                :            : {</a>
<a name="579"><span class="lineNum">     579 </span>                :<span class="lineCov">      74602 :         int flags, newflags;</span></a>
<a name="580"><span class="lineNum">     580 </span>                :            : </a>
<a name="581"><span class="lineNum">     581 </span>                :<span class="lineCov">      74602 :         flags = fcntl_fd(fd, F_GETFD);</span></a>
<a name="582"><span class="lineNum">     582 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 74602 times"> + </span>]:<span class="lineCov">      74602 :         if (flags < 0) {</span></a>
<a name="583"><span class="lineNum">     583 </span>                :            :                 /* Can happen only if fd is bad.</a>
<a name="584"><span class="lineNum">     584 </span>                :            :                  * Should never happen: if it does, we have a bug</a>
<a name="585"><span class="lineNum">     585 </span>                :            :                  * in the caller. Therefore we just abort</a>
<a name="586"><span class="lineNum">     586 </span>                :            :                  * instead of propagating the error.</a>
<a name="587"><span class="lineNum">     587 </span>                :            :                  */</a>
<a name="588"><span class="lineNum">     588 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("fcntl(%d, F_GETFD)", fd);</span></a>
<a name="589"><span class="lineNum">     589 </span>                :            :         }</a>
<a name="590"><span class="lineNum">     590 </span>                :            : </a>
<a name="591"><span class="lineNum">     591 </span>                :<span class="lineCov">      74602 :         newflags = flags | FD_CLOEXEC;</span></a>
<a name="592"><span class="lineNum">     592 </span>        [<span class="branchCov" title="Branch 0 was taken 74602 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      74602 :         if (flags == newflags)</span></a>
<a name="593"><span class="lineNum">     593 </span>                :            :                 return;</a>
<a name="594"><span class="lineNum">     594 </span>                :            : </a>
<a name="595"><span class="lineNum">     595 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 74602 times"> + </span>]:<span class="lineCov">      74602 :         if (fcntl_fd(fd, F_SETFD, newflags)) /* never fails */</span></a>
<a name="596"><span class="lineNum">     596 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("fcntl(%d, F_SETFD, %#x)", fd, newflags);</span></a>
<a name="597"><span class="lineNum">     597 </span>                :            : }</a>
<a name="598"><span class="lineNum">     598 </span>                :            : </a>
<a name="599"><span class="lineNum">     599 </span>                :            : /*</a>
<a name="600"><span class="lineNum">     600 </span>                :            :  * When strace is setuid executable, we have to swap uids</a>
<a name="601"><span class="lineNum">     601 </span>                :            :  * before and after filesystem and process management operations.</a>
<a name="602"><span class="lineNum">     602 </span>                :            :  */</a>
<a name="603"><span class="lineNum">     603 </span>                :            : static void</a>
<a name="604"><span class="lineNum">     604 </span>                :<span class="lineCov">      45197 : swap_uid(void)</span></a>
<a name="605"><span class="lineNum">     605 </span>                :            : {</a>
<a name="606"><span class="lineNum">     606 </span>                :<span class="lineCov">      45197 :         int euid = geteuid(), uid = getuid();</span></a>
<a name="607"><span class="lineNum">     607 </span>                :            : </a>
<a name="608"><span class="lineNum">     608 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 45197 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">      45197 :         if (euid != uid && setreuid(euid, uid) < 0) {</span></a>
<a name="609"><span class="lineNum">     609 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("setreuid");</span></a>
<a name="610"><span class="lineNum">     610 </span>                :            :         }</a>
<a name="611"><span class="lineNum">     611 </span>                :<span class="lineCov">      45197 : }</span></a>
<a name="612"><span class="lineNum">     612 </span>                :            : </a>
<a name="613"><span class="lineNum">     613 </span>                :            : static FILE *</a>
<a name="614"><span class="lineNum">     614 </span>                :<span class="lineCov">      22596 : strace_fopen(const char *path)</span></a>
<a name="615"><span class="lineNum">     615 </span>                :            : {</a>
<a name="616"><span class="lineNum">     616 </span>                :<span class="lineCov">      22596 :         FILE *fp;</span></a>
<a name="617"><span class="lineNum">     617 </span>                :            : </a>
<a name="618"><span class="lineNum">     618 </span>                :<span class="lineCov">      22596 :         swap_uid();</span></a>
<a name="619"><span class="lineNum">     619 </span>        [<span class="branchCov" title="Branch 0 was taken 22596 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      45192 :         fp = fopen_stream(path, open_append ? "a" : "w");</span></a>
<a name="620"><span class="lineNum">     620 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 22596 times"> + </span>]:<span class="lineCov">      22596 :         if (!fp)</span></a>
<a name="621"><span class="lineNum">     621 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("Can't fopen '%s'", path);</span></a>
<a name="622"><span class="lineNum">     622 </span>                :<span class="lineCov">      22596 :         swap_uid();</span></a>
<a name="623"><span class="lineNum">     623 </span>                :<span class="lineCov">      22596 :         set_cloexec_flag(fileno(fp));</span></a>
<a name="624"><span class="lineNum">     624 </span>                :<span class="lineCov">      22596 :         return fp;</span></a>
<a name="625"><span class="lineNum">     625 </span>                :            : }</a>
<a name="626"><span class="lineNum">     626 </span>                :            : </a>
<a name="627"><span class="lineNum">     627 </span>                :            : static int popen_pid;</a>
<a name="628"><span class="lineNum">     628 </span>                :            : </a>
<a name="629"><span class="lineNum">     629 </span>                :            : #ifndef _PATH_BSHELL</a>
<a name="630"><span class="lineNum">     630 </span>                :            : # define _PATH_BSHELL "/bin/sh"</a>
<a name="631"><span class="lineNum">     631 </span>                :            : #endif</a>
<a name="632"><span class="lineNum">     632 </span>                :            : </a>
<a name="633"><span class="lineNum">     633 </span>                :            : /*</a>
<a name="634"><span class="lineNum">     634 </span>                :            :  * We cannot use standard popen(3) here because we have to distinguish</a>
<a name="635"><span class="lineNum">     635 </span>                :            :  * popen child process from other processes we trace, and standard popen(3)</a>
<a name="636"><span class="lineNum">     636 </span>                :            :  * does not export its child's pid.</a>
<a name="637"><span class="lineNum">     637 </span>                :            :  */</a>
<a name="638"><span class="lineNum">     638 </span>                :            : static FILE *</a>
<a name="639"><span class="lineNum">     639 </span>                :<span class="lineCov">          5 : strace_popen(const char *command)</span></a>
<a name="640"><span class="lineNum">     640 </span>                :            : {</a>
<a name="641"><span class="lineNum">     641 </span>                :<span class="lineCov">          5 :         FILE *fp;</span></a>
<a name="642"><span class="lineNum">     642 </span>                :<span class="lineCov">          5 :         int pid;</span></a>
<a name="643"><span class="lineNum">     643 </span>                :<span class="lineCov">          5 :         int fds[2];</span></a>
<a name="644"><span class="lineNum">     644 </span>                :            : </a>
<a name="645"><span class="lineNum">     645 </span>                :<span class="lineCov">          5 :         swap_uid();</span></a>
<a name="646"><span class="lineNum">     646 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          5 :         if (pipe(fds) < 0)</span></a>
<a name="647"><span class="lineNum">     647 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("pipe");</span></a>
<a name="648"><span class="lineNum">     648 </span>                :            : </a>
<a name="649"><span class="lineNum">     649 </span>                :<span class="lineCov">          5 :         set_cloexec_flag(fds[1]); /* never fails */</span></a>
<a name="650"><span class="lineNum">     650 </span>                :            : </a>
<a name="651"><span class="lineNum">     651 </span>                :<span class="lineCov">          5 :         pid = vfork();</span></a>
<a name="652"><span class="lineNum">     652 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          5 :         if (pid < 0)</span></a>
<a name="653"><span class="lineNum">     653 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("vfork");</span></a>
<a name="654"><span class="lineNum">     654 </span>                :            : </a>
<a name="655"><span class="lineNum">     655 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          5 :         if (pid == 0) {</span></a>
<a name="656"><span class="lineNum">     656 </span>                :            :                 /* child */</a>
<a name="657"><span class="lineNum">     657 </span>                :<span class="lineCov">          5 :                 close(fds[1]);</span></a>
<a name="658"><span class="lineNum">     658 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          5 :                 if (fds[0] != 0) {</span></a>
<a name="659"><span class="lineNum">     659 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          5 :                         if (dup2(fds[0], 0))</span></a>
<a name="660"><span class="lineNum">     660 </span>                :<span class="lineNoCov">          0 :                                 perror_msg_and_die("dup2");</span></a>
<a name="661"><span class="lineNum">     661 </span>                :<span class="lineCov">          5 :                         close(fds[0]);</span></a>
<a name="662"><span class="lineNum">     662 </span>                :            :                 }</a>
<a name="663"><span class="lineNum">     663 </span>                :<span class="lineCov">          5 :                 execl(_PATH_BSHELL, "sh", "-c", command, NULL);</span></a>
<a name="664"><span class="lineNum">     664 </span>                :<span class="lineCov">          5 :                 perror_msg_and_die("Can't execute '%s'", _PATH_BSHELL);</span></a>
<a name="665"><span class="lineNum">     665 </span>                :            :         }</a>
<a name="666"><span class="lineNum">     666 </span>                :            : </a>
<a name="667"><span class="lineNum">     667 </span>                :            :         /* parent */</a>
<a name="668"><span class="lineNum">     668 </span>                :<span class="lineNoCov">          0 :         popen_pid = pid;</span></a>
<a name="669"><span class="lineNum">     669 </span>                :<span class="lineNoCov">          0 :         close(fds[0]);</span></a>
<a name="670"><span class="lineNum">     670 </span>                :<span class="lineNoCov">          0 :         swap_uid();</span></a>
<a name="671"><span class="lineNum">     671 </span>                :<span class="lineNoCov">          0 :         fp = fdopen(fds[1], "w");</span></a>
<a name="672"><span class="lineNum">     672 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (!fp)</span></a>
<a name="673"><span class="lineNum">     673 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("fdopen");</span></a>
<a name="674"><span class="lineNum">     674 </span>                :<span class="lineNoCov">          0 :         return fp;</span></a>
<a name="675"><span class="lineNum">     675 </span>                :            : }</a>
<a name="676"><span class="lineNum">     676 </span>                :            : </a>
<a name="677"><span class="lineNum">     677 </span>                :            : static void</a>
<a name="678"><span class="lineNum">     678 </span>                :<span class="lineCov">          1 : outf_perror(const struct tcb * const tcp)</span></a>
<a name="679"><span class="lineNum">     679 </span>                :            : {</a>
<a name="680"><span class="lineNum">     680 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          1 :         if (tcp->outf == stderr)</span></a>
<a name="681"><span class="lineNum">     681 </span>                :            :                 return;</a>
<a name="682"><span class="lineNum">     682 </span>                :            : </a>
<a name="683"><span class="lineNum">     683 </span>                :            :         /* This is ugly, but we don't store separate file names */</a>
<a name="684"><span class="lineNum">     684 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :         if (output_separately)</span></a>
<a name="685"><span class="lineNum">     685 </span>                :<span class="lineNoCov">          0 :                 perror_msg("%s.%u", outfname, tcp->pid);</span></a>
<a name="686"><span class="lineNum">     686 </span>                :            :         else</a>
<a name="687"><span class="lineNum">     687 </span>                :<span class="lineCov">          1 :                 perror_msg("%s", outfname);</span></a>
<a name="688"><span class="lineNum">     688 </span>                :            : }</a>
<a name="689"><span class="lineNum">     689 </span>                :            : </a>
<a name="690"><span class="lineNum">     690 </span>                :            : ATTRIBUTE_FORMAT((printf, 1, 0))</a>
<a name="691"><span class="lineNum">     691 </span>                :            : static void</a>
<a name="692"><span class="lineNum">     692 </span>                :<span class="lineCov">    8778408 : tvprintf(const char *const fmt, va_list args)</span></a>
<a name="693"><span class="lineNum">     693 </span>                :            : {</a>
<a name="694"><span class="lineNum">     694 </span>        [<span class="branchCov" title="Branch 0 was taken 8778408 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">    8778408 :         if (current_tcp) {</span></a>
<a name="695"><span class="lineNum">     695 </span>                :<span class="lineCov">    8778408 :                 int n = vfprintf(current_tcp->outf, fmt, args);</span></a>
<a name="696"><span class="lineNum">     696 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 8778408 times"> + </span>]:<span class="lineCov">    8778408 :                 if (n < 0) {</span></a>
<a name="697"><span class="lineNum">     697 </span>                :            :                         /* very unlikely due to vfprintf buffering */</a>
<a name="698"><span class="lineNum">     698 </span>                :<span class="lineNoCov">          0 :                         outf_perror(current_tcp);</span></a>
<a name="699"><span class="lineNum">     699 </span>                :            :                 } else</a>
<a name="700"><span class="lineNum">     700 </span>                :<span class="lineCov">    8778408 :                         current_tcp->curcol += n;</span></a>
<a name="701"><span class="lineNum">     701 </span>                :            :         }</a>
<a name="702"><span class="lineNum">     702 </span>                :<span class="lineCov">    8778408 : }</span></a>
<a name="703"><span class="lineNum">     703 </span>                :            : </a>
<a name="704"><span class="lineNum">     704 </span>                :            : void</a>
<a name="705"><span class="lineNum">     705 </span>                :<span class="lineCov">    8708450 : tprintf(const char *fmt, ...)</span></a>
<a name="706"><span class="lineNum">     706 </span>                :            : {</a>
<a name="707"><span class="lineNum">     707 </span>                :<span class="lineCov">    8708450 :         va_list args;</span></a>
<a name="708"><span class="lineNum">     708 </span>                :<span class="lineCov">    8708450 :         va_start(args, fmt);</span></a>
<a name="709"><span class="lineNum">     709 </span>                :<span class="lineCov">    8708450 :         tvprintf(fmt, args);</span></a>
<a name="710"><span class="lineNum">     710 </span>                :<span class="lineCov">    8708450 :         va_end(args);</span></a>
<a name="711"><span class="lineNum">     711 </span>                :<span class="lineCov">    8708450 : }</span></a>
<a name="712"><span class="lineNum">     712 </span>                :            : </a>
<a name="713"><span class="lineNum">     713 </span>                :            : #ifndef HAVE_FPUTS_UNLOCKED</a>
<a name="714"><span class="lineNum">     714 </span>                :            : # define fputs_unlocked fputs</a>
<a name="715"><span class="lineNum">     715 </span>                :            : #endif</a>
<a name="716"><span class="lineNum">     716 </span>                :            : </a>
<a name="717"><span class="lineNum">     717 </span>                :            : void</a>
<a name="718"><span class="lineNum">     718 </span>                :<span class="lineCov">   13265401 : tprints(const char *str)</span></a>
<a name="719"><span class="lineNum">     719 </span>                :            : {</a>
<a name="720"><span class="lineNum">     720 </span>        [<span class="branchCov" title="Branch 0 was taken 13265401 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">   13265401 :         if (current_tcp) {</span></a>
<a name="721"><span class="lineNum">     721 </span>                :<span class="lineCov">   13265401 :                 int n = fputs_unlocked(str, current_tcp->outf);</span></a>
<a name="722"><span class="lineNum">     722 </span>        [<span class="branchCov" title="Branch 0 was taken 13265401 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">   13265401 :                 if (n >= 0) {</span></a>
<a name="723"><span class="lineNum">     723 </span>                :<span class="lineCov">   13265401 :                         current_tcp->curcol += strlen(str);</span></a>
<a name="724"><span class="lineNum">     724 </span>                :<span class="lineCov">   13265401 :                         return;</span></a>
<a name="725"><span class="lineNum">     725 </span>                :            :                 }</a>
<a name="726"><span class="lineNum">     726 </span>                :            :                 /* very unlikely due to fputs_unlocked buffering */</a>
<a name="727"><span class="lineNum">     727 </span>                :<span class="lineNoCov">          0 :                 outf_perror(current_tcp);</span></a>
<a name="728"><span class="lineNum">     728 </span>                :            :         }</a>
<a name="729"><span class="lineNum">     729 </span>                :            : }</a>
<a name="730"><span class="lineNum">     730 </span>                :            : </a>
<a name="731"><span class="lineNum">     731 </span>                :            : void</a>
<a name="732"><span class="lineNum">     732 </span>                :<span class="lineCov">     116553 : tprints_comment(const char *const str)</span></a>
<a name="733"><span class="lineNum">     733 </span>                :            : {</a>
<a name="734"><span class="lineNum">     734 </span>  [<span class="branchCov" title="Branch 0 was taken 112930 times"> + </span><span class="branchCov" title="Branch 1 was taken 3623 times"> + </span><span class="branchCov" title="Branch 2 was taken 112907 times"> + </span><span class="branchCov" title="Branch 3 was taken 23 times"> + </span>]:<span class="lineCov">     116553 :         if (str && *str)</span></a>
<a name="735"><span class="lineNum">     735 </span>                :<span class="lineCov">     112907 :                 tprintf(" /* %s */", str);</span></a>
<a name="736"><span class="lineNum">     736 </span>                :<span class="lineCov">     116553 : }</span></a>
<a name="737"><span class="lineNum">     737 </span>                :            : </a>
<a name="738"><span class="lineNum">     738 </span>                :            : void</a>
<a name="739"><span class="lineNum">     739 </span>                :<span class="lineCov">      69958 : tprintf_comment(const char *fmt, ...)</span></a>
<a name="740"><span class="lineNum">     740 </span>                :            : {</a>
<a name="741"><span class="lineNum">     741 </span>  [<span class="branchCov" title="Branch 0 was taken 69958 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 69958 times"> + </span>]:<span class="lineCov">      69958 :         if (!fmt || !*fmt)</span></a>
<a name="742"><span class="lineNum">     742 </span>                :<span class="lineNoCov">          0 :                 return;</span></a>
<a name="743"><span class="lineNum">     743 </span>                :            : </a>
<a name="744"><span class="lineNum">     744 </span>                :<span class="lineCov">      69958 :         va_list args;</span></a>
<a name="745"><span class="lineNum">     745 </span>                :<span class="lineCov">      69958 :         va_start(args, fmt);</span></a>
<a name="746"><span class="lineNum">     746 </span>                :<span class="lineCov">      69958 :         tprint_comment_begin();</span></a>
<a name="747"><span class="lineNum">     747 </span>                :<span class="lineCov">      69958 :         tvprintf(fmt, args);</span></a>
<a name="748"><span class="lineNum">     748 </span>                :<span class="lineCov">      69958 :         tprint_comment_end();</span></a>
<a name="749"><span class="lineNum">     749 </span>                :<span class="lineCov">      69958 :         va_end(args);</span></a>
<a name="750"><span class="lineNum">     750 </span>                :            : }</a>
<a name="751"><span class="lineNum">     751 </span>                :            : </a>
<a name="752"><span class="lineNum">     752 </span>                :            : static void</a>
<a name="753"><span class="lineNum">     753 </span>                :<span class="lineCov">    1196597 : flush_tcp_output(const struct tcb *const tcp)</span></a>
<a name="754"><span class="lineNum">     754 </span>                :            : {</a>
<a name="755"><span class="lineNum">     755 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 1196596 times"> + </span>]:<span class="lineCov">    1196597 :         if (fflush(tcp->outf))</span></a>
<a name="756"><span class="lineNum">     756 </span>                :<span class="lineCov">          1 :                 outf_perror(tcp);</span></a>
<a name="757"><span class="lineNum">     757 </span>                :<span class="lineCov">    1196597 : }</span></a>
<a name="758"><span class="lineNum">     758 </span>                :            : </a>
<a name="759"><span class="lineNum">     759 </span>                :            : void</a>
<a name="760"><span class="lineNum">     760 </span>                :<span class="lineCov">    1157447 : line_ended(void)</span></a>
<a name="761"><span class="lineNum">     761 </span>                :            : {</a>
<a name="762"><span class="lineNum">     762 </span>        [<span class="branchCov" title="Branch 0 was taken 1157447 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">    1157447 :         if (current_tcp) {</span></a>
<a name="763"><span class="lineNum">     763 </span>                :<span class="lineCov">    1157447 :                 current_tcp->curcol = 0;</span></a>
<a name="764"><span class="lineNum">     764 </span>                :<span class="lineCov">    1157447 :                 flush_tcp_output(current_tcp);</span></a>
<a name="765"><span class="lineNum">     765 </span>                :            :         }</a>
<a name="766"><span class="lineNum">     766 </span>        [<span class="branchCov" title="Branch 0 was taken 1157447 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">    1157447 :         if (printing_tcp) {</span></a>
<a name="767"><span class="lineNum">     767 </span>                :<span class="lineCov">    1157447 :                 printing_tcp->curcol = 0;</span></a>
<a name="768"><span class="lineNum">     768 </span>                :<span class="lineCov">    1157447 :                 printing_tcp = NULL;</span></a>
<a name="769"><span class="lineNum">     769 </span>                :            :         }</a>
<a name="770"><span class="lineNum">     770 </span>                :<span class="lineCov">    1157447 : }</span></a>
<a name="771"><span class="lineNum">     771 </span>                :            : </a>
<a name="772"><span class="lineNum">     772 </span>                :            : static void</a>
<a name="773"><span class="lineNum">     773 </span>                :<span class="lineCov">  178084892 : set_current_tcp(const struct tcb *tcp)</span></a>
<a name="774"><span class="lineNum">     774 </span>                :            : {</a>
<a name="775"><span class="lineNum">     775 </span>                :<span class="lineCov">  178084892 :         current_tcp = (struct tcb *) tcp;</span></a>
<a name="776"><span class="lineNum">     776 </span>                :            : </a>
<a name="777"><span class="lineNum">     777 </span>                :            :         /* Sync current_personality and stuff */</a>
<a name="778"><span class="lineNum">     778 </span>        [<span class="branchCov" title="Branch 0 was taken 178038068 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">  178038068 :         if (current_tcp)</span></a>
<a name="779"><span class="lineNum">     779 </span>                :<span class="lineCov">  178038068 :                 set_personality(current_tcp->currpers);</span></a>
<a name="780"><span class="lineNum">     780 </span>                :<span class="lineCov">  178084892 : }</span></a>
<a name="781"><span class="lineNum">     781 </span>                :            : </a>
<a name="782"><span class="lineNum">     782 </span>                :            : static void</a>
<a name="783"><span class="lineNum">     783 </span>                :<span class="lineCov">     123372 : print_comm_str(const char *str, const size_t len)</span></a>
<a name="784"><span class="lineNum">     784 </span>                :            : {</a>
<a name="785"><span class="lineNum">     785 </span>        [<span class="branchCov" title="Branch 0 was taken 54 times"> + </span><span class="branchCov" title="Branch 1 was taken 123318 times"> + </span>]:<span class="lineCov">     123372 :         if (!len)</span></a>
<a name="786"><span class="lineNum">     786 </span>                :            :                 return;</a>
<a name="787"><span class="lineNum">     787 </span>                :<span class="lineCov">         54 :         tprints("<");</span></a>
<a name="788"><span class="lineNum">     788 </span>                :<span class="lineCov">         54 :         print_quoted_string_ex(str, len,</span></a>
<a name="789"><span class="lineNum">     789 </span>                :            :                                QUOTE_OMIT_LEADING_TRAILING_QUOTES, "<>");</a>
<a name="790"><span class="lineNum">     790 </span>                :<span class="lineCov">         54 :         tprints(">");</span></a>
<a name="791"><span class="lineNum">     791 </span>                :            : }</a>
<a name="792"><span class="lineNum">     792 </span>                :            : </a>
<a name="793"><span class="lineNum">     793 </span>                :            : void</a>
<a name="794"><span class="lineNum">     794 </span>                :<span class="lineCov">    1158333 : printleader(struct tcb *tcp)</span></a>
<a name="795"><span class="lineNum">     795 </span>                :            : {</a>
<a name="796"><span class="lineNum">     796 </span>                :            :         /* If -ff, "previous tcb we printed" is always the same as current,</a>
<a name="797"><span class="lineNum">     797 </span>                :            :          * because we have per-tcb output files.</a>
<a name="798"><span class="lineNum">     798 </span>                :            :          */</a>
<a name="799"><span class="lineNum">     799 </span>        [<span class="branchCov" title="Branch 0 was taken 540957 times"> + </span><span class="branchCov" title="Branch 1 was taken 617376 times"> + </span>]:<span class="lineCov">    1158333 :         if (output_separately)</span></a>
<a name="800"><span class="lineNum">     800 </span>                :<span class="lineCov">     540957 :                 printing_tcp = tcp;</span></a>
<a name="801"><span class="lineNum">     801 </span>                :            : </a>
<a name="802"><span class="lineNum">     802 </span>        [<span class="branchCov" title="Branch 0 was taken 541784 times"> + </span><span class="branchCov" title="Branch 1 was taken 616549 times"> + </span>]:<span class="lineCov">    1158333 :         if (printing_tcp) {</span></a>
<a name="803"><span class="lineNum">     803 </span>                :<span class="lineCov">     541784 :                 set_current_tcp(printing_tcp);</span></a>
<a name="804"><span class="lineNum">     804 </span>  [<span class="branchCov" title="Branch 0 was taken 541782 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span><span class="branchCov" title="Branch 2 was taken 808 times"> + </span><span class="branchCov" title="Branch 3 was taken 540974 times"> + </span>]:<span class="lineCov">     541784 :                 if (!tcp->staged_output_data && printing_tcp->curcol != 0 &&</span></a>
<a name="805"><span class="lineNum">     805 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 808 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">        808 :                     (!output_separately || printing_tcp == tcp)) {</span></a>
<a name="806"><span class="lineNum">     806 </span>                :            :                         /*</a>
<a name="807"><span class="lineNum">     807 </span>                :            :                          * case 1: we have a shared log (i.e. not -ff), and last line</a>
<a name="808"><span class="lineNum">     808 </span>                :            :                          * wasn't finished (same or different tcb, doesn't matter).</a>
<a name="809"><span class="lineNum">     809 </span>                :            :                          * case 2: split log, we are the same tcb, but our last line</a>
<a name="810"><span class="lineNum">     810 </span>                :            :                          * didn't finish ("SIGKILL nuked us after syscall entry" etc).</a>
<a name="811"><span class="lineNum">     811 </span>                :            :                          */</a>
<a name="812"><span class="lineNum">     812 </span>                :<span class="lineCov">        808 :                         tprints(" <unfinished ...>\n");</span></a>
<a name="813"><span class="lineNum">     813 </span>                :<span class="lineCov">        808 :                         printing_tcp->curcol = 0;</span></a>
<a name="814"><span class="lineNum">     814 </span>                :            :                 }</a>
<a name="815"><span class="lineNum">     815 </span>                :            :         }</a>
<a name="816"><span class="lineNum">     816 </span>                :            : </a>
<a name="817"><span class="lineNum">     817 </span>                :<span class="lineCov">    1158333 :         printing_tcp = tcp;</span></a>
<a name="818"><span class="lineNum">     818 </span>                :<span class="lineCov">    1158333 :         set_current_tcp(tcp);</span></a>
<a name="819"><span class="lineNum">     819 </span>                :<span class="lineCov">    1158333 :         current_tcp->curcol = 0;</span></a>
<a name="820"><span class="lineNum">     820 </span>                :            : </a>
<a name="821"><span class="lineNum">     821 </span>  [<span class="branchCov" title="Branch 0 was taken 1034994 times"> + </span><span class="branchCov" title="Branch 1 was taken 123339 times"> + </span><span class="branchCov" title="Branch 2 was taken 536148 times"> + </span><span class="branchCov" title="Branch 3 was taken 498846 times"> + </span> :<span class="lineCov">    1158333 :         if (print_pid_pfx || (nprocs > 1 && !outfname)) {</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 5 times"> + </span><span class="branchCov" title="Branch 5 was taken 536143 times"> + </span>]
<a name="822"><span class="lineNum">     822 </span>                :<span class="lineCov">     123344 :                 size_t len = is_number_in_set(DECODE_PID_COMM, decode_pid_set)</span></a>
<a name="823"><span class="lineNum">     823 </span>        [<span class="branchCov" title="Branch 0 was taken 26 times"> + </span><span class="branchCov" title="Branch 1 was taken 123318 times"> + </span>]:<span class="lineCov">     123344 :                              ? strlen(tcp->comm) : 0;</span></a>
<a name="824"><span class="lineNum">     824 </span>                :            : </a>
<a name="825"><span class="lineNum">     825 </span>        [<span class="branchCov" title="Branch 0 was taken 123339 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">     123344 :                 if (print_pid_pfx) {</span></a>
<a name="826"><span class="lineNum">     826 </span>        [<span class="branchCov" title="Branch 0 was taken 26 times"> + </span><span class="branchCov" title="Branch 1 was taken 123313 times"> + </span>]:<span class="lineCov">     123339 :                         if (len)</span></a>
<a name="827"><span class="lineNum">     827 </span>                :<span class="lineCov">         26 :                                 tprintf("%u", tcp->pid);</span></a>
<a name="828"><span class="lineNum">     828 </span>                :            :                         else</a>
<a name="829"><span class="lineNum">     829 </span>                :<span class="lineCov">     123313 :                                 tprintf("%-5u", tcp->pid);</span></a>
<a name="830"><span class="lineNum">     830 </span>                :            :                 } else {</a>
<a name="831"><span class="lineNum">     831 </span>                :<span class="lineCov">          5 :                         tprintf("[pid %5u", tcp->pid);</span></a>
<a name="832"><span class="lineNum">     832 </span>                :            :                 }</a>
<a name="833"><span class="lineNum">     833 </span>                :            : </a>
<a name="834"><span class="lineNum">     834 </span>                :<span class="lineCov">     123344 :                 print_comm_str(tcp->comm, len);</span></a>
<a name="835"><span class="lineNum">     835 </span>                :            : </a>
<a name="836"><span class="lineNum">     836 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 123339 times"> + </span>]:<span class="lineCov">     123344 :                 if (!print_pid_pfx)</span></a>
<a name="837"><span class="lineNum">     837 </span>                :<span class="lineCov">          5 :                         tprints("]");</span></a>
<a name="838"><span class="lineNum">     838 </span>                :<span class="lineCov">     123344 :                 tprints(" ");</span></a>
<a name="839"><span class="lineNum">     839 </span>                :            :         }</a>
<a name="840"><span class="lineNum">     840 </span>                :            : </a>
<a name="841"><span class="lineNum">     841 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="842"><span class="lineNum">     842 </span>                :<span class="lineCov">    1158333 :         char *context;</span></a>
<a name="843"><span class="lineNum">     843 </span>        [<span class="branchCov" title="Branch 0 was taken 656 times"> + </span><span class="branchCov" title="Branch 1 was taken 1157677 times"> + </span>]:<span class="lineCov">    1158333 :         if (!selinux_getpidcon(tcp, &context)) {</span></a>
<a name="844"><span class="lineNum">     844 </span>                :<span class="lineCov">        656 :                 tprintf("[%s] ", context);</span></a>
<a name="845"><span class="lineNum">     845 </span>                :<span class="lineCov">        656 :                 free(context);</span></a>
<a name="846"><span class="lineNum">     846 </span>                :            :         }</a>
<a name="847"><span class="lineNum">     847 </span>                :            : #endif</a>
<a name="848"><span class="lineNum">     848 </span>                :            : </a>
<a name="849"><span class="lineNum">     849 </span>        [<span class="branchCov" title="Branch 0 was taken 64 times"> + </span><span class="branchCov" title="Branch 1 was taken 1158269 times"> + </span>]:<span class="lineCov">    1158333 :         if (tflag_format) {</span></a>
<a name="850"><span class="lineNum">     850 </span>                :<span class="lineCov">         64 :                 struct timespec ts;</span></a>
<a name="851"><span class="lineNum">     851 </span>                :<span class="lineCov">         64 :                 clock_gettime(CLOCK_REALTIME, &ts);</span></a>
<a name="852"><span class="lineNum">     852 </span>                :            : </a>
<a name="853"><span class="lineNum">     853 </span>                :<span class="lineCov">         64 :                 time_t local = ts.tv_sec;</span></a>
<a name="854"><span class="lineNum">     854 </span>                :<span class="lineCov">         64 :                 char str[MAX(sizeof("HH:MM:SS"), sizeof(local) * 3)];</span></a>
<a name="855"><span class="lineNum">     855 </span>                :<span class="lineCov">         64 :                 struct tm *tm = localtime(&local);</span></a>
<a name="856"><span class="lineNum">     856 </span>                :            : </a>
<a name="857"><span class="lineNum">     857 </span>        [<span class="branchCov" title="Branch 0 was taken 64 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         64 :                 if (tm)</span></a>
<a name="858"><span class="lineNum">     858 </span>                :<span class="lineCov">         64 :                         strftime(str, sizeof(str), tflag_format, tm);</span></a>
<a name="859"><span class="lineNum">     859 </span>                :            :                 else</a>
<a name="860"><span class="lineNum">     860 </span>                :<span class="lineNoCov">          0 :                         xsprintf(str, "%lld", (long long) local);</span></a>
<a name="861"><span class="lineNum">     861 </span>        [<span class="branchCov" title="Branch 0 was taken 46 times"> + </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">         64 :                 if (tflag_width)</span></a>
<a name="862"><span class="lineNum">     862 </span>                :<span class="lineCov">         46 :                         tprintf("%s.%0*ld ", str, tflag_width,</span></a>
<a name="863"><span class="lineNum">     863 </span>                :<span class="lineCov">         46 :                                 (long) ts.tv_nsec / tflag_scale);</span></a>
<a name="864"><span class="lineNum">     864 </span>                :            :                 else</a>
<a name="865"><span class="lineNum">     865 </span>                :<span class="lineCov">         18 :                         tprintf("%s ", str);</span></a>
<a name="866"><span class="lineNum">     866 </span>                :            :         }</a>
<a name="867"><span class="lineNum">     867 </span>                :            : </a>
<a name="868"><span class="lineNum">     868 </span>        [<span class="branchCov" title="Branch 0 was taken 176 times"> + </span><span class="branchCov" title="Branch 1 was taken 1158157 times"> + </span>]:<span class="lineCov">    1158333 :         if (rflag) {</span></a>
<a name="869"><span class="lineNum">     869 </span>                :<span class="lineCov">        176 :                 struct timespec ts;</span></a>
<a name="870"><span class="lineNum">     870 </span>                :<span class="lineCov">        176 :                 clock_gettime(CLOCK_MONOTONIC, &ts);</span></a>
<a name="871"><span class="lineNum">     871 </span>                :            : </a>
<a name="872"><span class="lineNum">     872 </span>                :<span class="lineCov">        176 :                 static struct timespec ots;</span></a>
<a name="873"><span class="lineNum">     873 </span>        [<span class="branchCov" title="Branch 0 was taken 10 times"> + </span><span class="branchCov" title="Branch 1 was taken 166 times"> + </span>]:<span class="lineCov">        176 :                 if (ots.tv_sec == 0)</span></a>
<a name="874"><span class="lineNum">     874 </span>                :<span class="lineCov">         10 :                         ots = ts;</span></a>
<a name="875"><span class="lineNum">     875 </span>                :            : </a>
<a name="876"><span class="lineNum">     876 </span>                :<span class="lineCov">        176 :                 struct timespec dts;</span></a>
<a name="877"><span class="lineNum">     877 </span>                :<span class="lineCov">        176 :                 ts_sub(&dts, &ts, &ots);</span></a>
<a name="878"><span class="lineNum">     878 </span>                :<span class="lineCov">        176 :                 ots = ts;</span></a>
<a name="879"><span class="lineNum">     879 </span>                :            : </a>
<a name="880"><span class="lineNum">     880 </span>        [<span class="branchCov" title="Branch 0 was taken 176 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">        352 :                 tprintf("%s%6ld", tflag_format ? "(+" : "", (long) dts.tv_sec);</span></a>
<a name="881"><span class="lineNum">     881 </span>        [<span class="branchCov" title="Branch 0 was taken 174 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">        176 :                 if (rflag_width) {</span></a>
<a name="882"><span class="lineNum">     882 </span>                :<span class="lineCov">        174 :                         tprintf(".%0*ld",</span></a>
<a name="883"><span class="lineNum">     883 </span>                :<span class="lineCov">        174 :                                 rflag_width, (long) dts.tv_nsec / rflag_scale);</span></a>
<a name="884"><span class="lineNum">     884 </span>                :            :                 }</a>
<a name="885"><span class="lineNum">     885 </span>        [<span class="branchCov" title="Branch 0 was taken 176 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">        352 :                 tprints(tflag_format ? ") " : " ");</span></a>
<a name="886"><span class="lineNum">     886 </span>                :            :         }</a>
<a name="887"><span class="lineNum">     887 </span>                :            : </a>
<a name="888"><span class="lineNum">     888 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 1158332 times"> + </span>]:<span class="lineCov">    1158333 :         if (nflag)</span></a>
<a name="889"><span class="lineNum">     889 </span>                :<span class="lineCov">          1 :                 print_syscall_number(tcp);</span></a>
<a name="890"><span class="lineNum">     890 </span>                :            : </a>
<a name="891"><span class="lineNum">     891 </span>        [<span class="branchCov" title="Branch 0 was taken 48 times"> + </span><span class="branchCov" title="Branch 1 was taken 1158285 times"> + </span>]:<span class="lineCov">    1158333 :         if (iflag)</span></a>
<a name="892"><span class="lineNum">     892 </span>                :<span class="lineCov">         48 :                 print_instruction_pointer(tcp);</span></a>
<a name="893"><span class="lineNum">     893 </span>                :<span class="lineCov">    1158333 : }</span></a>
<a name="894"><span class="lineNum">     894 </span>                :            : </a>
<a name="895"><span class="lineNum">     895 </span>                :            : void</a>
<a name="896"><span class="lineNum">     896 </span>                :<span class="lineCov">    1140310 : tabto(void)</span></a>
<a name="897"><span class="lineNum">     897 </span>                :            : {</a>
<a name="898"><span class="lineNum">     898 </span>        [<span class="branchCov" title="Branch 0 was taken 70883 times"> + </span><span class="branchCov" title="Branch 1 was taken 1069427 times"> + </span>]:<span class="lineCov">    1140310 :         if (current_tcp->curcol < acolumn)</span></a>
<a name="899"><span class="lineNum">     899 </span>                :<span class="lineCov">      70883 :                 tprints(acolumn_spaces + current_tcp->curcol);</span></a>
<a name="900"><span class="lineNum">     900 </span>                :<span class="lineCov">    1140310 : }</span></a>
<a name="901"><span class="lineNum">     901 </span>                :            : </a>
<a name="902"><span class="lineNum">     902 </span>                :            : /* Should be only called directly *after successful attach* to a tracee.</a>
<a name="903"><span class="lineNum">     903 </span>                :            :  * Otherwise, "strace -oFILE -ff -p<nonexistant_pid>"</a>
<a name="904"><span class="lineNum">     904 </span>                :            :  * may create bogus empty FILE.<nonexistant_pid>, and then die.</a>
<a name="905"><span class="lineNum">     905 </span>                :            :  */</a>
<a name="906"><span class="lineNum">     906 </span>                :            : static void</a>
<a name="907"><span class="lineNum">     907 </span>                :<span class="lineCov">      46824 : after_successful_attach(struct tcb *tcp, const unsigned int flags)</span></a>
<a name="908"><span class="lineNum">     908 </span>                :            : {</a>
<a name="909"><span class="lineNum">     909 </span>                :<span class="lineCov">      46824 :         tcp->flags |= TCB_ATTACHED | TCB_STARTUP | flags;</span></a>
<a name="910"><span class="lineNum">     910 </span>                :<span class="lineCov">      46824 :         tcp->outf = shared_log; /* if not -ff mode, the same file is for all */</span></a>
<a name="911"><span class="lineNum">     911 </span>        [<span class="branchCov" title="Branch 0 was taken 7686 times"> + </span><span class="branchCov" title="Branch 1 was taken 39138 times"> + </span>]:<span class="lineCov">      46824 :         if (output_separately) {</span></a>
<a name="912"><span class="lineNum">     912 </span>                :<span class="lineCov">       7686 :                 char name[PATH_MAX];</span></a>
<a name="913"><span class="lineNum">     913 </span>                :<span class="lineCov">       7686 :                 xsprintf(name, "%s.%u", outfname, tcp->pid);</span></a>
<a name="914"><span class="lineNum">     914 </span>                :<span class="lineCov">       7686 :                 tcp->outf = strace_fopen(name);</span></a>
<a name="915"><span class="lineNum">     915 </span>                :            :         }</a>
<a name="916"><span class="lineNum">     916 </span>                :            : </a>
<a name="917"><span class="lineNum">     917 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="918"><span class="lineNum">     918 </span>                :            :         if (stack_trace_enabled)</a>
<a name="919"><span class="lineNum">     919 </span>                :            :                 unwind_tcb_init(tcp);</a>
<a name="920"><span class="lineNum">     920 </span>                :            : #endif</a>
<a name="921"><span class="lineNum">     921 </span>                :<span class="lineCov">      46824 : }</span></a>
<a name="922"><span class="lineNum">     922 </span>                :            : </a>
<a name="923"><span class="lineNum">     923 </span>                :            : static void</a>
<a name="924"><span class="lineNum">     924 </span>                :<span class="lineCov">      17718 : expand_tcbtab(void)</span></a>
<a name="925"><span class="lineNum">     925 </span>                :            : {</a>
<a name="926"><span class="lineNum">     926 </span>                :            :         /* Allocate some (more) TCBs (and expand the table).</a>
<a name="927"><span class="lineNum">     927 </span>                :            :            We don't want to relocate the TCBs because our</a>
<a name="928"><span class="lineNum">     928 </span>                :            :            callers have pointers and it would be a pain.</a>
<a name="929"><span class="lineNum">     929 </span>                :            :            So tcbtab is a table of pointers.  Since we never</a>
<a name="930"><span class="lineNum">     930 </span>                :            :            free the TCBs, we allocate a single chunk of many.  */</a>
<a name="931"><span class="lineNum">     931 </span>                :<span class="lineCov">      17718 :         size_t old_tcbtabsize;</span></a>
<a name="932"><span class="lineNum">     932 </span>                :<span class="lineCov">      17718 :         struct tcb *newtcbs;</span></a>
<a name="933"><span class="lineNum">     933 </span>                :            : </a>
<a name="934"><span class="lineNum">     934 </span>                :<span class="lineCov">      17718 :         old_tcbtabsize = tcbtabsize;</span></a>
<a name="935"><span class="lineNum">     935 </span>                :            : </a>
<a name="936"><span class="lineNum">     936 </span>                :<span class="lineCov">      17718 :         tcbtab = xgrowarray(tcbtab, &tcbtabsize, sizeof(tcbtab[0]));</span></a>
<a name="937"><span class="lineNum">     937 </span>                :<span class="lineCov">      17718 :         newtcbs = xcalloc(tcbtabsize - old_tcbtabsize, sizeof(newtcbs[0]));</span></a>
<a name="938"><span class="lineNum">     938 </span>                :            : </a>
<a name="939"><span class="lineNum">     939 </span>                :<span class="lineCov">      17718 :         for (struct tcb **tcb_ptr = tcbtab + old_tcbtabsize;</span></a>
<a name="940"><span class="lineNum">     940 </span>        [<span class="branchCov" title="Branch 0 was taken 293021 times"> + </span><span class="branchCov" title="Branch 1 was taken 17718 times"> + </span>]:<span class="lineCov">     310739 :              tcb_ptr < tcbtab + tcbtabsize;</span></a>
<a name="941"><span class="lineNum">     941 </span>                :<span class="lineCov">     293021 :              ++tcb_ptr, ++newtcbs)</span></a>
<a name="942"><span class="lineNum">     942 </span>                :<span class="lineCov">     293021 :                 *tcb_ptr = newtcbs;</span></a>
<a name="943"><span class="lineNum">     943 </span>                :<span class="lineCov">      17718 : }</span></a>
<a name="944"><span class="lineNum">     944 </span>                :            : </a>
<a name="945"><span class="lineNum">     945 </span>                :            : static char *</a>
<a name="946"><span class="lineNum">     946 </span>                :<span class="lineCov">         44 : strip_trailing_newlines(char *str)</span></a>
<a name="947"><span class="lineNum">     947 </span>                :            : {</a>
<a name="948"><span class="lineNum">     948 </span>                :<span class="lineCov">         44 :         size_t len = strlen(str);</span></a>
<a name="949"><span class="lineNum">     949 </span>        [<span class="branchCov" title="Branch 0 was taken 66 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         66 :         for (; len > 0; --len) {</span></a>
<a name="950"><span class="lineNum">     950 </span>        [<span class="branchCov" title="Branch 0 was taken 22 times"> + </span><span class="branchCov" title="Branch 1 was taken 44 times"> + </span>]:<span class="lineCov">         66 :                 if (str[len - 1] != '\n')</span></a>
<a name="951"><span class="lineNum">     951 </span>                :            :                         break;</a>
<a name="952"><span class="lineNum">     952 </span>                :            :         }</a>
<a name="953"><span class="lineNum">     953 </span>                :<span class="lineCov">         44 :         str[len] = '\0';</span></a>
<a name="954"><span class="lineNum">     954 </span>                :<span class="lineCov">         44 :         return str;</span></a>
<a name="955"><span class="lineNum">     955 </span>                :            : }</a>
<a name="956"><span class="lineNum">     956 </span>                :            : </a>
<a name="957"><span class="lineNum">     957 </span>                :            : /* Load the contents of /proc/$pid/comm into `buf'. */</a>
<a name="958"><span class="lineNum">     958 </span>                :            : static void</a>
<a name="959"><span class="lineNum">     959 </span>                :<span class="lineCov">         58 : load_pid_comm(int pid, char *buf, size_t buf_size)</span></a>
<a name="960"><span class="lineNum">     960 </span>                :            : {</a>
<a name="961"><span class="lineNum">     961 </span>                :<span class="lineCov">         58 :         static const char comm_path[] = "/proc/%d/comm";</span></a>
<a name="962"><span class="lineNum">     962 </span>                :<span class="lineCov">         58 :         char procfile[sizeof(comm_path) + sizeof(int) * 3];</span></a>
<a name="963"><span class="lineNum">     963 </span>                :            : </a>
<a name="964"><span class="lineNum">     964 </span>                :<span class="lineCov">         58 :         buf[0] = '\0';</span></a>
<a name="965"><span class="lineNum">     965 </span>                :<span class="lineCov">         58 :         xsprintf(procfile, comm_path, pid);</span></a>
<a name="966"><span class="lineNum">     966 </span>                :<span class="lineCov">         58 :         FILE *fp = fopen_stream(procfile, "r");</span></a>
<a name="967"><span class="lineNum">     967 </span>        [<span class="branchCov" title="Branch 0 was taken 44 times"> + </span><span class="branchCov" title="Branch 1 was taken 14 times"> + </span>]:<span class="lineCov">         58 :         if (fp) {</span></a>
<a name="968"><span class="lineNum">     968 </span>        [<span class="branchCov" title="Branch 0 was taken 44 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         44 :                 if (fgets(buf, buf_size, fp))</span></a>
<a name="969"><span class="lineNum">     969 </span>                :<span class="lineCov">         44 :                         strip_trailing_newlines(buf);</span></a>
<a name="970"><span class="lineNum">     970 </span>                :<span class="lineCov">         44 :                 fclose(fp);</span></a>
<a name="971"><span class="lineNum">     971 </span>                :            :         }</a>
<a name="972"><span class="lineNum">     972 </span>                :<span class="lineCov">         58 : }</span></a>
<a name="973"><span class="lineNum">     973 </span>                :            : </a>
<a name="974"><span class="lineNum">     974 </span>                :            : void</a>
<a name="975"><span class="lineNum">     975 </span>                :<span class="lineCov">         28 : print_pid_comm(int pid)</span></a>
<a name="976"><span class="lineNum">     976 </span>                :            : {</a>
<a name="977"><span class="lineNum">     977 </span>                :<span class="lineCov">         28 :         char buf[PROC_COMM_LEN];</span></a>
<a name="978"><span class="lineNum">     978 </span>                :<span class="lineCov">         28 :         load_pid_comm(pid, buf, sizeof(buf));</span></a>
<a name="979"><span class="lineNum">     979 </span>                :<span class="lineCov">         28 :         print_comm_str(buf, strlen(buf));</span></a>
<a name="980"><span class="lineNum">     980 </span>                :<span class="lineCov">         28 : }</span></a>
<a name="981"><span class="lineNum">     981 </span>                :            : </a>
<a name="982"><span class="lineNum">     982 </span>                :            : void</a>
<a name="983"><span class="lineNum">     983 </span>                :<span class="lineCov">      65361 : maybe_load_task_comm(struct tcb *tcp)</span></a>
<a name="984"><span class="lineNum">     984 </span>                :            : {</a>
<a name="985"><span class="lineNum">     985 </span>        [<span class="branchCov" title="Branch 0 was taken 30 times"> + </span><span class="branchCov" title="Branch 1 was taken 65331 times"> + </span>]:<span class="lineCov">      65361 :         if (!is_number_in_set(DECODE_PID_COMM, decode_pid_set))</span></a>
<a name="986"><span class="lineNum">     986 </span>                :            :                 return;</a>
<a name="987"><span class="lineNum">     987 </span>                :            : </a>
<a name="988"><span class="lineNum">     988 </span>                :<span class="lineCov">         30 :         load_pid_comm(get_proc_pid(tcp->pid), tcp->comm, sizeof(tcp->comm));</span></a>
<a name="989"><span class="lineNum">     989 </span>                :            : }</a>
<a name="990"><span class="lineNum">     990 </span>                :            : </a>
<a name="991"><span class="lineNum">     991 </span>                :            : static struct tcb *</a>
<a name="992"><span class="lineNum">     992 </span>                :<span class="lineCov">      46845 : alloctcb(int pid)</span></a>
<a name="993"><span class="lineNum">     993 </span>                :            : {</a>
<a name="994"><span class="lineNum">     994 </span>        [<span class="branchCov" title="Branch 0 was taken 17718 times"> + </span><span class="branchCov" title="Branch 1 was taken 29127 times"> + </span>]:<span class="lineCov">      46845 :         if (nprocs == tcbtabsize)</span></a>
<a name="995"><span class="lineNum">     995 </span>                :<span class="lineCov">      17718 :                 expand_tcbtab();</span></a>
<a name="996"><span class="lineNum">     996 </span>                :            : </a>
<a name="997"><span class="lineNum">     997 </span>        [<span class="branchCov" title="Branch 0 was taken 2144649 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">    2144649 :         for (unsigned int i = 0; i < tcbtabsize; ++i) {</span></a>
<a name="998"><span class="lineNum">     998 </span>                :<span class="lineCov">    2144649 :                 struct tcb *tcp = tcbtab[i];</span></a>
<a name="999"><span class="lineNum">     999 </span>        [<span class="branchCov" title="Branch 0 was taken 46845 times"> + </span><span class="branchCov" title="Branch 1 was taken 2097804 times"> + </span>]:<span class="lineCov">    2144649 :                 if (!tcp->pid) {</span></a>
<a name="1000"><span class="lineNum">    1000 </span>                :<span class="lineCov">      46845 :                         memset(tcp, 0, sizeof(*tcp));</span></a>
<a name="1001"><span class="lineNum">    1001 </span>                :<span class="lineCov">      46845 :                         list_init(&tcp->wait_list);</span></a>
<a name="1002"><span class="lineNum">    1002 </span>                :<span class="lineCov">      46845 :                         tcp->pid = pid;</span></a>
<a name="1003"><span class="lineNum">    1003 </span>                :<span class="lineCov">      46845 :                         maybe_load_task_comm(tcp);</span></a>
<a name="1004"><span class="lineNum">    1004 </span>                :            : #if SUPPORTED_PERSONALITIES > 1</a>
<a name="1005"><span class="lineNum">    1005 </span>                :<span class="lineCov">      46845 :                         tcp->currpers = current_personality;</span></a>
<a name="1006"><span class="lineNum">    1006 </span>                :            : #endif</a>
<a name="1007"><span class="lineNum">    1007 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="1008"><span class="lineNum">    1008 </span>                :<span class="lineCov">      46845 :                         tcp->last_dirfd = AT_FDCWD;</span></a>
<a name="1009"><span class="lineNum">    1009 </span>                :            : #endif</a>
<a name="1010"><span class="lineNum">    1010 </span>                :<span class="lineCov">      46845 :                         nprocs++;</span></a>
<a name="1011"><span class="lineNum">    1011 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 46833 times"> + </span>]:<span class="lineCov">      46845 :                         debug_msg("new tcb for pid %d, active tcbs:%d",</span></a>
<a name="1012"><span class="lineNum">    1012 </span>                :            :                                   tcp->pid, nprocs);</a>
<a name="1013"><span class="lineNum">    1013 </span>                :<span class="lineCov">      46845 :                         return tcp;</span></a>
<a name="1014"><span class="lineNum">    1014 </span>                :            :                 }</a>
<a name="1015"><span class="lineNum">    1015 </span>                :            :         }</a>
<a name="1016"><span class="lineNum">    1016 </span>                :<span class="lineNoCov">          0 :         error_msg_and_die("bug in alloctcb");</span></a>
<a name="1017"><span class="lineNum">    1017 </span>                :            : }</a>
<a name="1018"><span class="lineNum">    1018 </span>                :            : </a>
<a name="1019"><span class="lineNum">    1019 </span>                :            : void *</a>
<a name="1020"><span class="lineNum">    1020 </span>                :<span class="lineCov">       8319 : get_tcb_priv_data(const struct tcb *tcp)</span></a>
<a name="1021"><span class="lineNum">    1021 </span>                :            : {</a>
<a name="1022"><span class="lineNum">    1022 </span>                :<span class="lineCov">       8319 :         return tcp->_priv_data;</span></a>
<a name="1023"><span class="lineNum">    1023 </span>                :            : }</a>
<a name="1024"><span class="lineNum">    1024 </span>                :            : </a>
<a name="1025"><span class="lineNum">    1025 </span>                :            : int</a>
<a name="1026"><span class="lineNum">    1026 </span>                :<span class="lineCov">       8835 : set_tcb_priv_data(struct tcb *tcp, void *const priv_data,</span></a>
<a name="1027"><span class="lineNum">    1027 </span>                :            :                   void (*const free_priv_data)(void *))</a>
<a name="1028"><span class="lineNum">    1028 </span>                :            : {</a>
<a name="1029"><span class="lineNum">    1029 </span>        [<span class="branchCov" title="Branch 0 was taken 8819 times"> + </span><span class="branchCov" title="Branch 1 was taken 16 times"> + </span>]:<span class="lineCov">       8835 :         if (tcp->_priv_data)</span></a>
<a name="1030"><span class="lineNum">    1030 </span>                :            :                 return -1;</a>
<a name="1031"><span class="lineNum">    1031 </span>                :            : </a>
<a name="1032"><span class="lineNum">    1032 </span>                :<span class="lineCov">       8819 :         tcp->_free_priv_data = free_priv_data;</span></a>
<a name="1033"><span class="lineNum">    1033 </span>                :<span class="lineCov">       8819 :         tcp->_priv_data = priv_data;</span></a>
<a name="1034"><span class="lineNum">    1034 </span>                :            : </a>
<a name="1035"><span class="lineNum">    1035 </span>                :<span class="lineCov">       8819 :         return 0;</span></a>
<a name="1036"><span class="lineNum">    1036 </span>                :            : }</a>
<a name="1037"><span class="lineNum">    1037 </span>                :            : </a>
<a name="1038"><span class="lineNum">    1038 </span>                :            : void</a>
<a name="1039"><span class="lineNum">    1039 </span>                :<span class="lineCov">   88066006 : free_tcb_priv_data(struct tcb *tcp)</span></a>
<a name="1040"><span class="lineNum">    1040 </span>                :            : {</a>
<a name="1041"><span class="lineNum">    1041 </span>        [<span class="branchCov" title="Branch 0 was taken 8503 times"> + </span><span class="branchCov" title="Branch 1 was taken 88057503 times"> + </span>]:<span class="lineCov">   88066006 :         if (tcp->_priv_data) {</span></a>
<a name="1042"><span class="lineNum">    1042 </span>        [<span class="branchCov" title="Branch 0 was taken 1060 times"> + </span><span class="branchCov" title="Branch 1 was taken 7443 times"> + </span>]:<span class="lineCov">       8503 :                 if (tcp->_free_priv_data) {</span></a>
<a name="1043"><span class="lineNum">    1043 </span>                :<span class="lineCov">       1060 :                         tcp->_free_priv_data(tcp->_priv_data);</span></a>
<a name="1044"><span class="lineNum">    1044 </span>                :<span class="lineCov">       1060 :                         tcp->_free_priv_data = NULL;</span></a>
<a name="1045"><span class="lineNum">    1045 </span>                :            :                 }</a>
<a name="1046"><span class="lineNum">    1046 </span>                :<span class="lineCov">       8503 :                 tcp->_priv_data = NULL;</span></a>
<a name="1047"><span class="lineNum">    1047 </span>                :            :         }</a>
<a name="1048"><span class="lineNum">    1048 </span>                :<span class="lineCov">   88066006 : }</span></a>
<a name="1049"><span class="lineNum">    1049 </span>                :            : </a>
<a name="1050"><span class="lineNum">    1050 </span>                :            : static void</a>
<a name="1051"><span class="lineNum">    1051 </span>                :<span class="lineCov">      46853 : droptcb(struct tcb *tcp)</span></a>
<a name="1052"><span class="lineNum">    1052 </span>                :            : {</a>
<a name="1053"><span class="lineNum">    1053 </span>        [<span class="branchCov" title="Branch 0 was taken 46853 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      46853 :         if (tcp->pid == 0)</span></a>
<a name="1054"><span class="lineNum">    1054 </span>                :            :                 return;</a>
<a name="1055"><span class="lineNum">    1055 </span>                :            : </a>
<a name="1056"><span class="lineNum">    1056 </span>  [<span class="branchCov" title="Branch 0 was taken 74 times"> + </span><span class="branchCov" title="Branch 1 was taken 46779 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 74 times"> + </span>]:<span class="lineCov">      46853 :         if (cflag && debug_flag) {</span></a>
<a name="1057"><span class="lineNum">    1057 </span>                :<span class="lineNoCov">          0 :                 struct timespec dt;</span></a>
<a name="1058"><span class="lineNum">    1058 </span>                :            : </a>
<a name="1059"><span class="lineNum">    1059 </span>                :<span class="lineNoCov">          0 :                 ts_sub(&dt, &tcp->stime, &tcp->atime);</span></a>
<a name="1060"><span class="lineNum">    1060 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 debug_func_msg("pid %d: %.9f seconds of system time spent "</span></a>
<a name="1061"><span class="lineNum">    1061 </span>                :            :                                "since attach", tcp->pid, ts_float(&dt));</a>
<a name="1062"><span class="lineNum">    1062 </span>                :            :         }</a>
<a name="1063"><span class="lineNum">    1063 </span>                :            : </a>
<a name="1064"><span class="lineNum">    1064 </span>        [<span class="branchCov" title="Branch 0 was taken 140559 times"> + </span><span class="branchCov" title="Branch 1 was taken 46853 times"> + </span>]:<span class="lineCov">     187412 :         for (int p = 0; p < SUPPORTED_PERSONALITIES; ++p)</span></a>
<a name="1065"><span class="lineNum">    1065 </span>                :<span class="lineCov">     140559 :                 free(tcp->inject_vec[p]);</span></a>
<a name="1066"><span class="lineNum">    1066 </span>                :            : </a>
<a name="1067"><span class="lineNum">    1067 </span>                :<span class="lineCov">      46853 :         free_tcb_priv_data(tcp);</span></a>
<a name="1068"><span class="lineNum">    1068 </span>                :            : </a>
<a name="1069"><span class="lineNum">    1069 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="1070"><span class="lineNum">    1070 </span>                :            :         if (stack_trace_enabled)</a>
<a name="1071"><span class="lineNum">    1071 </span>                :            :                 unwind_tcb_fin(tcp);</a>
<a name="1072"><span class="lineNum">    1072 </span>                :            : #endif</a>
<a name="1073"><span class="lineNum">    1073 </span>                :            : </a>
<a name="1074"><span class="lineNum">    1074 </span>                :            : #ifdef HAVE_LINUX_KVM_H</a>
<a name="1075"><span class="lineNum">    1075 </span>                :<span class="lineCov">      46853 :         kvm_vcpu_info_free(tcp);</span></a>
<a name="1076"><span class="lineNum">    1076 </span>                :            : #endif</a>
<a name="1077"><span class="lineNum">    1077 </span>                :            : </a>
<a name="1078"><span class="lineNum">    1078 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 46852 times"> + </span>]:<span class="lineCov">      46853 :         if (tcp->mmap_cache)</span></a>
<a name="1079"><span class="lineNum">    1079 </span>                :<span class="lineCov">          1 :                 tcp->mmap_cache->free_fn(tcp, __func__);</span></a>
<a name="1080"><span class="lineNum">    1080 </span>                :            : </a>
<a name="1081"><span class="lineNum">    1081 </span>                :<span class="lineCov">      46853 :         nprocs--;</span></a>
<a name="1082"><span class="lineNum">    1082 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 46841 times"> + </span>]:<span class="lineCov">      46853 :         debug_msg("dropped tcb for pid %d, %d remain", tcp->pid, nprocs);</span></a>
<a name="1083"><span class="lineNum">    1083 </span>                :            : </a>
<a name="1084"><span class="lineNum">    1084 </span>        [<span class="branchCov" title="Branch 0 was taken 46824 times"> + </span><span class="branchCov" title="Branch 1 was taken 29 times"> + </span>]:<span class="lineCov">      46853 :         if (tcp->outf) {</span></a>
<a name="1085"><span class="lineNum">    1085 </span>                :<span class="lineCov">      46824 :                 bool publish = true;</span></a>
<a name="1086"><span class="lineNum">    1086 </span>        [<span class="branchCov" title="Branch 0 was taken 16 times"> + </span><span class="branchCov" title="Branch 1 was taken 46808 times"> + </span>]:<span class="lineCov">      46824 :                 if (!is_complete_set(status_set, NUMBER_OF_STATUSES)) {</span></a>
<a name="1087"><span class="lineNum">    1087 </span>                :<span class="lineCov">         16 :                         publish = is_number_in_set(STATUS_DETACHED, status_set);</span></a>
<a name="1088"><span class="lineNum">    1088 </span>                :<span class="lineCov">         16 :                         strace_close_memstream(tcp, publish);</span></a>
<a name="1089"><span class="lineNum">    1089 </span>                :            :                 }</a>
<a name="1090"><span class="lineNum">    1090 </span>                :            : </a>
<a name="1091"><span class="lineNum">    1091 </span>        [<span class="branchCov" title="Branch 0 was taken 7686 times"> + </span><span class="branchCov" title="Branch 1 was taken 39138 times"> + </span>]:<span class="lineCov">      46824 :                 if (output_separately) {</span></a>
<a name="1092"><span class="lineNum">    1092 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 7686 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">       7686 :                         if (tcp->curcol != 0 && publish)</span></a>
<a name="1093"><span class="lineNum">    1093 </span>                :<span class="lineNoCov">          0 :                                 fprintf(tcp->outf, " <detached ...>\n");</span></a>
<a name="1094"><span class="lineNum">    1094 </span>                :<span class="lineCov">       7686 :                         fclose(tcp->outf);</span></a>
<a name="1095"><span class="lineNum">    1095 </span>                :            :                 } else {</a>
<a name="1096"><span class="lineNum">    1096 </span>  [<span class="branchCov" title="Branch 0 was taken 59 times"> + </span><span class="branchCov" title="Branch 1 was taken 39079 times"> + </span><span class="branchCov" title="Branch 2 was taken 59 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span> :<span class="lineCov">      39138 :                         if (printing_tcp == tcp && tcp->curcol != 0 && publish)</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 59 times"> + </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span>]
<a name="1097"><span class="lineNum">    1097 </span>                :<span class="lineCov">         59 :                                 fprintf(tcp->outf, " <detached ...>\n");</span></a>
<a name="1098"><span class="lineNum">    1098 </span>                :<span class="lineCov">      39138 :                         flush_tcp_output(tcp);</span></a>
<a name="1099"><span class="lineNum">    1099 </span>                :            :                 }</a>
<a name="1100"><span class="lineNum">    1100 </span>                :            :         }</a>
<a name="1101"><span class="lineNum">    1101 </span>                :            : </a>
<a name="1102"><span class="lineNum">    1102 </span>        [<span class="branchCov" title="Branch 0 was taken 46824 times"> + </span><span class="branchCov" title="Branch 1 was taken 29 times"> + </span>]:<span class="lineCov">      46853 :         if (current_tcp == tcp)</span></a>
<a name="1103"><span class="lineNum">    1103 </span>                :<span class="lineCov">      46824 :                 set_current_tcp(NULL);</span></a>
<a name="1104"><span class="lineNum">    1104 </span>        [<span class="branchCov" title="Branch 0 was taken 59 times"> + </span><span class="branchCov" title="Branch 1 was taken 46794 times"> + </span>]:<span class="lineCov">      46853 :         if (printing_tcp == tcp)</span></a>
<a name="1105"><span class="lineNum">    1105 </span>                :<span class="lineCov">         59 :                 printing_tcp = NULL;</span></a>
<a name="1106"><span class="lineNum">    1106 </span>                :            : </a>
<a name="1107"><span class="lineNum">    1107 </span>                :<span class="lineCov">      46853 :         list_remove(&tcp->wait_list);</span></a>
<a name="1108"><span class="lineNum">    1108 </span>                :            : </a>
<a name="1109"><span class="lineNum">    1109 </span>                :<span class="lineCov">      46853 :         memset(tcp, 0, sizeof(*tcp));</span></a>
<a name="1110"><span class="lineNum">    1110 </span>                :            : }</a>
<a name="1111"><span class="lineNum">    1111 </span>                :            : </a>
<a name="1112"><span class="lineNum">    1112 </span>                :            : /* Detach traced process.</a>
<a name="1113"><span class="lineNum">    1113 </span>                :            :  * Never call DETACH twice on the same process as both unattached and</a>
<a name="1114"><span class="lineNum">    1114 </span>                :            :  * attached-unstopped processes give the same ESRCH.  For unattached process we</a>
<a name="1115"><span class="lineNum">    1115 </span>                :            :  * would SIGSTOP it and wait for its SIGSTOP notification forever.</a>
<a name="1116"><span class="lineNum">    1116 </span>                :            :  */</a>
<a name="1117"><span class="lineNum">    1117 </span>                :            : static void</a>
<a name="1118"><span class="lineNum">    1118 </span>                :<span class="lineCov">         34 : detach(struct tcb *tcp)</span></a>
<a name="1119"><span class="lineNum">    1119 </span>                :            : {</a>
<a name="1120"><span class="lineNum">    1120 </span>                :<span class="lineCov">         34 :         int error;</span></a>
<a name="1121"><span class="lineNum">    1121 </span>                :<span class="lineCov">         34 :         int status;</span></a>
<a name="1122"><span class="lineNum">    1122 </span>                :            : </a>
<a name="1123"><span class="lineNum">    1123 </span>                :            :         /*</a>
<a name="1124"><span class="lineNum">    1124 </span>                :            :          * Linux wrongly insists the child be stopped</a>
<a name="1125"><span class="lineNum">    1125 </span>                :            :          * before detaching.  Arghh.  We go through hoops</a>
<a name="1126"><span class="lineNum">    1126 </span>                :            :          * to make a clean break of things.</a>
<a name="1127"><span class="lineNum">    1127 </span>                :            :          */</a>
<a name="1128"><span class="lineNum">    1128 </span>                :            : </a>
<a name="1129"><span class="lineNum">    1129 </span>        [<span class="branchCov" title="Branch 0 was taken 28 times"> + </span><span class="branchCov" title="Branch 1 was taken 6 times"> + </span>]:<span class="lineCov">         34 :         if (!(tcp->flags & TCB_ATTACHED))</span></a>
<a name="1130"><span class="lineNum">    1130 </span>                :<span class="lineCov">         28 :                 goto drop;</span></a>
<a name="1131"><span class="lineNum">    1131 </span>                :            : </a>
<a name="1132"><span class="lineNum">    1132 </span>                :            :         /* We attached but possibly didn't see the expected SIGSTOP.</a>
<a name="1133"><span class="lineNum">    1133 </span>                :            :          * We must catch exactly one as otherwise the detached process</a>
<a name="1134"><span class="lineNum">    1134 </span>                :            :          * would be left stopped (process state T).</a>
<a name="1135"><span class="lineNum">    1135 </span>                :            :          */</a>
<a name="1136"><span class="lineNum">    1136 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 6 times"> + </span>]:<span class="lineCov">          6 :         if (tcp->flags & TCB_IGNORE_ONE_SIGSTOP)</span></a>
<a name="1137"><span class="lineNum">    1137 </span>                :<span class="lineNoCov">          0 :                 goto wait_loop;</span></a>
<a name="1138"><span class="lineNum">    1138 </span>                :            : </a>
<a name="1139"><span class="lineNum">    1139 </span>                :<span class="lineCov">          6 :         error = ptrace(PTRACE_DETACH, tcp->pid, 0, 0);</span></a>
<a name="1140"><span class="lineNum">    1140 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          6 :         if (!error) {</span></a>
<a name="1141"><span class="lineNum">    1141 </span>                :            :                 /* On a clear day, you can see forever. */</a>
<a name="1142"><span class="lineNum">    1142 </span>                :<span class="lineCov">          2 :                 goto drop;</span></a>
<a name="1143"><span class="lineNum">    1143 </span>                :            :         }</a>
<a name="1144"><span class="lineNum">    1144 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :         if (errno != ESRCH) {</span></a>
<a name="1145"><span class="lineNum">    1145 </span>                :            :                 /* Shouldn't happen. */</a>
<a name="1146"><span class="lineNum">    1146 </span>                :<span class="lineNoCov">          0 :                 perror_func_msg("ptrace(PTRACE_DETACH,%u)", tcp->pid);</span></a>
<a name="1147"><span class="lineNum">    1147 </span>                :<span class="lineNoCov">          0 :                 goto drop;</span></a>
<a name="1148"><span class="lineNum">    1148 </span>                :            :         }</a>
<a name="1149"><span class="lineNum">    1149 </span>                :            :         /* ESRCH: process is either not stopped or doesn't exist. */</a>
<a name="1150"><span class="lineNum">    1150 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :         if (my_tkill(tcp->pid, 0) < 0) {</span></a>
<a name="1151"><span class="lineNum">    1151 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (errno != ESRCH)</span></a>
<a name="1152"><span class="lineNum">    1152 </span>                :            :                         /* Shouldn't happen. */</a>
<a name="1153"><span class="lineNum">    1153 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg("tkill(%u,0)", tcp->pid);</span></a>
<a name="1154"><span class="lineNum">    1154 </span>                :            :                 /* else: process doesn't exist. */</a>
<a name="1155"><span class="lineNum">    1155 </span>                :<span class="lineNoCov">          0 :                 goto drop;</span></a>
<a name="1156"><span class="lineNum">    1156 </span>                :            :         }</a>
<a name="1157"><span class="lineNum">    1157 </span>                :            :         /* Process is not stopped, need to stop it. */</a>
<a name="1158"><span class="lineNum">    1158 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          4 :         if (use_seize) {</span></a>
<a name="1159"><span class="lineNum">    1159 </span>                :            :                 /*</a>
<a name="1160"><span class="lineNum">    1160 </span>                :            :                  * With SEIZE, tracee can be in group-stop already.</a>
<a name="1161"><span class="lineNum">    1161 </span>                :            :                  * In this state sending it another SIGSTOP does nothing.</a>
<a name="1162"><span class="lineNum">    1162 </span>                :            :                  * Need to use INTERRUPT.</a>
<a name="1163"><span class="lineNum">    1163 </span>                :            :                  * Testcase: trying to ^C a "strace -p <stopped_process>".</a>
<a name="1164"><span class="lineNum">    1164 </span>                :            :                  */</a>
<a name="1165"><span class="lineNum">    1165 </span>                :<span class="lineCov">          4 :                 error = ptrace(PTRACE_INTERRUPT, tcp->pid, 0, 0);</span></a>
<a name="1166"><span class="lineNum">    1166 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          4 :                 if (!error)</span></a>
<a name="1167"><span class="lineNum">    1167 </span>                :<span class="lineCov">          4 :                         goto wait_loop;</span></a>
<a name="1168"><span class="lineNum">    1168 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (errno != ESRCH)</span></a>
<a name="1169"><span class="lineNum">    1169 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg("ptrace(PTRACE_INTERRUPT,%u)", tcp->pid);</span></a>
<a name="1170"><span class="lineNum">    1170 </span>                :            :         } else {</a>
<a name="1171"><span class="lineNum">    1171 </span>                :<span class="lineNoCov">          0 :                 error = my_tkill(tcp->pid, SIGSTOP);</span></a>
<a name="1172"><span class="lineNum">    1172 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (!error)</span></a>
<a name="1173"><span class="lineNum">    1173 </span>                :<span class="lineNoCov">          0 :                         goto wait_loop;</span></a>
<a name="1174"><span class="lineNum">    1174 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (errno != ESRCH)</span></a>
<a name="1175"><span class="lineNum">    1175 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg("tkill(%u,SIGSTOP)", tcp->pid);</span></a>
<a name="1176"><span class="lineNum">    1176 </span>                :            :         }</a>
<a name="1177"><span class="lineNum">    1177 </span>                :            :         /* Either process doesn't exist, or some weird error. */</a>
<a name="1178"><span class="lineNum">    1178 </span>                :<span class="lineNoCov">          0 :         goto drop;</span></a>
<a name="1179"><span class="lineNum">    1179 </span>                :            : </a>
<a name="1180"><span class="lineNum">    1180 </span>                :            :  wait_loop:</a>
<a name="1181"><span class="lineNum">    1181 </span>                :            :         /* We end up here in three cases:</a>
<a name="1182"><span class="lineNum">    1182 </span>                :            :          * 1. We sent PTRACE_INTERRUPT (use_seize case)</a>
<a name="1183"><span class="lineNum">    1183 </span>                :            :          * 2. We sent SIGSTOP (!use_seize)</a>
<a name="1184"><span class="lineNum">    1184 </span>                :            :          * 3. Attach SIGSTOP was already pending (TCB_IGNORE_ONE_SIGSTOP set)</a>
<a name="1185"><span class="lineNum">    1185 </span>                :            :          */</a>
<a name="1186"><span class="lineNum">    1186 </span>                :<span class="lineCov">          4 :         for (;;) {</span></a>
<a name="1187"><span class="lineNum">    1187 </span>                :<span class="lineCov">          4 :                 unsigned int sig;</span></a>
<a name="1188"><span class="lineNum">    1188 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :                 if (waitpid(tcp->pid, &status, __WALL) < 0) {</span></a>
<a name="1189"><span class="lineNum">    1189 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                         if (errno == EINTR)</span></a>
<a name="1190"><span class="lineNum">    1190 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1191"><span class="lineNum">    1191 </span>                :            :                         /*</a>
<a name="1192"><span class="lineNum">    1192 </span>                :            :                          * if (errno == ECHILD) break;</a>
<a name="1193"><span class="lineNum">    1193 </span>                :            :                          * ^^^  WRONG! We expect this PID to exist,</a>
<a name="1194"><span class="lineNum">    1194 </span>                :            :                          * and want to emit a message otherwise:</a>
<a name="1195"><span class="lineNum">    1195 </span>                :            :                          */</a>
<a name="1196"><span class="lineNum">    1196 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg("waitpid(%u)", tcp->pid);</span></a>
<a name="1197"><span class="lineNum">    1197 </span>                :<span class="lineNoCov">          0 :                         break;</span></a>
<a name="1198"><span class="lineNum">    1198 </span>                :            :                 }</a>
<a name="1199"><span class="lineNum">    1199 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :                 if (!WIFSTOPPED(status)) {</span></a>
<a name="1200"><span class="lineNum">    1200 </span>                :            :                         /*</a>
<a name="1201"><span class="lineNum">    1201 </span>                :            :                          * Tracee exited or was killed by signal.</a>
<a name="1202"><span class="lineNum">    1202 </span>                :            :                          * We shouldn't normally reach this place:</a>
<a name="1203"><span class="lineNum">    1203 </span>                :            :                          * we don't want to consume exit status.</a>
<a name="1204"><span class="lineNum">    1204 </span>                :            :                          * Consider "strace -p PID" being ^C-ed:</a>
<a name="1205"><span class="lineNum">    1205 </span>                :            :                          * we want merely to detach from PID.</a>
<a name="1206"><span class="lineNum">    1206 </span>                :            :                          *</a>
<a name="1207"><span class="lineNum">    1207 </span>                :            :                          * However, we _can_ end up here if tracee</a>
<a name="1208"><span class="lineNum">    1208 </span>                :            :                          * was SIGKILLed.</a>
<a name="1209"><span class="lineNum">    1209 </span>                :            :                          */</a>
<a name="1210"><span class="lineNum">    1210 </span>                :            :                         break;</a>
<a name="1211"><span class="lineNum">    1211 </span>                :            :                 }</a>
<a name="1212"><span class="lineNum">    1212 </span>                :<span class="lineCov">          4 :                 sig = WSTOPSIG(status);</span></a>
<a name="1213"><span class="lineNum">    1213 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :                 debug_msg("detach wait: event:%d sig:%d",</span></a>
<a name="1214"><span class="lineNum">    1214 </span>                :            :                           (unsigned) status >> 16, sig);</a>
<a name="1215"><span class="lineNum">    1215 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          4 :                 if (use_seize) {</span></a>
<a name="1216"><span class="lineNum">    1216 </span>                :<span class="lineCov">          4 :                         unsigned event = (unsigned)status >> 16;</span></a>
<a name="1217"><span class="lineNum">    1217 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :                         if (event == PTRACE_EVENT_STOP /*&& sig == SIGTRAP*/) {</span></a>
<a name="1218"><span class="lineNum">    1218 </span>                :            :                                 /*</a>
<a name="1219"><span class="lineNum">    1219 </span>                :            :                                  * sig == SIGTRAP: PTRACE_INTERRUPT stop.</a>
<a name="1220"><span class="lineNum">    1220 </span>                :            :                                  * sig == other: process was already stopped</a>
<a name="1221"><span class="lineNum">    1221 </span>                :            :                                  * with this stopping sig (see tests/detach-stopped).</a>
<a name="1222"><span class="lineNum">    1222 </span>                :            :                                  * Looks like re-injecting this sig is not necessary</a>
<a name="1223"><span class="lineNum">    1223 </span>                :            :                                  * in DETACH for the tracee to remain stopped.</a>
<a name="1224"><span class="lineNum">    1224 </span>                :            :                                  */</a>
<a name="1225"><span class="lineNum">    1225 </span>                :            :                                 sig = 0;</a>
<a name="1226"><span class="lineNum">    1226 </span>                :            :                         }</a>
<a name="1227"><span class="lineNum">    1227 </span>                :            :                         /*</a>
<a name="1228"><span class="lineNum">    1228 </span>                :            :                          * PTRACE_INTERRUPT is not guaranteed to produce</a>
<a name="1229"><span class="lineNum">    1229 </span>                :            :                          * the above event if other ptrace-stop is pending.</a>
<a name="1230"><span class="lineNum">    1230 </span>                :            :                          * See tests/detach-sleeping testcase:</a>
<a name="1231"><span class="lineNum">    1231 </span>                :            :                          * strace got SIGINT while tracee is sleeping.</a>
<a name="1232"><span class="lineNum">    1232 </span>                :            :                          * We sent PTRACE_INTERRUPT.</a>
<a name="1233"><span class="lineNum">    1233 </span>                :            :                          * We see syscall exit, not PTRACE_INTERRUPT stop.</a>
<a name="1234"><span class="lineNum">    1234 </span>                :            :                          * We won't get PTRACE_INTERRUPT stop</a>
<a name="1235"><span class="lineNum">    1235 </span>                :            :                          * if we would CONT now. Need to DETACH.</a>
<a name="1236"><span class="lineNum">    1236 </span>                :            :                          */</a>
<a name="1237"><span class="lineNum">    1237 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          2 :                         if (sig == syscall_trap_sig)</span></a>
<a name="1238"><span class="lineNum">    1238 </span>                :<span class="lineCov">          2 :                                 sig = 0;</span></a>
<a name="1239"><span class="lineNum">    1239 </span>                :            :                         /* else: not sure in which case we can be here.</a>
<a name="1240"><span class="lineNum">    1240 </span>                :            :                          * Signal stop? Inject it while detaching.</a>
<a name="1241"><span class="lineNum">    1241 </span>                :            :                          */</a>
<a name="1242"><span class="lineNum">    1242 </span>                :<span class="lineCov">          4 :                         ptrace_restart(PTRACE_DETACH, tcp, sig);</span></a>
<a name="1243"><span class="lineNum">    1243 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="1244"><span class="lineNum">    1244 </span>                :            :                 }</a>
<a name="1245"><span class="lineNum">    1245 </span>                :            :                 /* Note: this check has to be after use_seize check */</a>
<a name="1246"><span class="lineNum">    1246 </span>                :            :                 /* (else, in use_seize case SIGSTOP will be mistreated) */</a>
<a name="1247"><span class="lineNum">    1247 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (sig == SIGSTOP) {</span></a>
<a name="1248"><span class="lineNum">    1248 </span>                :            :                         /* Detach, suppressing SIGSTOP */</a>
<a name="1249"><span class="lineNum">    1249 </span>                :<span class="lineNoCov">          0 :                         ptrace_restart(PTRACE_DETACH, tcp, 0);</span></a>
<a name="1250"><span class="lineNum">    1250 </span>                :<span class="lineNoCov">          0 :                         break;</span></a>
<a name="1251"><span class="lineNum">    1251 </span>                :            :                 }</a>
<a name="1252"><span class="lineNum">    1252 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (sig == syscall_trap_sig)</span></a>
<a name="1253"><span class="lineNum">    1253 </span>                :<span class="lineNoCov">          0 :                         sig = 0;</span></a>
<a name="1254"><span class="lineNum">    1254 </span>                :            :                 /* Can't detach just yet, may need to wait for SIGSTOP */</a>
<a name="1255"><span class="lineNum">    1255 </span>                :<span class="lineNoCov">          0 :                 error = ptrace_restart(PTRACE_CONT, tcp, sig);</span></a>
<a name="1256"><span class="lineNum">    1256 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (error < 0) {</span></a>
<a name="1257"><span class="lineNum">    1257 </span>                :            :                         /* Should not happen.</a>
<a name="1258"><span class="lineNum">    1258 </span>                :            :                          * Note: ptrace_restart returns 0 on ESRCH, so it's not it.</a>
<a name="1259"><span class="lineNum">    1259 </span>                :            :                          * ptrace_restart already emitted error message.</a>
<a name="1260"><span class="lineNum">    1260 </span>                :            :                          */</a>
<a name="1261"><span class="lineNum">    1261 </span>                :            :                         break;</a>
<a name="1262"><span class="lineNum">    1262 </span>                :            :                 }</a>
<a name="1263"><span class="lineNum">    1263 </span>                :            :         }</a>
<a name="1264"><span class="lineNum">    1264 </span>                :            : </a>
<a name="1265"><span class="lineNum">    1265 </span>                :<span class="lineNoCov">          0 :  drop:</span></a>
<a name="1266"><span class="lineNum">    1266 </span>        [<span class="branchCov" title="Branch 0 was taken 31 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         34 :         if (!is_number_in_set(QUIET_ATTACH, quiet_set)</span></a>
<a name="1267"><span class="lineNum">    1267 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 26 times"> + </span>]:<span class="lineCov">         31 :             && (tcp->flags & TCB_ATTACHED))</span></a>
<a name="1268"><span class="lineNum">    1268 </span>                :<span class="lineCov">          5 :                 error_msg("Process %u detached", tcp->pid);</span></a>
<a name="1269"><span class="lineNum">    1269 </span>                :            : </a>
<a name="1270"><span class="lineNum">    1270 </span>                :<span class="lineCov">         34 :         droptcb(tcp);</span></a>
<a name="1271"><span class="lineNum">    1271 </span>                :<span class="lineCov">         34 : }</span></a>
<a name="1272"><span class="lineNum">    1272 </span>                :            : </a>
<a name="1273"><span class="lineNum">    1273 </span>                :            : static void</a>
<a name="1274"><span class="lineNum">    1274 </span>                :<span class="lineCov">         44 : process_opt_p_list(char *opt)</span></a>
<a name="1275"><span class="lineNum">    1275 </span>                :            : {</a>
<a name="1276"><span class="lineNum">    1276 </span>        [<span class="branchCov" title="Branch 0 was taken 46 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         46 :         while (*opt) {</span></a>
<a name="1277"><span class="lineNum">    1277 </span>                :            :                 /*</a>
<a name="1278"><span class="lineNum">    1278 </span>                :            :                  * We accept -p PID,PID; -p "`pidof PROG`"; -p "`pgrep PROG`".</a>
<a name="1279"><span class="lineNum">    1279 </span>                :            :                  * pidof uses space as delim, pgrep uses newline. :(</a>
<a name="1280"><span class="lineNum">    1280 </span>                :            :                  */</a>
<a name="1281"><span class="lineNum">    1281 </span>                :<span class="lineCov">         46 :                 int pid;</span></a>
<a name="1282"><span class="lineNum">    1282 </span>                :<span class="lineCov">         46 :                 char *delim = opt + strcspn(opt, "\n\t ,");</span></a>
<a name="1283"><span class="lineNum">    1283 </span>                :<span class="lineCov">         46 :                 char c = *delim;</span></a>
<a name="1284"><span class="lineNum">    1284 </span>                :            : </a>
<a name="1285"><span class="lineNum">    1285 </span>                :<span class="lineCov">         46 :                 *delim = '\0';</span></a>
<a name="1286"><span class="lineNum">    1286 </span>                :<span class="lineCov">         46 :                 pid = string_to_uint(opt);</span></a>
<a name="1287"><span class="lineNum">    1287 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 38 times"> + </span>]:<span class="lineCov">         46 :                 if (pid <= 0) {</span></a>
<a name="1288"><span class="lineNum">    1288 </span>                :<span class="lineCov">          8 :                         error_msg_and_die("Invalid process id: '%s'", opt);</span></a>
<a name="1289"><span class="lineNum">    1289 </span>                :            :                 }</a>
<a name="1290"><span class="lineNum">    1290 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 38 times"> + </span>]:<span class="lineCov">         38 :                 if (pid == strace_tracer_pid) {</span></a>
<a name="1291"><span class="lineNum">    1291 </span>                :<span class="lineNoCov">          0 :                         error_msg_and_die("I'm sorry, I can't let you do that, Dave.");</span></a>
<a name="1292"><span class="lineNum">    1292 </span>                :            :                 }</a>
<a name="1293"><span class="lineNum">    1293 </span>                :<span class="lineCov">         38 :                 *delim = c;</span></a>
<a name="1294"><span class="lineNum">    1294 </span>                :<span class="lineCov">         38 :                 alloctcb(pid);</span></a>
<a name="1295"><span class="lineNum">    1295 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 36 times"> + </span>]:<span class="lineCov">         38 :                 if (c == '\0')</span></a>
<a name="1296"><span class="lineNum">    1296 </span>                :            :                         break;</a>
<a name="1297"><span class="lineNum">    1297 </span>                :<span class="lineCov">          2 :                 opt = delim + 1;</span></a>
<a name="1298"><span class="lineNum">    1298 </span>                :            :         }</a>
<a name="1299"><span class="lineNum">    1299 </span>                :<span class="lineCov">         36 : }</span></a>
<a name="1300"><span class="lineNum">    1300 </span>                :            : </a>
<a name="1301"><span class="lineNum">    1301 </span>                :            : static void</a>
<a name="1302"><span class="lineNum">    1302 </span>                :<span class="lineCov">         18 : attach_tcb(struct tcb *const tcp)</span></a>
<a name="1303"><span class="lineNum">    1303 </span>                :            : {</a>
<a name="1304"><span class="lineNum">    1304 </span>                :<span class="lineCov">         18 :         const char *ptrace_attach_cmd;</span></a>
<a name="1305"><span class="lineNum">    1305 </span>                :            : </a>
<a name="1306"><span class="lineNum">    1306 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         18 :         if (ptrace_attach_or_seize(tcp->pid, &ptrace_attach_cmd) < 0) {</span></a>
<a name="1307"><span class="lineNum">    1307 </span>                :<span class="lineCov">          1 :                 perror_msg("attach: ptrace(%s, %d)",</span></a>
<a name="1308"><span class="lineNum">    1308 </span>                :            :                            ptrace_attach_cmd, tcp->pid);</a>
<a name="1309"><span class="lineNum">    1309 </span>                :<span class="lineCov">          1 :                 droptcb(tcp);</span></a>
<a name="1310"><span class="lineNum">    1310 </span>                :<span class="lineCov">          1 :                 return;</span></a>
<a name="1311"><span class="lineNum">    1311 </span>                :            :         }</a>
<a name="1312"><span class="lineNum">    1312 </span>                :            : </a>
<a name="1313"><span class="lineNum">    1313 </span>                :<span class="lineCov">         17 :         after_successful_attach(tcp, TCB_GRABBED | post_attach_sigstop);</span></a>
<a name="1314"><span class="lineNum">    1314 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         17 :         debug_msg("attach to pid %d (main) succeeded", tcp->pid);</span></a>
<a name="1315"><span class="lineNum">    1315 </span>                :            : </a>
<a name="1316"><span class="lineNum">    1316 </span>                :<span class="lineCov">         17 :         static const char task_path[] = "/proc/%d/task";</span></a>
<a name="1317"><span class="lineNum">    1317 </span>                :<span class="lineCov">         17 :         char procdir[sizeof(task_path) + sizeof(int) * 3];</span></a>
<a name="1318"><span class="lineNum">    1318 </span>                :<span class="lineCov">         17 :         DIR *dir;</span></a>
<a name="1319"><span class="lineNum">    1319 </span>                :<span class="lineCov">         17 :         unsigned int ntid = 0, nerr = 0;</span></a>
<a name="1320"><span class="lineNum">    1320 </span>                :            : </a>
<a name="1321"><span class="lineNum">    1321 </span>  [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 14 times"> + </span><span class="branchCov" title="Branch 2 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span> :<span class="lineCov">         20 :         if (followfork && tcp->pid != strace_child &&</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span>]
<a name="1322"><span class="lineNum">    1322 </span>                :<span class="lineCov">          3 :             xsprintf(procdir, task_path, get_proc_pid(tcp->pid)) > 0 &&</span></a>
<a name="1323"><span class="lineNum">    1323 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          3 :             (dir = opendir(procdir)) != NULL) {</span></a>
<a name="1324"><span class="lineNum">    1324 </span>                :            :                 struct_dirent *de;</a>
<a name="1325"><span class="lineNum">    1325 </span>                :            : </a>
<a name="1326"><span class="lineNum">    1326 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         15 :                 while ((de = read_dir(dir)) != NULL) {</span></a>
<a name="1327"><span class="lineNum">    1327 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 12 times"> + </span>]:<span class="lineCov">         12 :                         if (de->d_fileno == 0)</span></a>
<a name="1328"><span class="lineNum">    1328 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1329"><span class="lineNum">    1329 </span>                :            : </a>
<a name="1330"><span class="lineNum">    1330 </span>                :<span class="lineCov">         12 :                         int tid = string_to_uint(de->d_name);</span></a>
<a name="1331"><span class="lineNum">    1331 </span>  [<span class="branchCov" title="Branch 0 was taken 6 times"> + </span><span class="branchCov" title="Branch 1 was taken 6 times"> + </span><span class="branchCov" title="Branch 2 was taken 3 times"> + </span><span class="branchCov" title="Branch 3 was taken 3 times"> + </span>]:<span class="lineCov">         12 :                         if (tid <= 0 || tid == tcp->pid)</span></a>
<a name="1332"><span class="lineNum">    1332 </span>                :<span class="lineCov">          9 :                                 continue;</span></a>
<a name="1333"><span class="lineNum">    1333 </span>                :            : </a>
<a name="1334"><span class="lineNum">    1334 </span>                :<span class="lineCov">          3 :                         ++ntid;</span></a>
<a name="1335"><span class="lineNum">    1335 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          3 :                         if (ptrace_attach_or_seize(tid, &ptrace_attach_cmd) < 0)</span></a>
<a name="1336"><span class="lineNum">    1336 </span>                :            :                         {</a>
<a name="1337"><span class="lineNum">    1337 </span>                :<span class="lineNoCov">          0 :                                 ++nerr;</span></a>
<a name="1338"><span class="lineNum">    1338 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                                 debug_perror_msg("attach: ptrace(%s, %d)",</span></a>
<a name="1339"><span class="lineNum">    1339 </span>                :            :                                                  ptrace_attach_cmd, tid);</a>
<a name="1340"><span class="lineNum">    1340 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1341"><span class="lineNum">    1341 </span>                :            :                         }</a>
<a name="1342"><span class="lineNum">    1342 </span>                :            : </a>
<a name="1343"><span class="lineNum">    1343 </span>                :<span class="lineCov">          3 :                         after_successful_attach(alloctcb(tid),</span></a>
<a name="1344"><span class="lineNum">    1344 </span>                :<span class="lineCov">          3 :                                                 TCB_GRABBED | post_attach_sigstop);</span></a>
<a name="1345"><span class="lineNum">    1345 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         18 :                         debug_msg("attach to pid %d succeeded", tid);</span></a>
<a name="1346"><span class="lineNum">    1346 </span>                :            :                 }</a>
<a name="1347"><span class="lineNum">    1347 </span>                :            : </a>
<a name="1348"><span class="lineNum">    1348 </span>                :<span class="lineCov">          3 :                 closedir(dir);</span></a>
<a name="1349"><span class="lineNum">    1349 </span>                :            :         }</a>
<a name="1350"><span class="lineNum">    1350 </span>                :            : </a>
<a name="1351"><span class="lineNum">    1351 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 10 times"> + </span>]:<span class="lineCov">         17 :         if (!is_number_in_set(QUIET_ATTACH, quiet_set)) {</span></a>
<a name="1352"><span class="lineNum">    1352 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 7 times"> + </span>]:<span class="lineCov">          7 :                 if (ntid > nerr)</span></a>
<a name="1353"><span class="lineNum">    1353 </span>                :<span class="lineNoCov">          0 :                         error_msg("Process %u attached"</span></a>
<a name="1354"><span class="lineNum">    1354 </span>                :            :                                   " with %u threads",</a>
<a name="1355"><span class="lineNum">    1355 </span>                :<span class="lineNoCov">          0 :                                   tcp->pid, ntid - nerr + 1);</span></a>
<a name="1356"><span class="lineNum">    1356 </span>                :            :                 else</a>
<a name="1357"><span class="lineNum">    1357 </span>                :<span class="lineCov">          7 :                         error_msg("Process %u attached",</span></a>
<a name="1358"><span class="lineNum">    1358 </span>                :            :                                   tcp->pid);</a>
<a name="1359"><span class="lineNum">    1359 </span>                :            :         }</a>
<a name="1360"><span class="lineNum">    1360 </span>                :            : }</a>
<a name="1361"><span class="lineNum">    1361 </span>                :            : </a>
<a name="1362"><span class="lineNum">    1362 </span>                :            : static void</a>
<a name="1363"><span class="lineNum">    1363 </span>                :<span class="lineCov">      17330 : startup_attach(void)</span></a>
<a name="1364"><span class="lineNum">    1364 </span>                :            : {</a>
<a name="1365"><span class="lineNum">    1365 </span>                :<span class="lineCov">      17330 :         pid_t parent_pid = strace_tracer_pid;</span></a>
<a name="1366"><span class="lineNum">    1366 </span>                :<span class="lineCov">      17330 :         struct tcb *tcp;</span></a>
<a name="1367"><span class="lineNum">    1367 </span>                :            : </a>
<a name="1368"><span class="lineNum">    1368 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17330 times"> + </span>]:<span class="lineCov">      17330 :         if (daemonized_tracer) {</span></a>
<a name="1369"><span class="lineNum">    1369 </span>                :<span class="lineNoCov">          0 :                 pid_t pid = fork();</span></a>
<a name="1370"><span class="lineNum">    1370 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span>]:<span class="lineCov">          8 :                 if (pid < 0)</span></a>
<a name="1371"><span class="lineNum">    1371 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg_and_die("fork");</span></a>
<a name="1372"><span class="lineNum">    1372 </span>                :            : </a>
<a name="1373"><span class="lineNum">    1373 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span>]:<span class="lineCov">          8 :                 if (pid) { /* parent */</span></a>
<a name="1374"><span class="lineNum">    1374 </span>                :            :                         /*</a>
<a name="1375"><span class="lineNum">    1375 </span>                :            :                          * Wait for grandchild to attach to straced process</a>
<a name="1376"><span class="lineNum">    1376 </span>                :            :                          * (grandparent). Grandchild SIGKILLs us after it attached.</a>
<a name="1377"><span class="lineNum">    1377 </span>                :            :                          * Grandparent's wait() is unblocked by our death,</a>
<a name="1378"><span class="lineNum">    1378 </span>                :            :                          * it proceeds to exec the straced program.</a>
<a name="1379"><span class="lineNum">    1379 </span>                :            :                          */</a>
<a name="1380"><span class="lineNum">    1380 </span>                :<span class="lineNoCov">          0 :                         pause();</span></a>
<a name="1381"><span class="lineNum">    1381 </span>                :<span class="lineNoCov">          0 :                         _exit(0); /* paranoia */</span></a>
<a name="1382"><span class="lineNum">    1382 </span>                :            :                 }</a>
<a name="1383"><span class="lineNum">    1383 </span>                :            :                 /* grandchild */</a>
<a name="1384"><span class="lineNum">    1384 </span>                :            :                 /* We will be the tracer process. Remember our new pid: */</a>
<a name="1385"><span class="lineNum">    1385 </span>                :<span class="lineCov">          8 :                 strace_tracer_pid = getpid();</span></a>
<a name="1386"><span class="lineNum">    1386 </span>                :            : </a>
<a name="1387"><span class="lineNum">    1387 </span>     [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span><span class="branchCov" title="Branch 2 was taken 3 times"> + </span>]:<span class="lineCov">          8 :                 switch (daemonized_tracer) {</span></a>
<a name="1388"><span class="lineNum">    1388 </span>                :<span class="lineCov">          3 :                 case DAEMONIZE_NEW_PGROUP:</span></a>
<a name="1389"><span class="lineNum">    1389 </span>                :            :                         /*</a>
<a name="1390"><span class="lineNum">    1390 </span>                :            :                          * If -D is passed twice, create a new process group,</a>
<a name="1391"><span class="lineNum">    1391 </span>                :            :                          * so we won't be killed by kill(0, ...).</a>
<a name="1392"><span class="lineNum">    1392 </span>                :            :                          */</a>
<a name="1393"><span class="lineNum">    1393 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          3 :                         if (setpgid(0, 0) < 0)</span></a>
<a name="1394"><span class="lineNum">    1394 </span>                :<span class="lineNoCov">          0 :                                 perror_msg_and_die("Cannot create a new"</span></a>
<a name="1395"><span class="lineNum">    1395 </span>                :            :                                                    " process group");</a>
<a name="1396"><span class="lineNum">    1396 </span>                :            :                         break;</a>
<a name="1397"><span class="lineNum">    1397 </span>                :<span class="lineCov">          3 :                 case DAEMONIZE_NEW_SESSION:</span></a>
<a name="1398"><span class="lineNum">    1398 </span>                :            :                         /*</a>
<a name="1399"><span class="lineNum">    1399 </span>                :            :                          * If -D is passed thrice, create a new session,</a>
<a name="1400"><span class="lineNum">    1400 </span>                :            :                          * so we won't be killed upon session termination.</a>
<a name="1401"><span class="lineNum">    1401 </span>                :            :                          */</a>
<a name="1402"><span class="lineNum">    1402 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          3 :                         if (setsid() < 0)</span></a>
<a name="1403"><span class="lineNum">    1403 </span>                :<span class="lineNoCov">          0 :                                 perror_msg_and_die("Cannot create a new"</span></a>
<a name="1404"><span class="lineNum">    1404 </span>                :            :                                                    " session");</a>
<a name="1405"><span class="lineNum">    1405 </span>                :            :                         break;</a>
<a name="1406"><span class="lineNum">    1406 </span>                :            :                 }</a>
<a name="1407"><span class="lineNum">    1407 </span>                :            :         }</a>
<a name="1408"><span class="lineNum">    1408 </span>                :            : </a>
<a name="1409"><span class="lineNum">    1409 </span>        [<span class="branchCov" title="Branch 0 was taken 277408 times"> + </span><span class="branchCov" title="Branch 1 was taken 17338 times"> + </span>]:<span class="lineCov">     294746 :         for (unsigned int tcbi = 0; tcbi < tcbtabsize; ++tcbi) {</span></a>
<a name="1410"><span class="lineNum">    1410 </span>                :<span class="lineCov">     277408 :                 tcp = tcbtab[tcbi];</span></a>
<a name="1411"><span class="lineNum">    1411 </span>                :            : </a>
<a name="1412"><span class="lineNum">    1412 </span>        [<span class="branchCov" title="Branch 0 was taken 260064 times"> + </span><span class="branchCov" title="Branch 1 was taken 17344 times"> + </span>]:<span class="lineCov">     277408 :                 if (!tcp->pid)</span></a>
<a name="1413"><span class="lineNum">    1413 </span>                :<span class="lineCov">     260064 :                         continue;</span></a>
<a name="1414"><span class="lineNum">    1414 </span>                :            : </a>
<a name="1415"><span class="lineNum">    1415 </span>                :            :                 /* Is this a process we should attach to, but not yet attached? */</a>
<a name="1416"><span class="lineNum">    1416 </span>        [<span class="branchCov" title="Branch 0 was taken 17326 times"> + </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">      17344 :                 if (tcp->flags & TCB_ATTACHED)</span></a>
<a name="1417"><span class="lineNum">    1417 </span>                :<span class="lineCov">      17326 :                         continue; /* no, we already attached it */</span></a>
<a name="1418"><span class="lineNum">    1418 </span>                :            : </a>
<a name="1419"><span class="lineNum">    1419 </span>  [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 18 times"> + </span>]:<span class="lineCov">         18 :                 if (tcp->pid == parent_pid || tcp->pid == strace_tracer_pid) {</span></a>
<a name="1420"><span class="lineNum">    1420 </span>                :<span class="lineNoCov">          0 :                         errno = EPERM;</span></a>
<a name="1421"><span class="lineNum">    1421 </span>                :<span class="lineNoCov">          0 :                         perror_msg("attach: pid %d", tcp->pid);</span></a>
<a name="1422"><span class="lineNum">    1422 </span>                :<span class="lineNoCov">          0 :                         droptcb(tcp);</span></a>
<a name="1423"><span class="lineNum">    1423 </span>                :<span class="lineNoCov">          0 :                         continue;</span></a>
<a name="1424"><span class="lineNum">    1424 </span>                :            :                 }</a>
<a name="1425"><span class="lineNum">    1425 </span>                :            : </a>
<a name="1426"><span class="lineNum">    1426 </span>                :<span class="lineCov">         18 :                 attach_tcb(tcp);</span></a>
<a name="1427"><span class="lineNum">    1427 </span>                :            : </a>
<a name="1428"><span class="lineNum">    1428 </span>        [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         18 :                 if (interrupted)</span></a>
<a name="1429"><span class="lineNum">    1429 </span>                :            :                         return;</a>
<a name="1430"><span class="lineNum">    1430 </span>                :            :         } /* for each tcbtab[] */</a>
<a name="1431"><span class="lineNum">    1431 </span>                :            : </a>
<a name="1432"><span class="lineNum">    1432 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 17330 times"> + </span>]:<span class="lineCov">      17338 :         if (daemonized_tracer) {</span></a>
<a name="1433"><span class="lineNum">    1433 </span>                :            :                 /*</a>
<a name="1434"><span class="lineNum">    1434 </span>                :            :                  * Make parent go away.</a>
<a name="1435"><span class="lineNum">    1435 </span>                :            :                  * Also makes grandparent's wait() unblock.</a>
<a name="1436"><span class="lineNum">    1436 </span>                :            :                  */</a>
<a name="1437"><span class="lineNum">    1437 </span>                :<span class="lineCov">          8 :                 kill(parent_pid, SIGKILL);</span></a>
<a name="1438"><span class="lineNum">    1438 </span>                :<span class="lineCov">          8 :                 strace_child = 0;</span></a>
<a name="1439"><span class="lineNum">    1439 </span>                :            :         }</a>
<a name="1440"><span class="lineNum">    1440 </span>                :            : }</a>
<a name="1441"><span class="lineNum">    1441 </span>                :            : </a>
<a name="1442"><span class="lineNum">    1442 </span>                :            : /* Stack-o-phobic exec helper, in the hope to work around</a>
<a name="1443"><span class="lineNum">    1443 </span>                :            :  * NOMMU + "daemonized tracer" difficulty.</a>
<a name="1444"><span class="lineNum">    1444 </span>                :            :  */</a>
<a name="1445"><span class="lineNum">    1445 </span>                :            : struct exec_params {</a>
<a name="1446"><span class="lineNum">    1446 </span>                :            :         int fd_to_close;</a>
<a name="1447"><span class="lineNum">    1447 </span>                :            :         uid_t run_euid;</a>
<a name="1448"><span class="lineNum">    1448 </span>                :            :         gid_t run_egid;</a>
<a name="1449"><span class="lineNum">    1449 </span>                :            :         char **argv;</a>
<a name="1450"><span class="lineNum">    1450 </span>                :            :         char **env;</a>
<a name="1451"><span class="lineNum">    1451 </span>                :            :         char *pathname;</a>
<a name="1452"><span class="lineNum">    1452 </span>                :            :         struct sigaction child_sa;</a>
<a name="1453"><span class="lineNum">    1453 </span>                :            : };</a>
<a name="1454"><span class="lineNum">    1454 </span>                :            : static struct exec_params params_for_tracee;</a>
<a name="1455"><span class="lineNum">    1455 </span>                :            : </a>
<a name="1456"><span class="lineNum">    1456 </span>                :            : static void ATTRIBUTE_NOINLINE ATTRIBUTE_NORETURN</a>
<a name="1457"><span class="lineNum">    1457 </span>                :<span class="lineCov">      17337 : exec_or_die(void)</span></a>
<a name="1458"><span class="lineNum">    1458 </span>                :            : {</a>
<a name="1459"><span class="lineNum">    1459 </span>                :<span class="lineCov">      17337 :         struct exec_params *params = &params_for_tracee;</span></a>
<a name="1460"><span class="lineNum">    1460 </span>                :            : </a>
<a name="1461"><span class="lineNum">    1461 </span>        [<span class="branchCov" title="Branch 0 was taken 14914 times"> + </span><span class="branchCov" title="Branch 1 was taken 2423 times"> + </span>]:<span class="lineCov">      17337 :         if (params->fd_to_close >= 0)</span></a>
<a name="1462"><span class="lineNum">    1462 </span>                :<span class="lineCov">      14914 :                 close(params->fd_to_close);</span></a>
<a name="1463"><span class="lineNum">    1463 </span>  [<span class="branchCov" title="Branch 0 was taken 17328 times"> + </span><span class="branchCov" title="Branch 1 was taken 9 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 17328 times"> + </span>]:<span class="lineCov">      17337 :         if (!daemonized_tracer && !use_seize) {</span></a>
<a name="1464"><span class="lineNum">    1464 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (ptrace(PTRACE_TRACEME, 0L, 0L, 0L) < 0) {</span></a>
<a name="1465"><span class="lineNum">    1465 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("ptrace(PTRACE_TRACEME, ...)");</span></a>
<a name="1466"><span class="lineNum">    1466 </span>                :            :                 }</a>
<a name="1467"><span class="lineNum">    1467 </span>                :            :         }</a>
<a name="1468"><span class="lineNum">    1468 </span>                :            : </a>
<a name="1469"><span class="lineNum">    1469 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17337 times"> + </span>]:<span class="lineCov">      17337 :         if (username != NULL) {</span></a>
<a name="1470"><span class="lineNum">    1470 </span>                :            :                 /*</a>
<a name="1471"><span class="lineNum">    1471 </span>                :            :                  * It is important to set groups before we</a>
<a name="1472"><span class="lineNum">    1472 </span>                :            :                  * lose privileges on setuid.</a>
<a name="1473"><span class="lineNum">    1473 </span>                :            :                  */</a>
<a name="1474"><span class="lineNum">    1474 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (initgroups(username, run_gid) < 0) {</span></a>
<a name="1475"><span class="lineNum">    1475 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("initgroups");</span></a>
<a name="1476"><span class="lineNum">    1476 </span>                :            :                 }</a>
<a name="1477"><span class="lineNum">    1477 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (setregid(run_gid, params->run_egid) < 0) {</span></a>
<a name="1478"><span class="lineNum">    1478 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("setregid");</span></a>
<a name="1479"><span class="lineNum">    1479 </span>                :            :                 }</a>
<a name="1480"><span class="lineNum">    1480 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (setreuid(run_uid, params->run_euid) < 0) {</span></a>
<a name="1481"><span class="lineNum">    1481 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("setreuid");</span></a>
<a name="1482"><span class="lineNum">    1482 </span>                :            :                 }</a>
<a name="1483"><span class="lineNum">    1483 </span>        [<span class="branchCov" title="Branch 0 was taken 17290 times"> + </span><span class="branchCov" title="Branch 1 was taken 47 times"> + </span>]:<span class="lineCov">      17337 :         } else if (geteuid() != 0)</span></a>
<a name="1484"><span class="lineNum">    1484 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17290 times"> + </span>]:<span class="lineCov">      17290 :                 if (setreuid(run_uid, run_uid) < 0) {</span></a>
<a name="1485"><span class="lineNum">    1485 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("setreuid");</span></a>
<a name="1486"><span class="lineNum">    1486 </span>                :            :                 }</a>
<a name="1487"><span class="lineNum">    1487 </span>                :            : </a>
<a name="1488"><span class="lineNum">    1488 </span>        [<span class="branchCov" title="Branch 0 was taken 17328 times"> + </span><span class="branchCov" title="Branch 1 was taken 9 times"> + </span>]:<span class="lineCov">      17337 :         if (!daemonized_tracer) {</span></a>
<a name="1489"><span class="lineNum">    1489 </span>                :            :                 /*</a>
<a name="1490"><span class="lineNum">    1490 </span>                :            :                  * Induce a ptrace stop. Tracer (our parent)</a>
<a name="1491"><span class="lineNum">    1491 </span>                :            :                  * will resume us with PTRACE_SYSCALL and display</a>
<a name="1492"><span class="lineNum">    1492 </span>                :            :                  * the immediately following execve syscall.</a>
<a name="1493"><span class="lineNum">    1493 </span>                :            :                  * Can't do this on NOMMU systems, we are after</a>
<a name="1494"><span class="lineNum">    1494 </span>                :            :                  * vfork: parent is blocked, stopping would deadlock.</a>
<a name="1495"><span class="lineNum">    1495 </span>                :            :                  */</a>
<a name="1496"><span class="lineNum">    1496 </span>                :<span class="lineCov">      17328 :                 if (!NOMMU_SYSTEM)</span></a>
<a name="1497"><span class="lineNum">    1497 </span>                :<span class="lineCov">      17328 :                         kill(getpid(), SIGSTOP);</span></a>
<a name="1498"><span class="lineNum">    1498 </span>                :            :         } else {</a>
<a name="1499"><span class="lineNum">    1499 </span>                :<span class="lineCov">          9 :                 alarm(3);</span></a>
<a name="1500"><span class="lineNum">    1500 </span>                :            :                 /* we depend on SIGCHLD set to SIG_DFL by init code */</a>
<a name="1501"><span class="lineNum">    1501 </span>                :            :                 /* if it happens to be SIG_IGN'ed, wait won't block */</a>
<a name="1502"><span class="lineNum">    1502 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 9 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">          9 :                 while (wait(NULL) < 0 && errno == EINTR)</span></a>
<a name="1503"><span class="lineNum">    1503 </span>                :            :                         ;</a>
<a name="1504"><span class="lineNum">    1504 </span>                :<span class="lineCov">          9 :                 alarm(0);</span></a>
<a name="1505"><span class="lineNum">    1505 </span>                :            :         }</a>
<a name="1506"><span class="lineNum">    1506 </span>                :            : </a>
<a name="1507"><span class="lineNum">    1507 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17337 :         if (params_for_tracee.child_sa.sa_handler != SIG_DFL)</span></a>
<a name="1508"><span class="lineNum">    1508 </span>                :<span class="lineCov">          5 :                 sigaction(SIGCHLD, &params_for_tracee.child_sa, NULL);</span></a>
<a name="1509"><span class="lineNum">    1509 </span>                :            : </a>
<a name="1510"><span class="lineNum">    1510 </span>  [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 17325 times"> + </span><span class="branchCov" title="Branch 2 was taken 12 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">      17349 :         debug_msg("seccomp filter %s",</span></a>
<a name="1511"><span class="lineNum">    1511 </span>                :            :                   seccomp_filtering ? "enabled" : "disabled");</a>
<a name="1512"><span class="lineNum">    1512 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 17330 times"> + </span>]:<span class="lineCov">      17337 :         if (seccomp_filtering)</span></a>
<a name="1513"><span class="lineNum">    1513 </span>                :<span class="lineCov">          7 :                 init_seccomp_filter();</span></a>
<a name="1514"><span class="lineNum">    1514 </span>                :<span class="lineCov">      17337 :         execve(params->pathname, params->argv, params->env);</span></a>
<a name="1515"><span class="lineNum">    1515 </span>                :<span class="lineCov">      17337 :         perror_msg_and_die("exec");</span></a>
<a name="1516"><span class="lineNum">    1516 </span>                :            : }</a>
<a name="1517"><span class="lineNum">    1517 </span>                :            : </a>
<a name="1518"><span class="lineNum">    1518 </span>                :            : /*</a>
<a name="1519"><span class="lineNum">    1519 </span>                :            :  * Open a dummy descriptor for use as a placeholder.</a>
<a name="1520"><span class="lineNum">    1520 </span>                :            :  * The descriptor is O_RDONLY with FD_CLOEXEC flag set.</a>
<a name="1521"><span class="lineNum">    1521 </span>                :            :  * A read attempt from such descriptor ends with EOF,</a>
<a name="1522"><span class="lineNum">    1522 </span>                :            :  * a write attempt is rejected with EBADF.</a>
<a name="1523"><span class="lineNum">    1523 </span>                :            :  */</a>
<a name="1524"><span class="lineNum">    1524 </span>                :            : static int</a>
<a name="1525"><span class="lineNum">    1525 </span>                :<span class="lineCov">      52001 : open_dummy_desc(void)</span></a>
<a name="1526"><span class="lineNum">    1526 </span>                :            : {</a>
<a name="1527"><span class="lineNum">    1527 </span>                :<span class="lineCov">      52001 :         int fds[2];</span></a>
<a name="1528"><span class="lineNum">    1528 </span>                :            : </a>
<a name="1529"><span class="lineNum">    1529 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 52001 times"> + </span>]:<span class="lineCov">      52001 :         if (pipe(fds))</span></a>
<a name="1530"><span class="lineNum">    1530 </span>                :<span class="lineNoCov">          0 :                 perror_func_msg_and_die("pipe");</span></a>
<a name="1531"><span class="lineNum">    1531 </span>                :<span class="lineCov">      52001 :         close(fds[1]);</span></a>
<a name="1532"><span class="lineNum">    1532 </span>                :<span class="lineCov">      52001 :         set_cloexec_flag(fds[0]);</span></a>
<a name="1533"><span class="lineNum">    1533 </span>                :<span class="lineCov">      52001 :         return fds[0];</span></a>
<a name="1534"><span class="lineNum">    1534 </span>                :            : }</a>
<a name="1535"><span class="lineNum">    1535 </span>                :            : </a>
<a name="1536"><span class="lineNum">    1536 </span>                :            : /* placeholder fds status for stdin and stdout */</a>
<a name="1537"><span class="lineNum">    1537 </span>                :            : static bool fd_is_placeholder[2];</a>
<a name="1538"><span class="lineNum">    1538 </span>                :            : </a>
<a name="1539"><span class="lineNum">    1539 </span>                :            : /*</a>
<a name="1540"><span class="lineNum">    1540 </span>                :            :  * Ensure that all standard file descriptors are open by opening placeholder</a>
<a name="1541"><span class="lineNum">    1541 </span>                :            :  * file descriptors for those standard file descriptors that are not open.</a>
<a name="1542"><span class="lineNum">    1542 </span>                :            :  *</a>
<a name="1543"><span class="lineNum">    1543 </span>                :            :  * The information which descriptors have been made open is saved</a>
<a name="1544"><span class="lineNum">    1544 </span>                :            :  * in fd_is_placeholder for later use.</a>
<a name="1545"><span class="lineNum">    1545 </span>                :            :  */</a>
<a name="1546"><span class="lineNum">    1546 </span>                :            : static void</a>
<a name="1547"><span class="lineNum">    1547 </span>                :<span class="lineCov">      17355 : ensure_standard_fds_opened(void)</span></a>
<a name="1548"><span class="lineNum">    1548 </span>                :            : {</a>
<a name="1549"><span class="lineNum">    1549 </span>                :<span class="lineCov">      17355 :         int fd;</span></a>
<a name="1550"><span class="lineNum">    1550 </span>                :            : </a>
<a name="1551"><span class="lineNum">    1551 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 17351 times"> + </span>]:<span class="lineCov">      17363 :         while ((fd = open_dummy_desc()) <= 2) {</span></a>
<a name="1552"><span class="lineNum">    1552 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">         12 :                 if (fd == 2)</span></a>
<a name="1553"><span class="lineNum">    1553 </span>                :            :                         break;</a>
<a name="1554"><span class="lineNum">    1554 </span>                :<span class="lineCov">          8 :                 fd_is_placeholder[fd] = true;</span></a>
<a name="1555"><span class="lineNum">    1555 </span>                :            :         }</a>
<a name="1556"><span class="lineNum">    1556 </span>                :            : </a>
<a name="1557"><span class="lineNum">    1557 </span>        [<span class="branchCov" title="Branch 0 was taken 17351 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">      17355 :         if (fd > 2)</span></a>
<a name="1558"><span class="lineNum">    1558 </span>                :<span class="lineCov">      17351 :                 close(fd);</span></a>
<a name="1559"><span class="lineNum">    1559 </span>                :<span class="lineCov">      17355 : }</span></a>
<a name="1560"><span class="lineNum">    1560 </span>                :            : </a>
<a name="1561"><span class="lineNum">    1561 </span>                :            : /*</a>
<a name="1562"><span class="lineNum">    1562 </span>                :            :  * Redirect stdin and stdout unless they have been opened earlier</a>
<a name="1563"><span class="lineNum">    1563 </span>                :            :  * by ensure_standard_fds_opened as placeholders.</a>
<a name="1564"><span class="lineNum">    1564 </span>                :            :  */</a>
<a name="1565"><span class="lineNum">    1565 </span>                :            : static void</a>
<a name="1566"><span class="lineNum">    1566 </span>                :<span class="lineCov">      17323 : redirect_standard_fds(void)</span></a>
<a name="1567"><span class="lineNum">    1567 </span>                :            : {</a>
<a name="1568"><span class="lineNum">    1568 </span>                :            :         /*</a>
<a name="1569"><span class="lineNum">    1569 </span>                :            :          * It might be a good idea to redirect stderr as well,</a>
<a name="1570"><span class="lineNum">    1570 </span>                :            :          * but we sometimes need to print error messages.</a>
<a name="1571"><span class="lineNum">    1571 </span>                :            :          */</a>
<a name="1572"><span class="lineNum">    1572 </span>        [<span class="branchCov" title="Branch 0 was taken 34646 times"> + </span><span class="branchCov" title="Branch 1 was taken 17323 times"> + </span>]:<span class="lineCov">      51969 :         for (int i = 0; i <= 1; ++i) {</span></a>
<a name="1573"><span class="lineNum">    1573 </span>        [<span class="branchCov" title="Branch 0 was taken 34638 times"> + </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span>]:<span class="lineCov">      34646 :                 if (!fd_is_placeholder[i]) {</span></a>
<a name="1574"><span class="lineNum">    1574 </span>                :<span class="lineCov">      34638 :                         close(i);</span></a>
<a name="1575"><span class="lineNum">    1575 </span>                :<span class="lineCov">      34638 :                         open_dummy_desc();</span></a>
<a name="1576"><span class="lineNum">    1576 </span>                :            :                 }</a>
<a name="1577"><span class="lineNum">    1577 </span>                :            :         }</a>
<a name="1578"><span class="lineNum">    1578 </span>                :<span class="lineCov">      17323 : }</span></a>
<a name="1579"><span class="lineNum">    1579 </span>                :            : </a>
<a name="1580"><span class="lineNum">    1580 </span>                :            : static void</a>
<a name="1581"><span class="lineNum">    1581 </span>                :<span class="lineCov">      17333 : startup_child(char **argv, char **env)</span></a>
<a name="1582"><span class="lineNum">    1582 </span>                :            : {</a>
<a name="1583"><span class="lineNum">    1583 </span>                :<span class="lineCov">      17333 :         strace_stat_t statbuf;</span></a>
<a name="1584"><span class="lineNum">    1584 </span>                :<span class="lineCov">      17333 :         const char *filename;</span></a>
<a name="1585"><span class="lineNum">    1585 </span>                :<span class="lineCov">      17333 :         size_t filename_len;</span></a>
<a name="1586"><span class="lineNum">    1586 </span>                :<span class="lineCov">      17333 :         char pathname[PATH_MAX];</span></a>
<a name="1587"><span class="lineNum">    1587 </span>                :<span class="lineCov">      17333 :         int pid;</span></a>
<a name="1588"><span class="lineNum">    1588 </span>                :<span class="lineCov">      17333 :         struct tcb *tcp;</span></a>
<a name="1589"><span class="lineNum">    1589 </span>                :            : </a>
<a name="1590"><span class="lineNum">    1590 </span>                :<span class="lineCov">      17333 :         filename = argv[0];</span></a>
<a name="1591"><span class="lineNum">    1591 </span>                :<span class="lineCov">      17333 :         filename_len = strlen(filename);</span></a>
<a name="1592"><span class="lineNum">    1592 </span>                :            : </a>
<a name="1593"><span class="lineNum">    1593 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17333 :         if (filename_len > sizeof(pathname) - 1) {</span></a>
<a name="1594"><span class="lineNum">    1594 </span>                :<span class="lineCov">          1 :                 errno = ENAMETOOLONG;</span></a>
<a name="1595"><span class="lineNum">    1595 </span>                :<span class="lineCov">          1 :                 perror_msg_and_die("exec");</span></a>
<a name="1596"><span class="lineNum">    1596 </span>                :            :         }</a>
<a name="1597"><span class="lineNum">    1597 </span>        [<span class="branchCov" title="Branch 0 was taken 17329 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">      17332 :         if (strchr(filename, '/')) {</span></a>
<a name="1598"><span class="lineNum">    1598 </span>                :<span class="lineCov">      17329 :                 strcpy(pathname, filename);</span></a>
<a name="1599"><span class="lineNum">    1599 </span>                :            :         }</a>
<a name="1600"><span class="lineNum">    1600 </span>                :            : #ifdef USE_DEBUGGING_EXEC</a>
<a name="1601"><span class="lineNum">    1601 </span>                :            :         /*</a>
<a name="1602"><span class="lineNum">    1602 </span>                :            :          * Debuggers customarily check the current directory</a>
<a name="1603"><span class="lineNum">    1603 </span>                :            :          * first regardless of the path but doing that gives</a>
<a name="1604"><span class="lineNum">    1604 </span>                :            :          * security geeks a panic attack.</a>
<a name="1605"><span class="lineNum">    1605 </span>                :            :          */</a>
<a name="1606"><span class="lineNum">    1606 </span>                :            :         else if (stat_file(filename, &statbuf) == 0)</a>
<a name="1607"><span class="lineNum">    1607 </span>                :            :                 strcpy(pathname, filename);</a>
<a name="1608"><span class="lineNum">    1608 </span>                :            : #endif /* USE_DEBUGGING_EXEC */</a>
<a name="1609"><span class="lineNum">    1609 </span>                :            :         else {</a>
<a name="1610"><span class="lineNum">    1610 </span>                :<span class="lineCov">          3 :                 const char *path;</span></a>
<a name="1611"><span class="lineNum">    1611 </span>                :<span class="lineCov">          3 :                 size_t m, n, len;</span></a>
<a name="1612"><span class="lineNum">    1612 </span>                :            : </a>
<a name="1613"><span class="lineNum">    1613 </span>  [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">         18 :                 for (path = getenv("PATH"); path && *path; path += m) {</span></a>
<a name="1614"><span class="lineNum">    1614 </span>                :<span class="lineCov">         18 :                         const char *colon = strchr(path, ':');</span></a>
<a name="1615"><span class="lineNum">    1615 </span>        [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         18 :                         if (colon) {</span></a>
<a name="1616"><span class="lineNum">    1616 </span>                :<span class="lineCov">         18 :                                 n = colon - path;</span></a>
<a name="1617"><span class="lineNum">    1617 </span>                :<span class="lineCov">         18 :                                 m = n + 1;</span></a>
<a name="1618"><span class="lineNum">    1618 </span>                :            :                         } else</a>
<a name="1619"><span class="lineNum">    1619 </span>                :<span class="lineNoCov">          0 :                                 m = n = strlen(path);</span></a>
<a name="1620"><span class="lineNum">    1620 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">         18 :                         if (n == 0) {</span></a>
<a name="1621"><span class="lineNum">    1621 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                                 if (!getcwd(pathname, PATH_MAX))</span></a>
<a name="1622"><span class="lineNum">    1622 </span>                :<span class="lineNoCov">          0 :                                         continue;</span></a>
<a name="1623"><span class="lineNum">    1623 </span>                :<span class="lineNoCov">          0 :                                 len = strlen(pathname);</span></a>
<a name="1624"><span class="lineNum">    1624 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">         18 :                         } else if (n > sizeof(pathname) - 1)</span></a>
<a name="1625"><span class="lineNum">    1625 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1626"><span class="lineNum">    1626 </span>                :            :                         else {</a>
<a name="1627"><span class="lineNum">    1627 </span>                :<span class="lineCov">         18 :                                 strncpy(pathname, path, n);</span></a>
<a name="1628"><span class="lineNum">    1628 </span>                :<span class="lineCov">         18 :                                 len = n;</span></a>
<a name="1629"><span class="lineNum">    1629 </span>                :            :                         }</a>
<a name="1630"><span class="lineNum">    1630 </span>  [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 18 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">         18 :                         if (len && pathname[len - 1] != '/')</span></a>
<a name="1631"><span class="lineNum">    1631 </span>                :<span class="lineCov">         18 :                                 pathname[len++] = '/';</span></a>
<a name="1632"><span class="lineNum">    1632 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">         18 :                         if (filename_len + len > sizeof(pathname) - 1)</span></a>
<a name="1633"><span class="lineNum">    1633 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1634"><span class="lineNum">    1634 </span>                :<span class="lineCov">         18 :                         strcpy(pathname + len, filename);</span></a>
<a name="1635"><span class="lineNum">    1635 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 15 times"> + </span>]:<span class="lineCov">         18 :                         if (stat_file(pathname, &statbuf) == 0 &&</span></a>
<a name="1636"><span class="lineNum">    1636 </span>                :            :                             /* Accept only regular files</a>
<a name="1637"><span class="lineNum">    1637 </span>                :            :                                with some execute bits set.</a>
<a name="1638"><span class="lineNum">    1638 </span>                :            :                                XXX not perfect, might still fail */</a>
<a name="1639"><span class="lineNum">    1639 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          3 :                             S_ISREG(statbuf.st_mode) &&</span></a>
<a name="1640"><span class="lineNum">    1640 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          3 :                             (statbuf.st_mode & 0111))</span></a>
<a name="1641"><span class="lineNum">    1641 </span>                :            :                                 break;</a>
<a name="1642"><span class="lineNum">    1642 </span>                :            :                 }</a>
<a name="1643"><span class="lineNum">    1643 </span>  [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 3 times"> + </span>]:<span class="lineCov">          3 :                 if (!path || !*path)</span></a>
<a name="1644"><span class="lineNum">    1644 </span>                :<span class="lineNoCov">          0 :                         pathname[0] = '\0';</span></a>
<a name="1645"><span class="lineNum">    1645 </span>                :            :         }</a>
<a name="1646"><span class="lineNum">    1646 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17332 :         if (stat_file(pathname, &statbuf) < 0) {</span></a>
<a name="1647"><span class="lineNum">    1647 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("Can't stat '%s'", filename);</span></a>
<a name="1648"><span class="lineNum">    1648 </span>                :            :         }</a>
<a name="1649"><span class="lineNum">    1649 </span>                :            : </a>
<a name="1650"><span class="lineNum">    1650 </span>        [<span class="branchCov" title="Branch 0 was taken 14909 times"> + </span><span class="branchCov" title="Branch 1 was taken 2423 times"> + </span>]:<span class="lineCov">      17332 :         params_for_tracee.fd_to_close = (shared_log != stderr) ? fileno(shared_log) : -1;</span></a>
<a name="1651"><span class="lineNum">    1651 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17332 :         params_for_tracee.run_euid = (statbuf.st_mode & S_ISUID) ? statbuf.st_uid : run_uid;</span></a>
<a name="1652"><span class="lineNum">    1652 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17332 :         params_for_tracee.run_egid = (statbuf.st_mode & S_ISGID) ? statbuf.st_gid : run_gid;</span></a>
<a name="1653"><span class="lineNum">    1653 </span>                :<span class="lineCov">      17332 :         params_for_tracee.argv = argv;</span></a>
<a name="1654"><span class="lineNum">    1654 </span>                :<span class="lineCov">      17332 :         params_for_tracee.env = env;</span></a>
<a name="1655"><span class="lineNum">    1655 </span>                :            :         /*</a>
<a name="1656"><span class="lineNum">    1656 </span>                :            :          * On NOMMU, can be safely freed only after execve in tracee.</a>
<a name="1657"><span class="lineNum">    1657 </span>                :            :          * It's hard to know when that happens, so we just leak it.</a>
<a name="1658"><span class="lineNum">    1658 </span>                :            :          */</a>
<a name="1659"><span class="lineNum">    1659 </span>                :<span class="lineCov">      17332 :         params_for_tracee.pathname = NOMMU_SYSTEM ? xstrdup(pathname) : pathname;</span></a>
<a name="1660"><span class="lineNum">    1660 </span>                :            : </a>
<a name="1661"><span class="lineNum">    1661 </span>        [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 17323 times"> + </span>]:<span class="lineCov">      17332 :         if (daemonized_tracer)</span></a>
<a name="1662"><span class="lineNum">    1662 </span>                :<span class="lineCov">          9 :                 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);</span></a>
<a name="1663"><span class="lineNum">    1663 </span>                :            : </a>
<a name="1664"><span class="lineNum">    1664 </span>                :<span class="lineCov">      17332 :         pid = fork();</span></a>
<a name="1665"><span class="lineNum">    1665 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 34660 times"> + </span>]:<span class="lineCov">      34660 :         if (pid < 0)</span></a>
<a name="1666"><span class="lineNum">    1666 </span>                :<span class="lineNoCov">          0 :                 perror_func_msg_and_die("fork");</span></a>
<a name="1667"><span class="lineNum">    1667 </span>                :            : </a>
<a name="1668"><span class="lineNum">    1668 </span>  [<span class="branchCov" title="Branch 0 was taken 17332 times"> + </span><span class="branchCov" title="Branch 1 was taken 17328 times"> + </span><span class="branchCov" title="Branch 2 was taken 17323 times"> + </span><span class="branchCov" title="Branch 3 was taken 9 times"> + </span>]:<span class="lineCov">      34660 :         if ((pid != 0 && daemonized_tracer)</span></a>
<a name="1669"><span class="lineNum">    1669 </span>  [<span class="branchCov" title="Branch 0 was taken 17328 times"> + </span><span class="branchCov" title="Branch 1 was taken 17323 times"> + </span><span class="branchCov" title="Branch 2 was taken 17328 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">      34651 :          || (pid == 0 && !daemonized_tracer)</span></a>
<a name="1670"><span class="lineNum">    1670 </span>                :            :         ) {</a>
<a name="1671"><span class="lineNum">    1671 </span>                :            :                 /* We are to become the tracee. Two cases:</a>
<a name="1672"><span class="lineNum">    1672 </span>                :            :                  * -D: we are parent</a>
<a name="1673"><span class="lineNum">    1673 </span>                :            :                  * not -D: we are child</a>
<a name="1674"><span class="lineNum">    1674 </span>                :            :                  */</a>
<a name="1675"><span class="lineNum">    1675 </span>                :<span class="lineCov">      17337 :                 exec_or_die();</span></a>
<a name="1676"><span class="lineNum">    1676 </span>                :            :         }</a>
<a name="1677"><span class="lineNum">    1677 </span>                :            : </a>
<a name="1678"><span class="lineNum">    1678 </span>                :            :         /* We are the tracer */</a>
<a name="1679"><span class="lineNum">    1679 </span>                :            : </a>
<a name="1680"><span class="lineNum">    1680 </span>        [<span class="branchCov" title="Branch 0 was taken 17323 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17323 :         if (!daemonized_tracer) {</span></a>
<a name="1681"><span class="lineNum">    1681 </span>                :<span class="lineCov">      17323 :                 strace_child = pid;</span></a>
<a name="1682"><span class="lineNum">    1682 </span>        [<span class="branchCov" title="Branch 0 was taken 17323 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17323 :                 if (!use_seize) {</span></a>
<a name="1683"><span class="lineNum">    1683 </span>                :            :                         /* child did PTRACE_TRACEME, nothing to do in parent */</a>
<a name="1684"><span class="lineNum">    1684 </span>                :            :                 } else {</a>
<a name="1685"><span class="lineNum">    1685 </span>                :            :                         if (!NOMMU_SYSTEM) {</a>
<a name="1686"><span class="lineNum">    1686 </span>                :            :                                 /* Wait until child stopped itself */</a>
<a name="1687"><span class="lineNum">    1687 </span>                :            :                                 int status;</a>
<a name="1688"><span class="lineNum">    1688 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17323 times"> + </span>]:<span class="lineCov">      17323 :                                 while (waitpid(pid, &status, WSTOPPED) < 0) {</span></a>
<a name="1689"><span class="lineNum">    1689 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                                         if (errno == EINTR)</span></a>
<a name="1690"><span class="lineNum">    1690 </span>                :<span class="lineNoCov">          0 :                                                 continue;</span></a>
<a name="1691"><span class="lineNum">    1691 </span>                :<span class="lineNoCov">          0 :                                         perror_msg_and_die("waitpid");</span></a>
<a name="1692"><span class="lineNum">    1692 </span>                :            :                                 }</a>
<a name="1693"><span class="lineNum">    1693 </span>  [<span class="branchCov" title="Branch 0 was taken 17323 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 17323 times"> + </span>]:<span class="lineCov">      17323 :                                 if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP) {</span></a>
<a name="1694"><span class="lineNum">    1694 </span>                :<span class="lineNoCov">          0 :                                         kill_save_errno(pid, SIGKILL);</span></a>
<a name="1695"><span class="lineNum">    1695 </span>                :<span class="lineNoCov">          0 :                                         perror_msg_and_die("Unexpected wait status %#x",</span></a>
<a name="1696"><span class="lineNum">    1696 </span>                :            :                                                            status);</a>
<a name="1697"><span class="lineNum">    1697 </span>                :            :                                 }</a>
<a name="1698"><span class="lineNum">    1698 </span>                :            :                         }</a>
<a name="1699"><span class="lineNum">    1699 </span>                :            :                         /* Else: NOMMU case, we have no way to sync.</a>
<a name="1700"><span class="lineNum">    1700 </span>                :            :                          * Just attach to it as soon as possible.</a>
<a name="1701"><span class="lineNum">    1701 </span>                :            :                          * This means that we may miss a few first syscalls...</a>
<a name="1702"><span class="lineNum">    1702 </span>                :            :                          */</a>
<a name="1703"><span class="lineNum">    1703 </span>                :            : </a>
<a name="1704"><span class="lineNum">    1704 </span>                :<span class="lineCov">      17323 :                         const char *ptrace_attach_cmd;</span></a>
<a name="1705"><span class="lineNum">    1705 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17323 times"> + </span>]:<span class="lineCov">      17323 :                         if (ptrace_attach_or_seize(pid, &ptrace_attach_cmd)) {</span></a>
<a name="1706"><span class="lineNum">    1706 </span>                :<span class="lineNoCov">          0 :                                 kill_save_errno(pid, SIGKILL);</span></a>
<a name="1707"><span class="lineNum">    1707 </span>                :<span class="lineNoCov">          0 :                                 perror_msg_and_die("attach: ptrace(%s, %d)",</span></a>
<a name="1708"><span class="lineNum">    1708 </span>                :            :                                                    ptrace_attach_cmd, pid);</a>
<a name="1709"><span class="lineNum">    1709 </span>                :            :                         }</a>
<a name="1710"><span class="lineNum">    1710 </span>                :<span class="lineCov">      17323 :                         if (!NOMMU_SYSTEM)</span></a>
<a name="1711"><span class="lineNum">    1711 </span>                :<span class="lineCov">      17323 :                                 kill(pid, SIGCONT);</span></a>
<a name="1712"><span class="lineNum">    1712 </span>                :            :                 }</a>
<a name="1713"><span class="lineNum">    1713 </span>                :<span class="lineCov">      17323 :                 tcp = alloctcb(pid);</span></a>
<a name="1714"><span class="lineNum">    1714 </span>                :<span class="lineCov">      17323 :                 after_successful_attach(tcp, TCB_SKIP_DETACH_ON_FIRST_EXEC</span></a>
<a name="1715"><span class="lineNum">    1715 </span>                :<span class="lineCov">      17323 :                                              | (NOMMU_SYSTEM ? 0</span></a>
<a name="1716"><span class="lineNum">    1716 </span>                :            :                                                 : (TCB_HIDE_LOG</a>
<a name="1717"><span class="lineNum">    1717 </span>                :            :                                                    | post_attach_sigstop)));</a>
<a name="1718"><span class="lineNum">    1718 </span>                :            :         } else {</a>
<a name="1719"><span class="lineNum">    1719 </span>                :            :                 /* With -D, we are *child* here, the tracee is our parent. */</a>
<a name="1720"><span class="lineNum">    1720 </span>                :<span class="lineNoCov">          0 :                 strace_child = strace_tracer_pid;</span></a>
<a name="1721"><span class="lineNum">    1721 </span>                :<span class="lineNoCov">          0 :                 strace_tracer_pid = getpid();</span></a>
<a name="1722"><span class="lineNum">    1722 </span>                :<span class="lineNoCov">          0 :                 tcp = alloctcb(strace_child);</span></a>
<a name="1723"><span class="lineNum">    1723 </span>                :<span class="lineNoCov">          0 :                 tcp->flags |= TCB_SKIP_DETACH_ON_FIRST_EXEC | TCB_HIDE_LOG;</span></a>
<a name="1724"><span class="lineNum">    1724 </span>                :            :                 /*</a>
<a name="1725"><span class="lineNum">    1725 </span>                :            :                  * Attaching will be done later, by startup_attach.</a>
<a name="1726"><span class="lineNum">    1726 </span>                :            :                  * Note: we don't do after_successful_attach() here either!</a>
<a name="1727"><span class="lineNum">    1727 </span>                :            :                  */</a>
<a name="1728"><span class="lineNum">    1728 </span>                :            : </a>
<a name="1729"><span class="lineNum">    1729 </span>                :            :                 /* NOMMU BUG! -D mode is active, we (child) return,</a>
<a name="1730"><span class="lineNum">    1730 </span>                :            :                  * and we will scribble over parent's stack!</a>
<a name="1731"><span class="lineNum">    1731 </span>                :            :                  * When parent later unpauses, it segfaults.</a>
<a name="1732"><span class="lineNum">    1732 </span>                :            :                  *</a>
<a name="1733"><span class="lineNum">    1733 </span>                :            :                  * We work around it</a>
<a name="1734"><span class="lineNum">    1734 </span>                :            :                  * (1) by declaring exec_or_die() NORETURN,</a>
<a name="1735"><span class="lineNum">    1735 </span>                :            :                  * hopefully compiler will just jump to it</a>
<a name="1736"><span class="lineNum">    1736 </span>                :            :                  * instead of call (won't push anything to stack),</a>
<a name="1737"><span class="lineNum">    1737 </span>                :            :                  * (2) by trying very hard in exec_or_die()</a>
<a name="1738"><span class="lineNum">    1738 </span>                :            :                  * to not use any stack,</a>
<a name="1739"><span class="lineNum">    1739 </span>                :            :                  * (3) having a really big (PATH_MAX) stack object</a>
<a name="1740"><span class="lineNum">    1740 </span>                :            :                  * in this function, which creates a "buffer" between</a>
<a name="1741"><span class="lineNum">    1741 </span>                :            :                  * child's and parent's stack pointers.</a>
<a name="1742"><span class="lineNum">    1742 </span>                :            :                  * This may save us if (1) and (2) failed</a>
<a name="1743"><span class="lineNum">    1743 </span>                :            :                  * and compiler decided to use stack in exec_or_die() anyway</a>
<a name="1744"><span class="lineNum">    1744 </span>                :            :                  * (happens on i386 because of stack parameter passing).</a>
<a name="1745"><span class="lineNum">    1745 </span>                :            :                  *</a>
<a name="1746"><span class="lineNum">    1746 </span>                :            :                  * A cleaner solution is to use makecontext + setcontext</a>
<a name="1747"><span class="lineNum">    1747 </span>                :            :                  * to create a genuine separate stack and execute on it.</a>
<a name="1748"><span class="lineNum">    1748 </span>                :            :                  */</a>
<a name="1749"><span class="lineNum">    1749 </span>                :            :         }</a>
<a name="1750"><span class="lineNum">    1750 </span>                :            : </a>
<a name="1751"><span class="lineNum">    1751 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 17316 times"> + </span>]:<span class="lineCov">      17323 :         if (seccomp_filtering)</span></a>
<a name="1752"><span class="lineNum">    1752 </span>                :<span class="lineCov">          7 :                 tcp->flags |= TCB_SECCOMP_FILTER;</span></a>
<a name="1753"><span class="lineNum">    1753 </span>                :            : </a>
<a name="1754"><span class="lineNum">    1754 </span>                :            :         /*</a>
<a name="1755"><span class="lineNum">    1755 </span>                :            :          * A case where straced process is part of a pipe:</a>
<a name="1756"><span class="lineNum">    1756 </span>                :            :          * { sleep 1; yes | head -n99999; } | strace -o/dev/null sh -c 'exec <&-; sleep 9'</a>
<a name="1757"><span class="lineNum">    1757 </span>                :            :          * If strace won't close its fd#0, closing it in tracee is not enough:</a>
<a name="1758"><span class="lineNum">    1758 </span>                :            :          * the pipe is still open, it has a reader. Thus, "head" will not get its</a>
<a name="1759"><span class="lineNum">    1759 </span>                :            :          * SIGPIPE at once, on the first write.</a>
<a name="1760"><span class="lineNum">    1760 </span>                :            :          *</a>
<a name="1761"><span class="lineNum">    1761 </span>                :            :          * Preventing it by redirecting strace's stdin/out.</a>
<a name="1762"><span class="lineNum">    1762 </span>                :            :          * (Don't leave fds 0 and 1 closed, this is bad practice: future opens</a>
<a name="1763"><span class="lineNum">    1763 </span>                :            :          * will reuse them, unexpectedly making a newly opened object "stdin").</a>
<a name="1764"><span class="lineNum">    1764 </span>                :            :          */</a>
<a name="1765"><span class="lineNum">    1765 </span>                :<span class="lineCov">      17323 :         redirect_standard_fds();</span></a>
<a name="1766"><span class="lineNum">    1766 </span>                :<span class="lineCov">      17323 : }</span></a>
<a name="1767"><span class="lineNum">    1767 </span>                :            : </a>
<a name="1768"><span class="lineNum">    1768 </span>                :            : static void</a>
<a name="1769"><span class="lineNum">    1769 </span>                :<span class="lineCov">      17355 : test_ptrace_seize(void)</span></a>
<a name="1770"><span class="lineNum">    1770 </span>                :            : {</a>
<a name="1771"><span class="lineNum">    1771 </span>                :<span class="lineCov">      17355 :         int pid;</span></a>
<a name="1772"><span class="lineNum">    1772 </span>                :            : </a>
<a name="1773"><span class="lineNum">    1773 </span>                :            :         /* Need fork for test. NOMMU has no forks */</a>
<a name="1774"><span class="lineNum">    1774 </span>                :<span class="lineCov">      17355 :         if (NOMMU_SYSTEM) {</span></a>
<a name="1775"><span class="lineNum">    1775 </span>                :            :                 post_attach_sigstop = 0; /* this sets use_seize to 1 */</a>
<a name="1776"><span class="lineNum">    1776 </span>                :            :                 return;</a>
<a name="1777"><span class="lineNum">    1777 </span>                :            :         }</a>
<a name="1778"><span class="lineNum">    1778 </span>                :            : </a>
<a name="1779"><span class="lineNum">    1779 </span>                :<span class="lineCov">      17355 :         pid = fork();</span></a>
<a name="1780"><span class="lineNum">    1780 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17355 times"> + </span>]:<span class="lineCov">      17355 :         if (pid < 0)</span></a>
<a name="1781"><span class="lineNum">    1781 </span>                :<span class="lineNoCov">          0 :                 perror_func_msg_and_die("fork");</span></a>
<a name="1782"><span class="lineNum">    1782 </span>                :            : </a>
<a name="1783"><span class="lineNum">    1783 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17355 times"> + </span>]:<span class="lineCov">      17355 :         if (pid == 0) {</span></a>
<a name="1784"><span class="lineNum">    1784 </span>                :<span class="lineNoCov">          0 :                 pause();</span></a>
<a name="1785"><span class="lineNum">    1785 </span>                :<span class="lineNoCov">          0 :                 _exit(0);</span></a>
<a name="1786"><span class="lineNum">    1786 </span>                :            :         }</a>
<a name="1787"><span class="lineNum">    1787 </span>                :            : </a>
<a name="1788"><span class="lineNum">    1788 </span>                :            :         /* PTRACE_SEIZE, unlike ATTACH, doesn't force tracee to trap.  After</a>
<a name="1789"><span class="lineNum">    1789 </span>                :            :          * attaching tracee continues to run unless a trap condition occurs.</a>
<a name="1790"><span class="lineNum">    1790 </span>                :            :          * PTRACE_SEIZE doesn't affect signal or group stop state.</a>
<a name="1791"><span class="lineNum">    1791 </span>                :            :          */</a>
<a name="1792"><span class="lineNum">    1792 </span>        [<span class="branchCov" title="Branch 0 was taken 17355 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17355 :         if (ptrace(PTRACE_SEIZE, pid, 0, 0) == 0) {</span></a>
<a name="1793"><span class="lineNum">    1793 </span>                :<span class="lineCov">      17355 :                 post_attach_sigstop = 0; /* this sets use_seize to 1 */</span></a>
<a name="1794"><span class="lineNum">    1794 </span>                :            :         } else {</a>
<a name="1795"><span class="lineNum">    1795 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 debug_msg("PTRACE_SEIZE doesn't work");</span></a>
<a name="1796"><span class="lineNum">    1796 </span>                :            :         }</a>
<a name="1797"><span class="lineNum">    1797 </span>                :            : </a>
<a name="1798"><span class="lineNum">    1798 </span>                :<span class="lineCov">      17355 :         kill(pid, SIGKILL);</span></a>
<a name="1799"><span class="lineNum">    1799 </span>                :            : </a>
<a name="1800"><span class="lineNum">    1800 </span>                :<span class="lineCov">      17355 :         while (1) {</span></a>
<a name="1801"><span class="lineNum">    1801 </span>                :<span class="lineCov">      17355 :                 int status, tracee_pid;</span></a>
<a name="1802"><span class="lineNum">    1802 </span>                :            : </a>
<a name="1803"><span class="lineNum">    1803 </span>                :<span class="lineCov">      17355 :                 errno = 0;</span></a>
<a name="1804"><span class="lineNum">    1804 </span>                :<span class="lineCov">      17355 :                 tracee_pid = waitpid(pid, &status, 0);</span></a>
<a name="1805"><span class="lineNum">    1805 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17355 times"> + </span>]:<span class="lineCov">      17355 :                 if (tracee_pid <= 0) {</span></a>
<a name="1806"><span class="lineNum">    1806 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                         if (errno == EINTR)</span></a>
<a name="1807"><span class="lineNum">    1807 </span>                :<span class="lineNoCov">          0 :                                 continue;</span></a>
<a name="1808"><span class="lineNum">    1808 </span>                :<span class="lineNoCov">          0 :                         perror_func_msg_and_die("unexpected wait result %d",</span></a>
<a name="1809"><span class="lineNum">    1809 </span>                :            :                                                 tracee_pid);</a>
<a name="1810"><span class="lineNum">    1810 </span>                :            :                 }</a>
<a name="1811"><span class="lineNum">    1811 </span>        [<span class="branchCov" title="Branch 0 was taken 17355 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17355 :                 if (WIFSIGNALED(status))</span></a>
<a name="1812"><span class="lineNum">    1812 </span>                :<span class="lineCov">      17355 :                         return;</span></a>
<a name="1813"><span class="lineNum">    1813 </span>                :            : </a>
<a name="1814"><span class="lineNum">    1814 </span>                :<span class="lineNoCov">          0 :                 error_func_msg_and_die("unexpected wait status %#x", status);</span></a>
<a name="1815"><span class="lineNum">    1815 </span>                :            :         }</a>
<a name="1816"><span class="lineNum">    1816 </span>                :            : }</a>
<a name="1817"><span class="lineNum">    1817 </span>                :            : </a>
<a name="1818"><span class="lineNum">    1818 </span>                :            : static unsigned int</a>
<a name="1819"><span class="lineNum">    1819 </span>                :<span class="lineCov">      23834 : get_os_release(void)</span></a>
<a name="1820"><span class="lineNum">    1820 </span>                :            : {</a>
<a name="1821"><span class="lineNum">    1821 </span>                :<span class="lineCov">      23834 :         struct utsname u;</span></a>
<a name="1822"><span class="lineNum">    1822 </span>        [<span class="branchCov" title="Branch 0 was taken 23834 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      23834 :         if (uname(&u) < 0)</span></a>
<a name="1823"><span class="lineNum">    1823 </span>                :<span class="lineNoCov">          0 :                 perror_msg_and_die("uname");</span></a>
<a name="1824"><span class="lineNum">    1824 </span>                :            :         /*</a>
<a name="1825"><span class="lineNum">    1825 </span>                :            :          * u.release string consists of at most three parts</a>
<a name="1826"><span class="lineNum">    1826 </span>                :            :          * and normally has this form: "3.2.9[-some-garbage]",</a>
<a name="1827"><span class="lineNum">    1827 </span>                :            :          * "X.Y-something" means "X.Y.0".</a>
<a name="1828"><span class="lineNum">    1828 </span>                :            :          */</a>
<a name="1829"><span class="lineNum">    1829 </span>                :            :         const char *p = u.release;</a>
<a name="1830"><span class="lineNum">    1830 </span>                :            :         unsigned int rel = 0;</a>
<a name="1831"><span class="lineNum">    1831 </span>        [<span class="branchCov" title="Branch 0 was taken 71502 times"> + </span><span class="branchCov" title="Branch 1 was taken 23834 times"> + </span>]:<span class="lineCov">      95336 :         for (unsigned int parts = 0; parts < 3; ++parts) {</span></a>
<a name="1832"><span class="lineNum">    1832 </span>                :            :                 unsigned int n = 0;</a>
<a name="1833"><span class="lineNum">    1833 </span>        [<span class="branchCov" title="Branch 0 was taken 119170 times"> + </span><span class="branchCov" title="Branch 1 was taken 71502 times"> + </span>]:<span class="lineCov">     190672 :                 for (; (*p >= '0') && (*p <= '9'); ++p) {</span></a>
<a name="1834"><span class="lineNum">    1834 </span>                :<span class="lineCov">     119170 :                         n *= 10;</span></a>
<a name="1835"><span class="lineNum">    1835 </span>                :<span class="lineCov">     119170 :                         n += *p - '0';</span></a>
<a name="1836"><span class="lineNum">    1836 </span>                :            :                 }</a>
<a name="1837"><span class="lineNum">    1837 </span>                :<span class="lineCov">      71502 :                 rel <<= 8;</span></a>
<a name="1838"><span class="lineNum">    1838 </span>                :<span class="lineCov">      71502 :                 rel |= n;</span></a>
<a name="1839"><span class="lineNum">    1839 </span>        [<span class="branchCov" title="Branch 0 was taken 47668 times"> + </span><span class="branchCov" title="Branch 1 was taken 23834 times"> + </span>]:<span class="lineCov">      71502 :                 if (*p == '.')</span></a>
<a name="1840"><span class="lineNum">    1840 </span>                :<span class="lineCov">      47668 :                         ++p;</span></a>
<a name="1841"><span class="lineNum">    1841 </span>                :            :         }</a>
<a name="1842"><span class="lineNum">    1842 </span>                :<span class="lineCov">      23834 :         return rel;</span></a>
<a name="1843"><span class="lineNum">    1843 </span>                :            : }</a>
<a name="1844"><span class="lineNum">    1844 </span>                :            : </a>
<a name="1845"><span class="lineNum">    1845 </span>                :            : static void</a>
<a name="1846"><span class="lineNum">    1846 </span>                :<span class="lineCov">     155543 : set_sighandler(int signo, void (*sighandler)(int), struct sigaction *oldact)</span></a>
<a name="1847"><span class="lineNum">    1847 </span>                :            : {</a>
<a name="1848"><span class="lineNum">    1848 </span>                :<span class="lineCov">     155543 :         const struct sigaction sa = { .sa_handler = sighandler };</span></a>
<a name="1849"><span class="lineNum">    1849 </span>                :<span class="lineCov">     155543 :         sigaction(signo, &sa, oldact);</span></a>
<a name="1850"><span class="lineNum">    1850 </span>                :<span class="lineCov">     155543 : }</span></a>
<a name="1851"><span class="lineNum">    1851 </span>                :            : </a>
<a name="1852"><span class="lineNum">    1852 </span>                :            : static int</a>
<a name="1853"><span class="lineNum">    1853 </span>                :<span class="lineCov">        508 : parse_interruptible_arg(const char *arg)</span></a>
<a name="1854"><span class="lineNum">    1854 </span>                :            : {</a>
<a name="1855"><span class="lineNum">    1855 </span>                :<span class="lineCov">        508 :         static const struct xlat_data intr_str[] = {</span></a>
<a name="1856"><span class="lineNum">    1856 </span>                :            :                 { INTR_ANYWHERE,        "anywhere" },</a>
<a name="1857"><span class="lineNum">    1857 </span>                :            :                 { INTR_ANYWHERE,        "always" },</a>
<a name="1858"><span class="lineNum">    1858 </span>                :            :                 { INTR_WHILE_WAIT,      "waiting" },</a>
<a name="1859"><span class="lineNum">    1859 </span>                :            :                 { INTR_NEVER,           "never" },</a>
<a name="1860"><span class="lineNum">    1860 </span>                :            :                 { INTR_BLOCK_TSTP_TOO,  "never_tstp" },</a>
<a name="1861"><span class="lineNum">    1861 </span>                :            :         };</a>
<a name="1862"><span class="lineNum">    1862 </span>                :            : </a>
<a name="1863"><span class="lineNum">    1863 </span>                :<span class="lineCov">        508 :         const struct xlat_data *intr_arg = find_xlat_val(intr_str, arg);</span></a>
<a name="1864"><span class="lineNum">    1864 </span>                :            : </a>
<a name="1865"><span class="lineNum">    1865 </span>                :<span class="lineCov">        752 :         return intr_arg ? (int) intr_arg->val</span></a>
<a name="1866"><span class="lineNum">    1866 </span>        [<span class="branchCov" title="Branch 0 was taken 244 times"> + </span><span class="branchCov" title="Branch 1 was taken 264 times"> + </span>]:<span class="lineCov">        772 :                         : (int) string_to_uint_upto(arg, NUM_INTR_OPTS - 1);</span></a>
<a name="1867"><span class="lineNum">    1867 </span>                :            : }</a>
<a name="1868"><span class="lineNum">    1868 </span>                :            : </a>
<a name="1869"><span class="lineNum">    1869 </span>                :            : static int</a>
<a name="1870"><span class="lineNum">    1870 </span>                :<span class="lineCov">         58 : parse_ts_arg(const char *in_arg)</span></a>
<a name="1871"><span class="lineNum">    1871 </span>                :            : {</a>
<a name="1872"><span class="lineNum">    1872 </span>                :<span class="lineCov">         58 :         static const char format_pfx[] = "format:";</span></a>
<a name="1873"><span class="lineNum">    1873 </span>                :<span class="lineCov">         58 :         static const char scale_pfx[] = "precision:";</span></a>
<a name="1874"><span class="lineNum">    1874 </span>                :            : </a>
<a name="1875"><span class="lineNum">    1875 </span>                :<span class="lineCov">         58 :         enum {</span></a>
<a name="1876"><span class="lineNum">    1876 </span>                :            :                 TOKEN_FORMAT = 1 << 0,</a>
<a name="1877"><span class="lineNum">    1877 </span>                :            :                 TOKEN_SCALE  = 1 << 1,</a>
<a name="1878"><span class="lineNum">    1878 </span>                :            :         } token_type;</a>
<a name="1879"><span class="lineNum">    1879 </span>                :<span class="lineCov">         58 :         enum {</span></a>
<a name="1880"><span class="lineNum">    1880 </span>                :            :                 FK_UNSET,</a>
<a name="1881"><span class="lineNum">    1881 </span>                :            :                 FK_NONE,</a>
<a name="1882"><span class="lineNum">    1882 </span>                :            :                 FK_TIME,</a>
<a name="1883"><span class="lineNum">    1883 </span>                :            :                 FK_UNIX,</a>
<a name="1884"><span class="lineNum">    1884 </span>                :<span class="lineCov">         58 :         } format_kind = FK_UNSET;</span></a>
<a name="1885"><span class="lineNum">    1885 </span>                :<span class="lineCov">         58 :         int precision_width;</span></a>
<a name="1886"><span class="lineNum">    1886 </span>                :<span class="lineCov">         58 :         int precision_scale = 0;</span></a>
<a name="1887"><span class="lineNum">    1887 </span>                :<span class="lineCov">         58 :         char *arg = xstrdup(in_arg);</span></a>
<a name="1888"><span class="lineNum">    1888 </span>                :<span class="lineCov">         58 :         char *saveptr = NULL;</span></a>
<a name="1889"><span class="lineNum">    1889 </span>                :            : </a>
<a name="1890"><span class="lineNum">    1890 </span>                :<span class="lineCov">         58 :         for (const char *token = strtok_r(arg, ",", &saveptr);</span></a>
<a name="1891"><span class="lineNum">    1891 </span>        [<span class="branchCov" title="Branch 0 was taken 76 times"> + </span><span class="branchCov" title="Branch 1 was taken 54 times"> + </span>]:<span class="lineCov">        130 :              token; token = strtok_r(NULL, ",", &saveptr)) {</span></a>
<a name="1892"><span class="lineNum">    1892 </span>                :<span class="lineCov">         76 :                 token_type = TOKEN_FORMAT | TOKEN_SCALE;</span></a>
<a name="1893"><span class="lineNum">    1893 </span>                :            : </a>
<a name="1894"><span class="lineNum">    1894 </span>        [<span class="branchCov" title="Branch 0 was taken 26 times"> + </span><span class="branchCov" title="Branch 1 was taken 50 times"> + </span>]:<span class="lineCov">         76 :                 if (!strncasecmp(token, format_pfx, sizeof(format_pfx) - 1)) {</span></a>
<a name="1895"><span class="lineNum">    1895 </span>                :<span class="lineCov">         26 :                         token += sizeof(format_pfx) - 1;</span></a>
<a name="1896"><span class="lineNum">    1896 </span>                :<span class="lineCov">         26 :                         token_type = TOKEN_FORMAT;</span></a>
<a name="1897"><span class="lineNum">    1897 </span>        [<span class="branchCov" title="Branch 0 was taken 17 times"> + </span><span class="branchCov" title="Branch 1 was taken 33 times"> + </span>]:<span class="lineCov">         50 :                 } else if (!strncasecmp(token, scale_pfx,</span></a>
<a name="1898"><span class="lineNum">    1898 </span>                :            :                                         sizeof(scale_pfx) - 1)) {</a>
<a name="1899"><span class="lineNum">    1899 </span>                :<span class="lineCov">         17 :                         token += sizeof(scale_pfx) - 1;</span></a>
<a name="1900"><span class="lineNum">    1900 </span>                :<span class="lineCov">         17 :                         token_type = TOKEN_SCALE;</span></a>
<a name="1901"><span class="lineNum">    1901 </span>                :            : </a>
<a name="1902"><span class="lineNum">    1902 </span>                :            :                 }</a>
<a name="1903"><span class="lineNum">    1903 </span>                :            : </a>
<a name="1904"><span class="lineNum">    1904 </span>        [<span class="branchCov" title="Branch 0 was taken 59 times"> + </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         76 :                 if (token_type & TOKEN_FORMAT) {</span></a>
<a name="1905"><span class="lineNum">    1905 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 56 times"> + </span>]:<span class="lineCov">         59 :                         if (!strcasecmp(token, "none")) {</span></a>
<a name="1906"><span class="lineNum">    1906 </span>                :<span class="lineCov">          3 :                                 format_kind = FK_NONE;</span></a>
<a name="1907"><span class="lineNum">    1907 </span>                :<span class="lineCov">          3 :                                 continue;</span></a>
<a name="1908"><span class="lineNum">    1908 </span>        [<span class="branchCov" title="Branch 0 was taken 24 times"> + </span><span class="branchCov" title="Branch 1 was taken 32 times"> + </span>]:<span class="lineCov">         56 :                         } else if (!strcasecmp(token, "time")) {</span></a>
<a name="1909"><span class="lineNum">    1909 </span>                :<span class="lineCov">         24 :                                 format_kind = FK_TIME;</span></a>
<a name="1910"><span class="lineNum">    1910 </span>                :<span class="lineCov">         24 :                                 continue;</span></a>
<a name="1911"><span class="lineNum">    1911 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 20 times"> + </span>]:<span class="lineCov">         32 :                         } else if (!strcasecmp(token, "unix")) {</span></a>
<a name="1912"><span class="lineNum">    1912 </span>                :<span class="lineCov">         12 :                                 format_kind = FK_UNIX;</span></a>
<a name="1913"><span class="lineNum">    1913 </span>                :<span class="lineCov">         12 :                                 continue;</span></a>
<a name="1914"><span class="lineNum">    1914 </span>                :            :                         }</a>
<a name="1915"><span class="lineNum">    1915 </span>                :            :                 }</a>
<a name="1916"><span class="lineNum">    1916 </span>                :            : </a>
<a name="1917"><span class="lineNum">    1917 </span>        [<span class="branchCov" title="Branch 0 was taken 36 times"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">         37 :                 if (token_type & TOKEN_SCALE) {</span></a>
<a name="1918"><span class="lineNum">    1918 </span>                :<span class="lineCov">         36 :                         precision_scale =</span></a>
<a name="1919"><span class="lineNum">    1919 </span>                :<span class="lineCov">         36 :                                 str2timescale_optarg(token, &precision_width);</span></a>
<a name="1920"><span class="lineNum">    1920 </span>                :            : </a>
<a name="1921"><span class="lineNum">    1921 </span>        [<span class="branchCov" title="Branch 0 was taken 33 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         36 :                         if (precision_scale > 0)</span></a>
<a name="1922"><span class="lineNum">    1922 </span>                :<span class="lineCov">         33 :                                 continue;</span></a>
<a name="1923"><span class="lineNum">    1923 </span>                :            :                 }</a>
<a name="1924"><span class="lineNum">    1924 </span>                :            : </a>
<a name="1925"><span class="lineNum">    1925 </span>                :<span class="lineCov">          4 :                 free(arg);</span></a>
<a name="1926"><span class="lineNum">    1926 </span>                :<span class="lineCov">          4 :                 return -1;</span></a>
<a name="1927"><span class="lineNum">    1927 </span>                :            :         }</a>
<a name="1928"><span class="lineNum">    1928 </span>                :            : </a>
<a name="1929"><span class="lineNum">    1929 </span>  [<span class="branchCov" title="Branch 0 was taken 16 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span><span class="branchCov" title="Branch 2 was taken 24 times"> + </span><span class="branchCov" title="Branch 3 was taken 12 times"> + </span> :<span class="lineCov">         54 :         switch (format_kind) {</span></a>
<span class="lineNum">         </span>            <span class="branchNoCov" title="Branch 4 was not taken"> - </span>]
<a name="1930"><span class="lineNum">    1930 </span>                :<span class="lineCov">         16 :         case FK_UNSET:</span></a>
<a name="1931"><span class="lineNum">    1931 </span>        [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 7 times"> + </span>]:<span class="lineCov">         16 :                 if (!tflag_format)</span></a>
<a name="1932"><span class="lineNum">    1932 </span>                :<span class="lineCov">          9 :                         tflag_format = "%T";</span></a>
<a name="1933"><span class="lineNum">    1933 </span>                :            :                 break;</a>
<a name="1934"><span class="lineNum">    1934 </span>                :<span class="lineCov">          2 :         case FK_NONE:</span></a>
<a name="1935"><span class="lineNum">    1935 </span>                :<span class="lineCov">          2 :                 tflag_format = NULL;</span></a>
<a name="1936"><span class="lineNum">    1936 </span>                :<span class="lineCov">          2 :                 break;</span></a>
<a name="1937"><span class="lineNum">    1937 </span>                :<span class="lineCov">         24 :         case FK_TIME:</span></a>
<a name="1938"><span class="lineNum">    1938 </span>                :<span class="lineCov">         24 :                 tflag_format = "%T";</span></a>
<a name="1939"><span class="lineNum">    1939 </span>                :<span class="lineCov">         24 :                 break;</span></a>
<a name="1940"><span class="lineNum">    1940 </span>                :<span class="lineCov">         12 :         case FK_UNIX:</span></a>
<a name="1941"><span class="lineNum">    1941 </span>                :<span class="lineCov">         12 :                 tflag_format = "%s";</span></a>
<a name="1942"><span class="lineNum">    1942 </span>                :<span class="lineCov">         12 :                 break;</span></a>
<a name="1943"><span class="lineNum">    1943 </span>                :            :         }</a>
<a name="1944"><span class="lineNum">    1944 </span>                :            : </a>
<a name="1945"><span class="lineNum">    1945 </span>        [<span class="branchCov" title="Branch 0 was taken 30 times"> + </span><span class="branchCov" title="Branch 1 was taken 24 times"> + </span>]:<span class="lineCov">         54 :         if (precision_scale > 0) {</span></a>
<a name="1946"><span class="lineNum">    1946 </span>                :<span class="lineCov">         30 :                 tflag_scale = precision_scale;</span></a>
<a name="1947"><span class="lineNum">    1947 </span>                :<span class="lineCov">         30 :                 tflag_width = precision_width;</span></a>
<a name="1948"><span class="lineNum">    1948 </span>                :            :         }</a>
<a name="1949"><span class="lineNum">    1949 </span>                :            : </a>
<a name="1950"><span class="lineNum">    1950 </span>                :<span class="lineCov">         54 :         free(arg);</span></a>
<a name="1951"><span class="lineNum">    1951 </span>                :<span class="lineCov">         54 :         return 0;</span></a>
<a name="1952"><span class="lineNum">    1952 </span>                :            : }</a>
<a name="1953"><span class="lineNum">    1953 </span>                :            : </a>
<a name="1954"><span class="lineNum">    1954 </span>                :            : static void</a>
<a name="1955"><span class="lineNum">    1955 </span>                :<span class="lineCov">          4 : remove_from_env(char **env, size_t *env_count, const char *var)</span></a>
<a name="1956"><span class="lineNum">    1956 </span>                :            : {</a>
<a name="1957"><span class="lineNum">    1957 </span>                :<span class="lineCov">          4 :         const size_t len = strlen(var);</span></a>
<a name="1958"><span class="lineNum">    1958 </span>                :<span class="lineCov">          4 :         size_t w = 0;</span></a>
<a name="1959"><span class="lineNum">    1959 </span>                :            : </a>
<a name="1960"><span class="lineNum">    1960 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :         debug_func_msg("Removing variable \"%s\" from the command environment",</span></a>
<a name="1961"><span class="lineNum">    1961 </span>                :            :                        var);</a>
<a name="1962"><span class="lineNum">    1962 </span>                :            : </a>
<a name="1963"><span class="lineNum">    1963 </span>        [<span class="branchCov" title="Branch 0 was taken 350 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">        354 :         for (size_t r = 0; r < *env_count; ++r) {</span></a>
<a name="1964"><span class="lineNum">    1964 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 346 times"> + </span>]:<span class="lineCov">        350 :                 if (!strncmp(env[r], var, len) &&</span></a>
<a name="1965"><span class="lineNum">    1965 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :                     (env[r][len] == '=' || env[r][len] == '\0')) {</span></a>
<a name="1966"><span class="lineNum">    1966 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :                         debug_func_msg("Skipping entry %zu (\"%s\")",</span></a>
<a name="1967"><span class="lineNum">    1967 </span>                :            :                                        r, env[r]);</a>
<a name="1968"><span class="lineNum">    1968 </span>                :<span class="lineCov">          2 :                         continue;</span></a>
<a name="1969"><span class="lineNum">    1969 </span>                :            :                 }</a>
<a name="1970"><span class="lineNum">    1970 </span>        [<span class="branchCov" title="Branch 0 was taken 18 times"> + </span><span class="branchCov" title="Branch 1 was taken 330 times"> + </span>]:<span class="lineCov">        348 :                 if (w < r) {</span></a>
<a name="1971"><span class="lineNum">    1971 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov">         18 :                         debug_func_msg("Copying entry %zu to %zu", r, w);</span></a>
<a name="1972"><span class="lineNum">    1972 </span>                :<span class="lineCov">         18 :                         env[w] = env[r];</span></a>
<a name="1973"><span class="lineNum">    1973 </span>                :            :                 }</a>
<a name="1974"><span class="lineNum">    1974 </span>                :<span class="lineCov">        348 :                 ++w;</span></a>
<a name="1975"><span class="lineNum">    1975 </span>                :            :         }</a>
<a name="1976"><span class="lineNum">    1976 </span>                :            : </a>
<a name="1977"><span class="lineNum">    1977 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :         if (w < *env_count) {</span></a>
<a name="1978"><span class="lineNum">    1978 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :                 debug_func_msg("Decreasing env count from %zu to %zu",</span></a>
<a name="1979"><span class="lineNum">    1979 </span>                :            :                                *env_count, w);</a>
<a name="1980"><span class="lineNum">    1980 </span>                :<span class="lineCov">          2 :                 *env_count = w;</span></a>
<a name="1981"><span class="lineNum">    1981 </span>                :            :         }</a>
<a name="1982"><span class="lineNum">    1982 </span>                :<span class="lineCov">          4 : }</span></a>
<a name="1983"><span class="lineNum">    1983 </span>                :            : </a>
<a name="1984"><span class="lineNum">    1984 </span>                :            : static void</a>
<a name="1985"><span class="lineNum">    1985 </span>                :<span class="lineCov">          5 : add_to_env(char **env, size_t *env_count, char *var, const size_t len)</span></a>
<a name="1986"><span class="lineNum">    1986 </span>                :            : {</a>
<a name="1987"><span class="lineNum">    1987 </span>                :<span class="lineCov">          5 :         size_t r;</span></a>
<a name="1988"><span class="lineNum">    1988 </span>                :            : </a>
<a name="1989"><span class="lineNum">    1989 </span>        [<span class="branchCov" title="Branch 0 was taken 262 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">        264 :         for (r = 0; r < *env_count; ++r) {</span></a>
<a name="1990"><span class="lineNum">    1990 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 259 times"> + </span>]:<span class="lineCov">        262 :                 if (!strncmp(env[r], var, len) &&</span></a>
<a name="1991"><span class="lineNum">    1991 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          3 :                     (env[r][len] == '=' || env[r][len] == '\0'))</span></a>
<a name="1992"><span class="lineNum">    1992 </span>                :            :                         break;</a>
<a name="1993"><span class="lineNum">    1993 </span>                :            :         }</a>
<a name="1994"><span class="lineNum">    1994 </span>                :            : </a>
<a name="1995"><span class="lineNum">    1995 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          5 :         if (r < *env_count) {</span></a>
<a name="1996"><span class="lineNum">    1996 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          3 :                 debug_func_msg("Replacing entry %zu (\"%s\")"</span></a>
<a name="1997"><span class="lineNum">    1997 </span>                :            :                                ", key=\"%.*s\", var=\"%s\"",</a>
<a name="1998"><span class="lineNum">    1998 </span>                :            :                                r, env[r], (int) len, var, var);</a>
<a name="1999"><span class="lineNum">    1999 </span>                :            :         } else {</a>
<a name="2000"><span class="lineNum">    2000 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :                 debug_func_msg("Adding entry %zu"</span></a>
<a name="2001"><span class="lineNum">    2001 </span>                :            :                                ", key=\"%.*s\", var=\"%s\"",</a>
<a name="2002"><span class="lineNum">    2002 </span>                :            :                                r, (int) len, var, var);</a>
<a name="2003"><span class="lineNum">    2003 </span>                :<span class="lineCov">          2 :                 *env_count += 1;</span></a>
<a name="2004"><span class="lineNum">    2004 </span>                :            :         }</a>
<a name="2005"><span class="lineNum">    2005 </span>                :            : </a>
<a name="2006"><span class="lineNum">    2006 </span>                :<span class="lineCov">          5 :         env[r] = var;</span></a>
<a name="2007"><span class="lineNum">    2007 </span>                :<span class="lineCov">          5 : }</span></a>
<a name="2008"><span class="lineNum">    2008 </span>                :            : </a>
<a name="2009"><span class="lineNum">    2009 </span>                :            : static void</a>
<a name="2010"><span class="lineNum">    2010 </span>                :<span class="lineCov">          9 : update_env(char **env, size_t *env_count, char *var)</span></a>
<a name="2011"><span class="lineNum">    2011 </span>                :            : {</a>
<a name="2012"><span class="lineNum">    2012 </span>                :<span class="lineCov">          9 :         char *val = strchr(var, '=');</span></a>
<a name="2013"><span class="lineNum">    2013 </span>                :            : </a>
<a name="2014"><span class="lineNum">    2014 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          9 :         if (val)</span></a>
<a name="2015"><span class="lineNum">    2015 </span>                :<span class="lineCov">          5 :                 add_to_env(env, env_count, var, val - var);</span></a>
<a name="2016"><span class="lineNum">    2016 </span>                :            :         else</a>
<a name="2017"><span class="lineNum">    2017 </span>                :<span class="lineCov">          4 :                 remove_from_env(env, env_count, var);</span></a>
<a name="2018"><span class="lineNum">    2018 </span>                :<span class="lineCov">          9 : }</span></a>
<a name="2019"><span class="lineNum">    2019 </span>                :            : </a>
<a name="2020"><span class="lineNum">    2020 </span>                :            : static char **</a>
<a name="2021"><span class="lineNum">    2021 </span>                :<span class="lineCov">      17333 : make_env(char **orig_env, char *const *env_changes, size_t env_change_count)</span></a>
<a name="2022"><span class="lineNum">    2022 </span>                :            : {</a>
<a name="2023"><span class="lineNum">    2023 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 17328 times"> + </span>]:<span class="lineCov">      17333 :         if (!env_change_count)</span></a>
<a name="2024"><span class="lineNum">    2024 </span>                :            :                 return orig_env;</a>
<a name="2025"><span class="lineNum">    2025 </span>                :            : </a>
<a name="2026"><span class="lineNum">    2026 </span>                :<span class="lineCov">          5 :         char **new_env;</span></a>
<a name="2027"><span class="lineNum">    2027 </span>                :<span class="lineCov">          5 :         size_t new_env_count = 0;</span></a>
<a name="2028"><span class="lineNum">    2028 </span>                :<span class="lineCov">          5 :         size_t new_env_size;</span></a>
<a name="2029"><span class="lineNum">    2029 </span>                :            : </a>
<a name="2030"><span class="lineNum">    2030 </span>                :            :         /* Determining the environment variable count.  */</a>
<a name="2031"><span class="lineNum">    2031 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          5 :         if (orig_env) {</span></a>
<a name="2032"><span class="lineNum">    2032 </span>        [<span class="branchCov" title="Branch 0 was taken 425 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">        430 :                 for (; orig_env[new_env_count]; ++new_env_count)</span></a>
<a name="2033"><span class="lineNum">    2033 </span>                :            :                         ;</a>
<a name="2034"><span class="lineNum">    2034 </span>                :            :         }</a>
<a name="2035"><span class="lineNum">    2035 </span>                :<span class="lineCov">          5 :         new_env_size = new_env_count + env_change_count;</span></a>
<a name="2036"><span class="lineNum">    2036 </span>                :            : </a>
<a name="2037"><span class="lineNum">    2037 </span>  [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 5 times"> + </span>]:<span class="lineCov">          5 :         if (new_env_size < new_env_count || new_env_size < env_change_count ||</span></a>
<a name="2038"><span class="lineNum">    2038 </span>                :            :             new_env_size + 1 < new_env_size)</a>
<a name="2039"><span class="lineNum">    2039 </span>                :<span class="lineNoCov">          0 :                 error_msg_and_die("Cannot construct new environment: the sum "</span></a>
<a name="2040"><span class="lineNum">    2040 </span>                :            :                                   "of old environment variable count (%zu) and "</a>
<a name="2041"><span class="lineNum">    2041 </span>                :            :                                   "environment changes count (%zu) is too big",</a>
<a name="2042"><span class="lineNum">    2042 </span>                :            :                                   new_env_count, env_change_count);</a>
<a name="2043"><span class="lineNum">    2043 </span>                :            : </a>
<a name="2044"><span class="lineNum">    2044 </span>                :<span class="lineCov">          5 :         new_env_size++;</span></a>
<a name="2045"><span class="lineNum">    2045 </span>                :<span class="lineCov">          5 :         new_env = xallocarray(new_env_size, sizeof(*new_env));</span></a>
<a name="2046"><span class="lineNum">    2046 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          5 :         if (new_env_count)</span></a>
<a name="2047"><span class="lineNum">    2047 </span>                :<span class="lineCov">          5 :                 memcpy(new_env, orig_env, new_env_count * sizeof(*orig_env));</span></a>
<a name="2048"><span class="lineNum">    2048 </span>                :            : </a>
<a name="2049"><span class="lineNum">    2049 </span>        [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">         14 :         for (size_t i = 0; i < env_change_count; ++i)</span></a>
<a name="2050"><span class="lineNum">    2050 </span>                :<span class="lineCov">          9 :                 update_env(new_env, &new_env_count, env_changes[i]);</span></a>
<a name="2051"><span class="lineNum">    2051 </span>                :            : </a>
<a name="2052"><span class="lineNum">    2052 </span>                :<span class="lineCov">          5 :         new_env[new_env_count] = NULL;</span></a>
<a name="2053"><span class="lineNum">    2053 </span>                :            : </a>
<a name="2054"><span class="lineNum">    2054 </span>                :<span class="lineCov">          5 :         return new_env;</span></a>
<a name="2055"><span class="lineNum">    2055 </span>                :            : }</a>
<a name="2056"><span class="lineNum">    2056 </span>                :            : </a>
<a name="2057"><span class="lineNum">    2057 </span>                :            : /*</a>
<a name="2058"><span class="lineNum">    2058 </span>                :            :  * Initialization part of main() was eating much stack (~0.5k),</a>
<a name="2059"><span class="lineNum">    2059 </span>                :            :  * which was unused after init.</a>
<a name="2060"><span class="lineNum">    2060 </span>                :            :  * We can reuse it if we move init code into a separate function.</a>
<a name="2061"><span class="lineNum">    2061 </span>                :            :  *</a>
<a name="2062"><span class="lineNum">    2062 </span>                :            :  * Don't want main() to inline us and defeat the reason</a>
<a name="2063"><span class="lineNum">    2063 </span>                :            :  * we have a separate function.</a>
<a name="2064"><span class="lineNum">    2064 </span>                :            :  */</a>
<a name="2065"><span class="lineNum">    2065 </span>                :            : static void ATTRIBUTE_NOINLINE</a>
<a name="2066"><span class="lineNum">    2066 </span>                :<span class="lineCov">      23834 : init(int argc, char *argv[])</span></a>
<a name="2067"><span class="lineNum">    2067 </span>                :            : {</a>
<a name="2068"><span class="lineNum">    2068 </span>                :<span class="lineCov">      23834 :         static const char qflag_qual[] = "attach,personality";</span></a>
<a name="2069"><span class="lineNum">    2069 </span>                :<span class="lineCov">      23834 :         static const char qqflag_qual[] = "exit,attach,personality";</span></a>
<a name="2070"><span class="lineNum">    2070 </span>                :<span class="lineCov">      23834 :         static const char qqqflag_qual[] = "all";</span></a>
<a name="2071"><span class="lineNum">    2071 </span>                :<span class="lineCov">      23834 :         static const char yflag_qual[] = "path";</span></a>
<a name="2072"><span class="lineNum">    2072 </span>                :<span class="lineCov">      23834 :         static const char yyflag_qual[] = "all";</span></a>
<a name="2073"><span class="lineNum">    2073 </span>                :<span class="lineCov">      23834 :         static const char tflag_str[] = "format:time";</span></a>
<a name="2074"><span class="lineNum">    2074 </span>                :<span class="lineCov">      23834 :         static const char ttflag_str[] = "precision:us,format:time";</span></a>
<a name="2075"><span class="lineNum">    2075 </span>                :<span class="lineCov">      23834 :         static const char tttflag_str[] = "format:unix,precision:us";</span></a>
<a name="2076"><span class="lineNum">    2076 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2077"><span class="lineNum">    2077 </span>                :<span class="lineCov">      23834 :         static const char secontext_qual[] = "!full,mismatch";</span></a>
<a name="2078"><span class="lineNum">    2078 </span>                :            : #endif</a>
<a name="2079"><span class="lineNum">    2079 </span>                :            : </a>
<a name="2080"><span class="lineNum">    2080 </span>                :<span class="lineCov">      23834 :         int c, i;</span></a>
<a name="2081"><span class="lineNum">    2081 </span>                :<span class="lineCov">      23834 :         int optF = 0, zflags = 0;</span></a>
<a name="2082"><span class="lineNum">    2082 </span>                :<span class="lineCov">      23834 :         int lopt_idx;</span></a>
<a name="2083"><span class="lineNum">    2083 </span>                :<span class="lineCov">      23834 :         int daemonized_tracer_long = DAEMONIZE_NONE;</span></a>
<a name="2084"><span class="lineNum">    2084 </span>                :<span class="lineCov">      23834 :         int xflag_long = -1;</span></a>
<a name="2085"><span class="lineNum">    2085 </span>                :<span class="lineCov">      23834 :         int qflag_short = 0;</span></a>
<a name="2086"><span class="lineNum">    2086 </span>                :<span class="lineCov">      23834 :         int followfork_short = 0;</span></a>
<a name="2087"><span class="lineNum">    2087 </span>                :<span class="lineCov">      23834 :         int yflag_short = 0;</span></a>
<a name="2088"><span class="lineNum">    2088 </span>                :<span class="lineCov">      23834 :         bool tflag_long_set = false;</span></a>
<a name="2089"><span class="lineNum">    2089 </span>                :<span class="lineCov">      23834 :         int tflag_short = 0;</span></a>
<a name="2090"><span class="lineNum">    2090 </span>                :<span class="lineCov">      23834 :         bool columns_set = false;</span></a>
<a name="2091"><span class="lineNum">    2091 </span>                :<span class="lineCov">      23834 :         bool sortby_set = false;</span></a>
<a name="2092"><span class="lineNum">    2092 </span>                :            : </a>
<a name="2093"><span class="lineNum">    2093 </span>                :            :         /*</a>
<a name="2094"><span class="lineNum">    2094 </span>                :            :          * We can initialise global_path_set only after tracing backend</a>
<a name="2095"><span class="lineNum">    2095 </span>                :            :          * initialisation, so we store pointers to all the paths from</a>
<a name="2096"><span class="lineNum">    2096 </span>                :            :          * command-line arguments during parsing in this array and then,</a>
<a name="2097"><span class="lineNum">    2097 </span>                :            :          * after the successful backend initialisation, iterate over it</a>
<a name="2098"><span class="lineNum">    2098 </span>                :            :          * in order to add them to global_path_set.</a>
<a name="2099"><span class="lineNum">    2099 </span>                :            :          */</a>
<a name="2100"><span class="lineNum">    2100 </span>                :<span class="lineCov">      23834 :         const char **pathtrace_paths = NULL;</span></a>
<a name="2101"><span class="lineNum">    2101 </span>                :<span class="lineCov">      23834 :         size_t pathtrace_size = 0;</span></a>
<a name="2102"><span class="lineNum">    2102 </span>                :<span class="lineCov">      23834 :         size_t pathtrace_count = 0;</span></a>
<a name="2103"><span class="lineNum">    2103 </span>                :            : </a>
<a name="2104"><span class="lineNum">    2104 </span>                :            :         /**</a>
<a name="2105"><span class="lineNum">    2105 </span>                :            :          * Storage for environment changes requested for command.  They</a>
<a name="2106"><span class="lineNum">    2106 </span>                :            :          * are stored in a temporary array and not applied as is during</a>
<a name="2107"><span class="lineNum">    2107 </span>                :            :          * command line parsing for two reasons:</a>
<a name="2108"><span class="lineNum">    2108 </span>                :            :          *  - putenv() changes environment of the tracer as well,</a>
<a name="2109"><span class="lineNum">    2109 </span>                :            :          *    which is unacceptable.</a>
<a name="2110"><span class="lineNum">    2110 </span>                :            :          *  - Environment changes have to be applied</a>
<a name="2111"><span class="lineNum">    2111 </span>                :            :          *    in a tracing-backend-specific way.</a>
<a name="2112"><span class="lineNum">    2112 </span>                :            :          */</a>
<a name="2113"><span class="lineNum">    2113 </span>                :<span class="lineCov">      23834 :         char **env_changes = NULL;</span></a>
<a name="2114"><span class="lineNum">    2114 </span>                :<span class="lineCov">      23834 :         size_t env_change_size = 0;</span></a>
<a name="2115"><span class="lineNum">    2115 </span>                :<span class="lineCov">      23834 :         size_t env_change_count = 0;</span></a>
<a name="2116"><span class="lineNum">    2116 </span>                :            : </a>
<a name="2117"><span class="lineNum">    2117 </span>  [<span class="branchCov" title="Branch 0 was taken 23834 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span><span class="branchCov" title="Branch 3 was taken 23833 times"> + </span>]:<span class="lineCov">      23834 :         if (!program_invocation_name || !*program_invocation_name) {</span></a>
<a name="2118"><span class="lineNum">    2118 </span>                :<span class="lineCov">          1 :                 static char name[] = "strace";</span></a>
<a name="2119"><span class="lineNum">    2119 </span>                :<span class="lineCov">          1 :                 program_invocation_name =</span></a>
<a name="2120"><span class="lineNum">    2120 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span> :<span class="lineCov">          1 :                         (argc > 0 && argv[0] && *argv[0]) ? argv[0] : name;</span></a>
<span class="lineNum">         </span>         <span class="branchNoCov" title="Branch 4 was not taken"> - </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span>]
<a name="2121"><span class="lineNum">    2121 </span>                :            :         }</a>
<a name="2122"><span class="lineNum">    2122 </span>                :            : </a>
<a name="2123"><span class="lineNum">    2123 </span>                :<span class="lineCov">      23834 :         strace_tracer_pid = getpid();</span></a>
<a name="2124"><span class="lineNum">    2124 </span>                :            : </a>
<a name="2125"><span class="lineNum">    2125 </span>                :<span class="lineCov">      23834 :         os_release = get_os_release();</span></a>
<a name="2126"><span class="lineNum">    2126 </span>                :            : </a>
<a name="2127"><span class="lineNum">    2127 </span>                :<span class="lineCov">      23834 :         pidns_init();</span></a>
<a name="2128"><span class="lineNum">    2128 </span>                :            : </a>
<a name="2129"><span class="lineNum">    2129 </span>                :<span class="lineCov">      23834 :         shared_log = stderr;</span></a>
<a name="2130"><span class="lineNum">    2130 </span>                :<span class="lineCov">      23834 :         set_sortby(DEFAULT_SORTBY);</span></a>
<a name="2131"><span class="lineNum">    2131 </span>                :<span class="lineCov">      23834 :         set_personality(DEFAULT_PERSONALITY);</span></a>
<a name="2132"><span class="lineNum">    2132 </span>                :<span class="lineCov">      23834 :         qualify_trace("all");</span></a>
<a name="2133"><span class="lineNum">    2133 </span>                :<span class="lineCov">      23834 :         qualify_abbrev("all");</span></a>
<a name="2134"><span class="lineNum">    2134 </span>                :<span class="lineCov">      23834 :         qualify_verbose("all");</span></a>
<a name="2135"><span class="lineNum">    2135 </span>                :            : #if DEFAULT_QUAL_FLAGS != (QUAL_TRACE | QUAL_ABBREV | QUAL_VERBOSE)</a>
<a name="2136"><span class="lineNum">    2136 </span>                :            : # error Bug in DEFAULT_QUAL_FLAGS</a>
<a name="2137"><span class="lineNum">    2137 </span>                :            : #endif</a>
<a name="2138"><span class="lineNum">    2138 </span>                :<span class="lineCov">      23834 :         qualify_status("all");</span></a>
<a name="2139"><span class="lineNum">    2139 </span>                :<span class="lineCov">      23834 :         qualify_quiet("none");</span></a>
<a name="2140"><span class="lineNum">    2140 </span>                :<span class="lineCov">      23834 :         qualify_decode_fd("none");</span></a>
<a name="2141"><span class="lineNum">    2141 </span>                :<span class="lineCov">      23834 :         qualify_signals("all");</span></a>
<a name="2142"><span class="lineNum">    2142 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2143"><span class="lineNum">    2143 </span>                :<span class="lineCov">      23834 :         qualify_secontext("none");</span></a>
<a name="2144"><span class="lineNum">    2144 </span>                :            : #endif</a>
<a name="2145"><span class="lineNum">    2145 </span>                :            : </a>
<a name="2146"><span class="lineNum">    2146 </span>                :<span class="lineCov">      23834 :         static const char optstring[] =</span></a>
<a name="2147"><span class="lineNum">    2147 </span>                :            :                 "+a:Ab:cCdDe:E:fFhiI:kno:O:p:P:qrs:S:tTu:U:vVwxX:yYzZ";</a>
<a name="2148"><span class="lineNum">    2148 </span>                :            : </a>
<a name="2149"><span class="lineNum">    2149 </span>                :<span class="lineCov">      23834 :         enum {</span></a>
<a name="2150"><span class="lineNum">    2150 </span>                :            :                 GETOPT_SECCOMP = 0x100,</a>
<a name="2151"><span class="lineNum">    2151 </span>                :            :                 GETOPT_DAEMONIZE,</a>
<a name="2152"><span class="lineNum">    2152 </span>                :            :                 GETOPT_HEX_STR,</a>
<a name="2153"><span class="lineNum">    2153 </span>                :            :                 GETOPT_FOLLOWFORKS,</a>
<a name="2154"><span class="lineNum">    2154 </span>                :            :                 GETOPT_OUTPUT_SEPARATELY,</a>
<a name="2155"><span class="lineNum">    2155 </span>                :            :                 GETOPT_TS,</a>
<a name="2156"><span class="lineNum">    2156 </span>                :            :                 GETOPT_PIDNS_TRANSLATION,</a>
<a name="2157"><span class="lineNum">    2157 </span>                :            : </a>
<a name="2158"><span class="lineNum">    2158 </span>                :            :                 GETOPT_QUAL_TRACE,</a>
<a name="2159"><span class="lineNum">    2159 </span>                :            :                 GETOPT_QUAL_ABBREV,</a>
<a name="2160"><span class="lineNum">    2160 </span>                :            :                 GETOPT_QUAL_VERBOSE,</a>
<a name="2161"><span class="lineNum">    2161 </span>                :            :                 GETOPT_QUAL_RAW,</a>
<a name="2162"><span class="lineNum">    2162 </span>                :            :                 GETOPT_QUAL_SIGNAL,</a>
<a name="2163"><span class="lineNum">    2163 </span>                :            :                 GETOPT_QUAL_STATUS,</a>
<a name="2164"><span class="lineNum">    2164 </span>                :            :                 GETOPT_QUAL_READ,</a>
<a name="2165"><span class="lineNum">    2165 </span>                :            :                 GETOPT_QUAL_WRITE,</a>
<a name="2166"><span class="lineNum">    2166 </span>                :            :                 GETOPT_QUAL_FAULT,</a>
<a name="2167"><span class="lineNum">    2167 </span>                :            :                 GETOPT_QUAL_INJECT,</a>
<a name="2168"><span class="lineNum">    2168 </span>                :            :                 GETOPT_QUAL_KVM,</a>
<a name="2169"><span class="lineNum">    2169 </span>                :            :                 GETOPT_QUAL_QUIET,</a>
<a name="2170"><span class="lineNum">    2170 </span>                :            :                 GETOPT_QUAL_DECODE_FD,</a>
<a name="2171"><span class="lineNum">    2171 </span>                :            :                 GETOPT_QUAL_DECODE_PID,</a>
<a name="2172"><span class="lineNum">    2172 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2173"><span class="lineNum">    2173 </span>                :            :                 GETOPT_QUAL_SECONTEXT,</a>
<a name="2174"><span class="lineNum">    2174 </span>                :            : #endif</a>
<a name="2175"><span class="lineNum">    2175 </span>                :            :         };</a>
<a name="2176"><span class="lineNum">    2176 </span>                :<span class="lineCov">      23834 :         static const struct option longopts[] = {</span></a>
<a name="2177"><span class="lineNum">    2177 </span>                :            :                 { "columns",          required_argument, 0, 'a' },</a>
<a name="2178"><span class="lineNum">    2178 </span>                :            :                 { "output-append-mode",       no_argument,       0, 'A' },</a>
<a name="2179"><span class="lineNum">    2179 </span>                :            :                 { "detach-on",                required_argument, 0, 'b' },</a>
<a name="2180"><span class="lineNum">    2180 </span>                :            :                 { "summary-only",     no_argument,       0, 'c' },</a>
<a name="2181"><span class="lineNum">    2181 </span>                :            :                 { "summary",          no_argument,       0, 'C' },</a>
<a name="2182"><span class="lineNum">    2182 </span>                :            :                 { "debug",            no_argument,       0, 'd' },</a>
<a name="2183"><span class="lineNum">    2183 </span>                :            :                 { "daemonize",                optional_argument, 0, GETOPT_DAEMONIZE },</a>
<a name="2184"><span class="lineNum">    2184 </span>                :            :                 { "daemonised",               optional_argument, 0, GETOPT_DAEMONIZE },</a>
<a name="2185"><span class="lineNum">    2185 </span>                :            :                 { "daemonized",               optional_argument, 0, GETOPT_DAEMONIZE },</a>
<a name="2186"><span class="lineNum">    2186 </span>                :            :                 { "env",              required_argument, 0, 'E' },</a>
<a name="2187"><span class="lineNum">    2187 </span>                :            :                 { "follow-forks",     no_argument,       0, GETOPT_FOLLOWFORKS },</a>
<a name="2188"><span class="lineNum">    2188 </span>                :            :                 { "output-separately",        no_argument,       0,</a>
<a name="2189"><span class="lineNum">    2189 </span>                :            :                         GETOPT_OUTPUT_SEPARATELY },</a>
<a name="2190"><span class="lineNum">    2190 </span>                :            :                 { "help",             no_argument,       0, 'h' },</a>
<a name="2191"><span class="lineNum">    2191 </span>                :            :                 { "instruction-pointer", no_argument,      0, 'i' },</a>
<a name="2192"><span class="lineNum">    2192 </span>                :            :                 { "interruptible",    required_argument, 0, 'I' },</a>
<a name="2193"><span class="lineNum">    2193 </span>                :            :                 { "stack-traces",     no_argument,       0, 'k' },</a>
<a name="2194"><span class="lineNum">    2194 </span>                :            :                 { "syscall-number",   no_argument,       0, 'n' },</a>
<a name="2195"><span class="lineNum">    2195 </span>                :            :                 { "output",           required_argument, 0, 'o' },</a>
<a name="2196"><span class="lineNum">    2196 </span>                :            :                 { "summary-syscall-overhead", required_argument, 0, 'O' },</a>
<a name="2197"><span class="lineNum">    2197 </span>                :            :                 { "attach",           required_argument, 0, 'p' },</a>
<a name="2198"><span class="lineNum">    2198 </span>                :            :                 { "trace-path",               required_argument, 0, 'P' },</a>
<a name="2199"><span class="lineNum">    2199 </span>                :            :                 { "relative-timestamps", optional_argument, 0, 'r' },</a>
<a name="2200"><span class="lineNum">    2200 </span>                :            :                 { "string-limit",     required_argument, 0, 's' },</a>
<a name="2201"><span class="lineNum">    2201 </span>                :            :                 { "summary-sort-by",  required_argument, 0, 'S' },</a>
<a name="2202"><span class="lineNum">    2202 </span>                :            :                 { "absolute-timestamps", optional_argument, 0, GETOPT_TS },</a>
<a name="2203"><span class="lineNum">    2203 </span>                :            :                 { "timestamps",               optional_argument, 0, GETOPT_TS },</a>
<a name="2204"><span class="lineNum">    2204 </span>                :            :                 { "syscall-times",    optional_argument, 0, 'T' },</a>
<a name="2205"><span class="lineNum">    2205 </span>                :            :                 { "user",             required_argument, 0, 'u' },</a>
<a name="2206"><span class="lineNum">    2206 </span>                :            :                 { "summary-columns",  required_argument, 0, 'U' },</a>
<a name="2207"><span class="lineNum">    2207 </span>                :            :                 { "no-abbrev",                no_argument,       0, 'v' },</a>
<a name="2208"><span class="lineNum">    2208 </span>                :            :                 { "version",          no_argument,       0, 'V' },</a>
<a name="2209"><span class="lineNum">    2209 </span>                :            :                 { "summary-wall-clock", no_argument,     0, 'w' },</a>
<a name="2210"><span class="lineNum">    2210 </span>                :            :                 { "strings-in-hex",   optional_argument, 0, GETOPT_HEX_STR },</a>
<a name="2211"><span class="lineNum">    2211 </span>                :            :                 { "const-print-style",        required_argument, 0, 'X' },</a>
<a name="2212"><span class="lineNum">    2212 </span>                :            :                 { "pidns-translation",        no_argument      , 0, GETOPT_PIDNS_TRANSLATION },</a>
<a name="2213"><span class="lineNum">    2213 </span>                :            :                 { "successful-only",  no_argument,       0, 'z' },</a>
<a name="2214"><span class="lineNum">    2214 </span>                :            :                 { "failed-only",      no_argument,       0, 'Z' },</a>
<a name="2215"><span class="lineNum">    2215 </span>                :            :                 { "failing-only",     no_argument,       0, 'Z' },</a>
<a name="2216"><span class="lineNum">    2216 </span>                :            :                 { "seccomp-bpf",      no_argument,       0, GETOPT_SECCOMP },</a>
<a name="2217"><span class="lineNum">    2217 </span>                :            : </a>
<a name="2218"><span class="lineNum">    2218 </span>                :            :                 { "trace",    required_argument, 0, GETOPT_QUAL_TRACE },</a>
<a name="2219"><span class="lineNum">    2219 </span>                :            :                 { "abbrev",   required_argument, 0, GETOPT_QUAL_ABBREV },</a>
<a name="2220"><span class="lineNum">    2220 </span>                :            :                 { "verbose",  required_argument, 0, GETOPT_QUAL_VERBOSE },</a>
<a name="2221"><span class="lineNum">    2221 </span>                :            :                 { "raw",      required_argument, 0, GETOPT_QUAL_RAW },</a>
<a name="2222"><span class="lineNum">    2222 </span>                :            :                 { "signals",  required_argument, 0, GETOPT_QUAL_SIGNAL },</a>
<a name="2223"><span class="lineNum">    2223 </span>                :            :                 { "status",   required_argument, 0, GETOPT_QUAL_STATUS },</a>
<a name="2224"><span class="lineNum">    2224 </span>                :            :                 { "read",     required_argument, 0, GETOPT_QUAL_READ },</a>
<a name="2225"><span class="lineNum">    2225 </span>                :            :                 { "write",    required_argument, 0, GETOPT_QUAL_WRITE },</a>
<a name="2226"><span class="lineNum">    2226 </span>                :            :                 { "fault",    required_argument, 0, GETOPT_QUAL_FAULT },</a>
<a name="2227"><span class="lineNum">    2227 </span>                :            :                 { "inject",   required_argument, 0, GETOPT_QUAL_INJECT },</a>
<a name="2228"><span class="lineNum">    2228 </span>                :            :                 { "kvm",      required_argument, 0, GETOPT_QUAL_KVM },</a>
<a name="2229"><span class="lineNum">    2229 </span>                :            :                 { "quiet",    optional_argument, 0, GETOPT_QUAL_QUIET },</a>
<a name="2230"><span class="lineNum">    2230 </span>                :            :                 { "silent",   optional_argument, 0, GETOPT_QUAL_QUIET },</a>
<a name="2231"><span class="lineNum">    2231 </span>                :            :                 { "silence",  optional_argument, 0, GETOPT_QUAL_QUIET },</a>
<a name="2232"><span class="lineNum">    2232 </span>                :            :                 { "decode-fds",       optional_argument, 0, GETOPT_QUAL_DECODE_FD },</a>
<a name="2233"><span class="lineNum">    2233 </span>                :            :                 { "decode-pids",required_argument, 0, GETOPT_QUAL_DECODE_PID },</a>
<a name="2234"><span class="lineNum">    2234 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2235"><span class="lineNum">    2235 </span>                :            :                 { "secontext",                optional_argument, 0, GETOPT_QUAL_SECONTEXT },</a>
<a name="2236"><span class="lineNum">    2236 </span>                :            : #endif</a>
<a name="2237"><span class="lineNum">    2237 </span>                :            : </a>
<a name="2238"><span class="lineNum">    2238 </span>                :            :                 { 0, 0, 0, 0 }</a>
<a name="2239"><span class="lineNum">    2239 </span>                :            :         };</a>
<a name="2240"><span class="lineNum">    2240 </span>                :            : </a>
<a name="2241"><span class="lineNum">    2241 </span>                :<span class="lineCov">      23834 :         lopt_idx = -1;</span></a>
<a name="2242"><span class="lineNum">    2242 </span>        [<span class="branchCov" title="Branch 0 was taken 101430 times"> + </span><span class="branchCov" title="Branch 1 was taken 17606 times"> + </span>]:<span class="lineCov">     142870 :         while ((c = getopt_long(argc, argv, optstring, longopts, &lopt_idx)) != EOF) {</span></a>
<a name="2243"><span class="lineNum">    2243 </span>                :<span class="lineCov">     202860 :                 const struct option *lopt = lopt_idx >= 0</span></a>
<a name="2244"><span class="lineNum">    2244 </span>                :<span class="lineCov">     101430 :                         && (unsigned) lopt_idx < ARRAY_SIZE(longopts)</span></a>
<a name="2245"><span class="lineNum">    2245 </span>        [<span class="branchCov" title="Branch 0 was taken 2810 times"> + </span><span class="branchCov" title="Branch 1 was taken 98620 times"> + </span>]:<span class="lineCov">     101430 :                         ? longopts + lopt_idx : NULL;</span></a>
<a name="2246"><span class="lineNum">    2246 </span>                :<span class="lineCov">     101430 :                 lopt_idx = -1;</span></a>
<a name="2247"><span class="lineNum">    2247 </span>                :            : </a>
<a name="2248"><span class="lineNum">    2248 </span>  [<span class="branchCov" title="Branch 0 was taken 3634 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span><span class="branchCov" title="Branch 2 was taken 8 times"> + </span><span class="branchCov" title="Branch 3 was taken 111 times"> + </span> :<span class="lineCov">     101430 :                 switch (c) {</span></a>
<span class="lineNum">         </span><span class="branchCov" title="Branch 4 was taken 7 times"> + </span><span class="branchCov" title="Branch 5 was taken 12 times"> + </span><span class="branchCov" title="Branch 6 was taken 35 times"> + </span><span class="branchCov" title="Branch 7 was taken 9 times"> + </span><span class="branchCov" title="Branch 8 was taken 36824 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 9 was taken 9 times"> + </span><span class="branchCov" title="Branch 10 was taken 4963 times"> + </span><span class="branchCov" title="Branch 11 was taken 67 times"> + </span><span class="branchCov" title="Branch 12 was taken 8 times"> + </span><span class="branchCov" title="Branch 13 was taken 16 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 14 was taken 4 times"> + </span><span class="branchCov" title="Branch 15 was taken 508 times"> + </span><span class="branchCov" title="Branch 16 was taken 2 times"> + </span><span class="branchCov" title="Branch 17 was taken 4 times"> + </span><span class="branchCov" title="Branch 18 was taken 17331 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 19 was taken 12 times"> + </span><span class="branchCov" title="Branch 20 was taken 44 times"> + </span><span class="branchCov" title="Branch 21 was taken 5438 times"> + </span><span class="branchCov" title="Branch 22 was taken 25333 times"> + </span><span class="branchCov" title="Branch 23 was taken 19 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 24 was taken 72 times"> + </span><span class="branchCov" title="Branch 25 was taken 83 times"> + </span><span class="branchCov" title="Branch 26 was taken 19 times"> + </span><span class="branchCov" title="Branch 27 was taken 51 times"> + </span><span class="branchCov" title="Branch 28 was taken 15 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 29 was taken 20 times"> + </span><span class="branchCov" title="Branch 30 was taken 74 times"> + </span><span class="branchCov" title="Branch 31 was taken 2789 times"> + </span><span class="branchCov" title="Branch 32 was taken 1182 times"> + </span><span class="branchCov" title="Branch 33 was taken 34 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 34 was taken 11 times"> + </span><span class="branchCov" title="Branch 35 was taken 13 times"> + </span><span class="branchCov" title="Branch 36 was taken 351 times"> + </span><span class="branchCov" title="Branch 37 was taken 113 times"> + </span><span class="branchCov" title="Branch 38 was taken 5 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 39 was taken 6 times"> + </span><span class="branchCov" title="Branch 40 was taken 9 times"> + </span><span class="branchCov" title="Branch 41 was taken 5 times"> + </span><span class="branchCov" title="Branch 42 was taken 10 times"> + </span><span class="branchCov" title="Branch 43 was taken 65 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 44 was taken 340 times"> + </span><span class="branchCov" title="Branch 45 was taken 127 times"> + </span><span class="branchCov" title="Branch 46 was taken 127 times"> + </span><span class="branchCov" title="Branch 47 was taken 127 times"> + </span><span class="branchCov" title="Branch 48 was taken 113 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 49 was taken 4 times"> + </span><span class="branchCov" title="Branch 50 was taken 34 times"> + </span><span class="branchCov" title="Branch 51 was taken 34 times"> + </span><span class="branchCov" title="Branch 52 was taken 515 times"> + </span><span class="branchCov" title="Branch 53 was taken 528 times"> + </span> 
<span class="lineNum">         </span><span class="branchCov" title="Branch 54 was taken 1 time"> + </span><span class="branchCov" title="Branch 55 was taken 27 times"> + </span><span class="branchCov" title="Branch 56 was taken 20 times"> + </span><span class="branchCov" title="Branch 57 was taken 102 times"> + </span><span class="branchNoCov" title="Branch 58 was not taken"> - </span> 
<span class="lineNum">         </span>            <span class="branchCov" title="Branch 59 was taken 4 times"> + </span>]
<a name="2249"><span class="lineNum">    2249 </span>                :<span class="lineCov">       3634 :                 case 'a':</span></a>
<a name="2250"><span class="lineNum">    2250 </span>                :<span class="lineCov">       3634 :                         acolumn = string_to_uint(optarg);</span></a>
<a name="2251"><span class="lineNum">    2251 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 3633 times"> + </span>]:<span class="lineCov">       3634 :                         if (acolumn < 0)</span></a>
<a name="2252"><span class="lineNum">    2252 </span>                :<span class="lineCov">          1 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2253"><span class="lineNum">    2253 </span>                :            :                         break;</a>
<a name="2254"><span class="lineNum">    2254 </span>                :<span class="lineCov">          2 :                 case 'A':</span></a>
<a name="2255"><span class="lineNum">    2255 </span>                :<span class="lineCov">          2 :                         open_append = true;</span></a>
<a name="2256"><span class="lineNum">    2256 </span>                :<span class="lineCov">          2 :                         break;</span></a>
<a name="2257"><span class="lineNum">    2257 </span>                :<span class="lineCov">          8 :                 case 'b':</span></a>
<a name="2258"><span class="lineNum">    2258 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          8 :                         if (strcmp(optarg, "execve") != 0)</span></a>
<a name="2259"><span class="lineNum">    2259 </span>                :<span class="lineCov">          4 :                                 error_msg_and_die("Syscall '%s' for -b isn't supported",</span></a>
<a name="2260"><span class="lineNum">    2260 </span>                :            :                                         optarg);</a>
<a name="2261"><span class="lineNum">    2261 </span>                :<span class="lineCov">          4 :                         detach_on_execve = 1;</span></a>
<a name="2262"><span class="lineNum">    2262 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="2263"><span class="lineNum">    2263 </span>                :<span class="lineCov">        111 :                 case 'c':</span></a>
<a name="2264"><span class="lineNum">    2264 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 109 times"> + </span>]:<span class="lineCov">        111 :                         if (cflag == CFLAG_BOTH) {</span></a>
<a name="2265"><span class="lineNum">    2265 </span>                :<span class="lineCov">          2 :                                 error_msg_and_help("-c/--summary-only and "</span></a>
<a name="2266"><span class="lineNum">    2266 </span>                :            :                                                    "-C/--summary are mutually "</a>
<a name="2267"><span class="lineNum">    2267 </span>                :            :                                                    "exclusive");</a>
<a name="2268"><span class="lineNum">    2268 </span>                :            :                         }</a>
<a name="2269"><span class="lineNum">    2269 </span>                :<span class="lineCov">        109 :                         cflag = CFLAG_ONLY_STATS;</span></a>
<a name="2270"><span class="lineNum">    2270 </span>                :<span class="lineCov">        109 :                         break;</span></a>
<a name="2271"><span class="lineNum">    2271 </span>                :<span class="lineCov">          7 :                 case 'C':</span></a>
<a name="2272"><span class="lineNum">    2272 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          7 :                         if (cflag == CFLAG_ONLY_STATS) {</span></a>
<a name="2273"><span class="lineNum">    2273 </span>                :<span class="lineCov">          2 :                                 error_msg_and_help("-c/--summary-only and "</span></a>
<a name="2274"><span class="lineNum">    2274 </span>                :            :                                                    "-C/--summary are mutually "</a>
<a name="2275"><span class="lineNum">    2275 </span>                :            :                                                    "exclusive");</a>
<a name="2276"><span class="lineNum">    2276 </span>                :            :                         }</a>
<a name="2277"><span class="lineNum">    2277 </span>                :<span class="lineCov">          5 :                         cflag = CFLAG_BOTH;</span></a>
<a name="2278"><span class="lineNum">    2278 </span>                :<span class="lineCov">          5 :                         break;</span></a>
<a name="2279"><span class="lineNum">    2279 </span>                :<span class="lineCov">         12 :                 case 'd':</span></a>
<a name="2280"><span class="lineNum">    2280 </span>                :<span class="lineCov">         12 :                         debug_flag = 1;</span></a>
<a name="2281"><span class="lineNum">    2281 </span>                :<span class="lineCov">         12 :                         break;</span></a>
<a name="2282"><span class="lineNum">    2282 </span>                :<span class="lineCov">         35 :                 case 'D':</span></a>
<a name="2283"><span class="lineNum">    2283 </span>                :<span class="lineCov">         35 :                         daemonized_tracer++;</span></a>
<a name="2284"><span class="lineNum">    2284 </span>                :<span class="lineCov">         35 :                         break;</span></a>
<a name="2285"><span class="lineNum">    2285 </span>                :<span class="lineCov">          9 :                 case GETOPT_DAEMONIZE:</span></a>
<a name="2286"><span class="lineNum">    2286 </span>                :<span class="lineCov">         18 :                         daemonized_tracer_long =</span></a>
<a name="2287"><span class="lineNum">    2287 </span>                :<span class="lineCov">          9 :                                 find_arg_val(optarg, daemonize_str,</span></a>
<a name="2288"><span class="lineNum">    2288 </span>                :            :                                              DAEMONIZE_GRANDCHILD,</a>
<a name="2289"><span class="lineNum">    2289 </span>                :            :                                              DAEMONIZE_NONE);</a>
<a name="2290"><span class="lineNum">    2290 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span>]:<span class="lineCov">          9 :                         if (daemonized_tracer_long <= DAEMONIZE_NONE)</span></a>
<a name="2291"><span class="lineNum">    2291 </span>                :<span class="lineCov">          1 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2292"><span class="lineNum">    2292 </span>                :            :                         break;</a>
<a name="2293"><span class="lineNum">    2293 </span>                :<span class="lineCov">      36824 :                 case 'e':</span></a>
<a name="2294"><span class="lineNum">    2294 </span>                :<span class="lineCov">      36824 :                         qualify(optarg);</span></a>
<a name="2295"><span class="lineNum">    2295 </span>                :<span class="lineCov">      36824 :                         break;</span></a>
<a name="2296"><span class="lineNum">    2296 </span>                :<span class="lineCov">          9 :                 case 'E':</span></a>
<a name="2297"><span class="lineNum">    2297 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          9 :                         if (env_change_count >= env_change_size)</span></a>
<a name="2298"><span class="lineNum">    2298 </span>                :<span class="lineCov">          5 :                                 env_changes = xgrowarray(env_changes,</span></a>
<a name="2299"><span class="lineNum">    2299 </span>                :            :                                                          &env_change_size,</a>
<a name="2300"><span class="lineNum">    2300 </span>                :            :                                                          sizeof(*env_changes));</a>
<a name="2301"><span class="lineNum">    2301 </span>                :            : </a>
<a name="2302"><span class="lineNum">    2302 </span>                :<span class="lineCov">          9 :                         env_changes[env_change_count++] = optarg;</span></a>
<a name="2303"><span class="lineNum">    2303 </span>                :<span class="lineCov">          9 :                         break;</span></a>
<a name="2304"><span class="lineNum">    2304 </span>                :<span class="lineCov">       4963 :                 case 'f':</span></a>
<a name="2305"><span class="lineNum">    2305 </span>                :<span class="lineCov">       4963 :                         followfork_short++;</span></a>
<a name="2306"><span class="lineNum">    2306 </span>                :<span class="lineCov">       4963 :                         break;</span></a>
<a name="2307"><span class="lineNum">    2307 </span>                :<span class="lineCov">         67 :                 case GETOPT_FOLLOWFORKS:</span></a>
<a name="2308"><span class="lineNum">    2308 </span>                :<span class="lineCov">         67 :                         followfork = true;</span></a>
<a name="2309"><span class="lineNum">    2309 </span>                :<span class="lineCov">         67 :                         break;</span></a>
<a name="2310"><span class="lineNum">    2310 </span>                :<span class="lineCov">          8 :                 case GETOPT_OUTPUT_SEPARATELY:</span></a>
<a name="2311"><span class="lineNum">    2311 </span>                :<span class="lineCov">          8 :                         output_separately = true;</span></a>
<a name="2312"><span class="lineNum">    2312 </span>                :<span class="lineCov">          8 :                         break;</span></a>
<a name="2313"><span class="lineNum">    2313 </span>                :            :                 case 'F':</a>
<a name="2314"><span class="lineNum">    2314 </span>                :            :                         optF = 1;</a>
<a name="2315"><span class="lineNum">    2315 </span>                :            :                         break;</a>
<a name="2316"><span class="lineNum">    2316 </span>                :<span class="lineCov">         16 :                 case 'h':</span></a>
<a name="2317"><span class="lineNum">    2317 </span>                :<span class="lineCov">         16 :                         usage();</span></a>
<a name="2318"><span class="lineNum">    2318 </span>                :            :                         break;</a>
<a name="2319"><span class="lineNum">    2319 </span>                :<span class="lineCov">          4 :                 case 'i':</span></a>
<a name="2320"><span class="lineNum">    2320 </span>                :<span class="lineCov">          4 :                         iflag = 1;</span></a>
<a name="2321"><span class="lineNum">    2321 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="2322"><span class="lineNum">    2322 </span>                :<span class="lineCov">        508 :                 case 'I':</span></a>
<a name="2323"><span class="lineNum">    2323 </span>                :<span class="lineCov">        508 :                         opt_intr = parse_interruptible_arg(optarg);</span></a>
<a name="2324"><span class="lineNum">    2324 </span>        [<span class="branchCov" title="Branch 0 was taken 11 times"> + </span><span class="branchCov" title="Branch 1 was taken 497 times"> + </span>]:<span class="lineCov">        508 :                         if (opt_intr <= 0)</span></a>
<a name="2325"><span class="lineNum">    2325 </span>                :<span class="lineCov">         11 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2326"><span class="lineNum">    2326 </span>                :            :                         break;</a>
<a name="2327"><span class="lineNum">    2327 </span>                :<span class="lineCov">          2 :                 case 'k':</span></a>
<a name="2328"><span class="lineNum">    2328 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="2329"><span class="lineNum">    2329 </span>                :            :                         stack_trace_enabled = true;</a>
<a name="2330"><span class="lineNum">    2330 </span>                :            : #else</a>
<a name="2331"><span class="lineNum">    2331 </span>                :<span class="lineCov">          2 :                         error_msg_and_die("Stack traces (-k/--stack-traces "</span></a>
<a name="2332"><span class="lineNum">    2332 </span>                :            :                                           "option) are not supported by this "</a>
<a name="2333"><span class="lineNum">    2333 </span>                :            :                                           "build of strace");</a>
<a name="2334"><span class="lineNum">    2334 </span>                :            : #endif</a>
<a name="2335"><span class="lineNum">    2335 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="2336"><span class="lineNum">    2336 </span>                :<span class="lineCov">          4 :                 case 'n':</span></a>
<a name="2337"><span class="lineNum">    2337 </span>                :<span class="lineCov">          4 :                         nflag = 1;</span></a>
<a name="2338"><span class="lineNum">    2338 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="2339"><span class="lineNum">    2339 </span>                :<span class="lineCov">      17331 :                 case 'o':</span></a>
<a name="2340"><span class="lineNum">    2340 </span>                :<span class="lineCov">      17331 :                         outfname = optarg;</span></a>
<a name="2341"><span class="lineNum">    2341 </span>                :<span class="lineCov">      17331 :                         break;</span></a>
<a name="2342"><span class="lineNum">    2342 </span>                :<span class="lineCov">         12 :                 case 'O':</span></a>
<a name="2343"><span class="lineNum">    2343 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 11 times"> + </span>]:<span class="lineCov">         12 :                         if (set_overhead(optarg) < 0)</span></a>
<a name="2344"><span class="lineNum">    2344 </span>                :<span class="lineCov">          1 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2345"><span class="lineNum">    2345 </span>                :            :                         break;</a>
<a name="2346"><span class="lineNum">    2346 </span>                :<span class="lineCov">         44 :                 case 'p':</span></a>
<a name="2347"><span class="lineNum">    2347 </span>                :<span class="lineCov">         44 :                         process_opt_p_list(optarg);</span></a>
<a name="2348"><span class="lineNum">    2348 </span>                :<span class="lineCov">         44 :                         break;</span></a>
<a name="2349"><span class="lineNum">    2349 </span>                :<span class="lineCov">       5438 :                 case 'P':</span></a>
<a name="2350"><span class="lineNum">    2350 </span>        [<span class="branchCov" title="Branch 0 was taken 2735 times"> + </span><span class="branchCov" title="Branch 1 was taken 2703 times"> + </span>]:<span class="lineCov">       5438 :                         if (pathtrace_count >= pathtrace_size)</span></a>
<a name="2351"><span class="lineNum">    2351 </span>                :<span class="lineCov">       2735 :                                 pathtrace_paths = xgrowarray(pathtrace_paths,</span></a>
<a name="2352"><span class="lineNum">    2352 </span>                :            :                                         &pathtrace_size,</a>
<a name="2353"><span class="lineNum">    2353 </span>                :            :                                         sizeof(pathtrace_paths[0]));</a>
<a name="2354"><span class="lineNum">    2354 </span>                :            : </a>
<a name="2355"><span class="lineNum">    2355 </span>                :<span class="lineCov">       5438 :                         pathtrace_paths[pathtrace_count++] = optarg;</span></a>
<a name="2356"><span class="lineNum">    2356 </span>                :<span class="lineCov">       5438 :                         break;</span></a>
<a name="2357"><span class="lineNum">    2357 </span>                :<span class="lineCov">      25333 :                 case 'q':</span></a>
<a name="2358"><span class="lineNum">    2358 </span>                :<span class="lineCov">      25333 :                         qflag_short++;</span></a>
<a name="2359"><span class="lineNum">    2359 </span>                :<span class="lineCov">      25333 :                         break;</span></a>
<a name="2360"><span class="lineNum">    2360 </span>                :<span class="lineCov">         19 :                 case 'r':</span></a>
<a name="2361"><span class="lineNum">    2361 </span>                :<span class="lineCov">         19 :                         rflag = 1;</span></a>
<a name="2362"><span class="lineNum">    2362 </span>                :<span class="lineCov">         19 :                         rflag_width = 6;</span></a>
<a name="2363"><span class="lineNum">    2363 </span>                :<span class="lineCov">         19 :                         rflag_scale = str2timescale_optarg(optarg,</span></a>
<a name="2364"><span class="lineNum">    2364 </span>                :            :                                                            &rflag_width);</a>
<a name="2365"><span class="lineNum">    2365 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         19 :                         if (rflag_scale < 0)</span></a>
<a name="2366"><span class="lineNum">    2366 </span>                :<span class="lineCov">          2 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2367"><span class="lineNum">    2367 </span>                :            :                         break;</a>
<a name="2368"><span class="lineNum">    2368 </span>                :<span class="lineCov">         72 :                 case 's':</span></a>
<a name="2369"><span class="lineNum">    2369 </span>                :<span class="lineCov">         72 :                         i = string_to_uint(optarg);</span></a>
<a name="2370"><span class="lineNum">    2370 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 68 times"> + </span>]:<span class="lineCov">         72 :                         if (i < 0 || (unsigned int) i > -1U / 4)</span></a>
<a name="2371"><span class="lineNum">    2371 </span>                :<span class="lineCov">          4 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2372"><span class="lineNum">    2372 </span>                :<span class="lineCov">         68 :                         max_strlen = i;</span></a>
<a name="2373"><span class="lineNum">    2373 </span>                :<span class="lineCov">         68 :                         break;</span></a>
<a name="2374"><span class="lineNum">    2374 </span>                :<span class="lineCov">         83 :                 case 'S':</span></a>
<a name="2375"><span class="lineNum">    2375 </span>                :<span class="lineCov">         83 :                         set_sortby(optarg);</span></a>
<a name="2376"><span class="lineNum">    2376 </span>                :<span class="lineCov">         83 :                         sortby_set = true;</span></a>
<a name="2377"><span class="lineNum">    2377 </span>                :<span class="lineCov">         83 :                         break;</span></a>
<a name="2378"><span class="lineNum">    2378 </span>                :<span class="lineCov">         19 :                 case 't':</span></a>
<a name="2379"><span class="lineNum">    2379 </span>                :<span class="lineCov">         19 :                         tflag_short++;</span></a>
<a name="2380"><span class="lineNum">    2380 </span>                :<span class="lineCov">         19 :                         break;</span></a>
<a name="2381"><span class="lineNum">    2381 </span>                :<span class="lineCov">         51 :                 case GETOPT_TS:</span></a>
<a name="2382"><span class="lineNum">    2382 </span>                :<span class="lineCov">         51 :                         tflag_long_set = true;</span></a>
<a name="2383"><span class="lineNum">    2383 </span>  [<span class="branchCov" title="Branch 0 was taken 6 times"> + </span><span class="branchCov" title="Branch 1 was taken 45 times"> + </span><span class="branchCov" title="Branch 2 was taken 4 times"> + </span><span class="branchCov" title="Branch 3 was taken 47 times"> + </span>]:<span class="lineCov">         57 :                         if (parse_ts_arg(optarg ?: tflag_str))</span></a>
<a name="2384"><span class="lineNum">    2384 </span>                :<span class="lineCov">          4 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2385"><span class="lineNum">    2385 </span>                :            :                         break;</a>
<a name="2386"><span class="lineNum">    2386 </span>                :<span class="lineCov">         15 :                 case 'T':</span></a>
<a name="2387"><span class="lineNum">    2387 </span>                :<span class="lineCov">         15 :                         Tflag = 1;</span></a>
<a name="2388"><span class="lineNum">    2388 </span>                :<span class="lineCov">         15 :                         Tflag_width = 6;</span></a>
<a name="2389"><span class="lineNum">    2389 </span>                :<span class="lineCov">         15 :                         Tflag_scale = str2timescale_optarg(optarg,</span></a>
<a name="2390"><span class="lineNum">    2390 </span>                :            :                                                            &Tflag_width);</a>
<a name="2391"><span class="lineNum">    2391 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 13 times"> + </span>]:<span class="lineCov">         15 :                         if (Tflag_scale < 0)</span></a>
<a name="2392"><span class="lineNum">    2392 </span>                :<span class="lineCov">          2 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2393"><span class="lineNum">    2393 </span>                :            :                         break;</a>
<a name="2394"><span class="lineNum">    2394 </span>                :<span class="lineCov">         20 :                 case 'u':</span></a>
<a name="2395"><span class="lineNum">    2395 </span>                :<span class="lineCov">         20 :                         username = optarg;</span></a>
<a name="2396"><span class="lineNum">    2396 </span>                :<span class="lineCov">         20 :                         break;</span></a>
<a name="2397"><span class="lineNum">    2397 </span>                :<span class="lineCov">         74 :                 case 'U':</span></a>
<a name="2398"><span class="lineNum">    2398 </span>                :<span class="lineCov">         74 :                         columns_set = true;</span></a>
<a name="2399"><span class="lineNum">    2399 </span>                :<span class="lineCov">         74 :                         set_count_summary_columns(optarg);</span></a>
<a name="2400"><span class="lineNum">    2400 </span>                :<span class="lineCov">         74 :                         break;</span></a>
<a name="2401"><span class="lineNum">    2401 </span>                :<span class="lineCov">       2789 :                 case 'v':</span></a>
<a name="2402"><span class="lineNum">    2402 </span>                :<span class="lineCov">       2789 :                         qualify_abbrev("none");</span></a>
<a name="2403"><span class="lineNum">    2403 </span>                :<span class="lineCov">       2789 :                         break;</span></a>
<a name="2404"><span class="lineNum">    2404 </span>                :<span class="lineCov">       1182 :                 case 'V':</span></a>
<a name="2405"><span class="lineNum">    2405 </span>                :<span class="lineCov">       1182 :                         print_version();</span></a>
<a name="2406"><span class="lineNum">    2406 </span>                :<span class="lineCov">       1182 :                         exit(0);</span></a>
<a name="2407"><span class="lineNum">    2407 </span>                :<span class="lineCov">         34 :                         break;</span></a>
<a name="2408"><span class="lineNum">    2408 </span>                :<span class="lineCov">         34 :                 case 'w':</span></a>
<a name="2409"><span class="lineNum">    2409 </span>                :<span class="lineCov">         34 :                         count_wallclock = 1;</span></a>
<a name="2410"><span class="lineNum">    2410 </span>                :<span class="lineCov">         34 :                         break;</span></a>
<a name="2411"><span class="lineNum">    2411 </span>                :<span class="lineCov">         11 :                 case 'x':</span></a>
<a name="2412"><span class="lineNum">    2412 </span>                :<span class="lineCov">         11 :                         xflag = MIN(xflag + 1, HEXSTR_ALL);</span></a>
<a name="2413"><span class="lineNum">    2413 </span>                :<span class="lineCov">         11 :                         break;</span></a>
<a name="2414"><span class="lineNum">    2414 </span>                :<span class="lineCov">         13 :                 case GETOPT_HEX_STR:</span></a>
<a name="2415"><span class="lineNum">    2415 </span>                :<span class="lineCov">         13 :                         xflag_long = find_arg_val(optarg, xflag_str,</span></a>
<a name="2416"><span class="lineNum">    2416 </span>                :            :                                                   HEXSTR_ALL, -1);</a>
<a name="2417"><span class="lineNum">    2417 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 10 times"> + </span>]:<span class="lineCov">         13 :                         if (xflag_long < HEXSTR_NONE)</span></a>
<a name="2418"><span class="lineNum">    2418 </span>                :<span class="lineCov">          3 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2419"><span class="lineNum">    2419 </span>                :            :                         break;</a>
<a name="2420"><span class="lineNum">    2420 </span>                :<span class="lineCov">        351 :                 case 'X':</span></a>
<a name="2421"><span class="lineNum">    2421 </span>        [<span class="branchCov" title="Branch 0 was taken 114 times"> + </span><span class="branchCov" title="Branch 1 was taken 237 times"> + </span>]:<span class="lineCov">        351 :                         if (!strcmp(optarg, "raw"))</span></a>
<a name="2422"><span class="lineNum">    2422 </span>                :<span class="lineCov">        114 :                                 xlat_verbosity = XLAT_STYLE_RAW;</span></a>
<a name="2423"><span class="lineNum">    2423 </span>        [<span class="branchCov" title="Branch 0 was taken 114 times"> + </span><span class="branchCov" title="Branch 1 was taken 123 times"> + </span>]:<span class="lineCov">        237 :                         else if (!strcmp(optarg, "abbrev"))</span></a>
<a name="2424"><span class="lineNum">    2424 </span>                :<span class="lineCov">        114 :                                 xlat_verbosity = XLAT_STYLE_ABBREV;</span></a>
<a name="2425"><span class="lineNum">    2425 </span>        [<span class="branchCov" title="Branch 0 was taken 117 times"> + </span><span class="branchCov" title="Branch 1 was taken 6 times"> + </span>]:<span class="lineCov">        123 :                         else if (!strcmp(optarg, "verbose"))</span></a>
<a name="2426"><span class="lineNum">    2426 </span>                :<span class="lineCov">        117 :                                 xlat_verbosity = XLAT_STYLE_VERBOSE;</span></a>
<a name="2427"><span class="lineNum">    2427 </span>                :            :                         else</a>
<a name="2428"><span class="lineNum">    2428 </span>                :<span class="lineCov">          6 :                                 error_opt_arg(c, lopt, optarg);</span></a>
<a name="2429"><span class="lineNum">    2429 </span>                :            :                         break;</a>
<a name="2430"><span class="lineNum">    2430 </span>                :<span class="lineCov">        113 :                 case 'y':</span></a>
<a name="2431"><span class="lineNum">    2431 </span>                :<span class="lineCov">        113 :                         yflag_short++;</span></a>
<a name="2432"><span class="lineNum">    2432 </span>                :<span class="lineCov">        113 :                         break;</span></a>
<a name="2433"><span class="lineNum">    2433 </span>                :<span class="lineCov">          5 :                 case 'Y':</span></a>
<a name="2434"><span class="lineNum">    2434 </span>                :<span class="lineCov">          5 :                         qualify_decode_pid("comm");</span></a>
<a name="2435"><span class="lineNum">    2435 </span>                :<span class="lineCov">          5 :                         break;</span></a>
<a name="2436"><span class="lineNum">    2436 </span>                :<span class="lineCov">          6 :                 case GETOPT_PIDNS_TRANSLATION:</span></a>
<a name="2437"><span class="lineNum">    2437 </span>                :<span class="lineCov">          6 :                         qualify_decode_pid("pidns");</span></a>
<a name="2438"><span class="lineNum">    2438 </span>                :<span class="lineCov">          6 :                         break;</span></a>
<a name="2439"><span class="lineNum">    2439 </span>                :<span class="lineCov">          9 :                 case 'z':</span></a>
<a name="2440"><span class="lineNum">    2440 </span>                :<span class="lineCov">          9 :                         clear_number_set_array(status_set, 1);</span></a>
<a name="2441"><span class="lineNum">    2441 </span>                :<span class="lineCov">          9 :                         add_number_to_set(STATUS_SUCCESSFUL, status_set);</span></a>
<a name="2442"><span class="lineNum">    2442 </span>                :<span class="lineCov">          9 :                         zflags++;</span></a>
<a name="2443"><span class="lineNum">    2443 </span>                :<span class="lineCov">          9 :                         break;</span></a>
<a name="2444"><span class="lineNum">    2444 </span>                :<span class="lineCov">          5 :                 case 'Z':</span></a>
<a name="2445"><span class="lineNum">    2445 </span>                :<span class="lineCov">          5 :                         clear_number_set_array(status_set, 1);</span></a>
<a name="2446"><span class="lineNum">    2446 </span>                :<span class="lineCov">          5 :                         add_number_to_set(STATUS_FAILED, status_set);</span></a>
<a name="2447"><span class="lineNum">    2447 </span>                :<span class="lineCov">          5 :                         zflags++;</span></a>
<a name="2448"><span class="lineNum">    2448 </span>                :<span class="lineCov">          5 :                         break;</span></a>
<a name="2449"><span class="lineNum">    2449 </span>                :<span class="lineCov">         10 :                 case GETOPT_SECCOMP:</span></a>
<a name="2450"><span class="lineNum">    2450 </span>                :<span class="lineCov">         10 :                         seccomp_filtering = true;</span></a>
<a name="2451"><span class="lineNum">    2451 </span>                :<span class="lineCov">         10 :                         break;</span></a>
<a name="2452"><span class="lineNum">    2452 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2453"><span class="lineNum">    2453 </span>                :<span class="lineCov">         65 :                 case GETOPT_QUAL_SECONTEXT:</span></a>
<a name="2454"><span class="lineNum">    2454 </span>        [<span class="branchCov" title="Branch 0 was taken 50 times"> + </span><span class="branchCov" title="Branch 1 was taken 15 times"> + </span>]:<span class="lineCov">         65 :                         qualify_secontext(optarg ? optarg : secontext_qual);</span></a>
<a name="2455"><span class="lineNum">    2455 </span>                :<span class="lineCov">         65 :                         break;</span></a>
<a name="2456"><span class="lineNum">    2456 </span>                :            : #endif</a>
<a name="2457"><span class="lineNum">    2457 </span>                :<span class="lineCov">        340 :                 case GETOPT_QUAL_TRACE:</span></a>
<a name="2458"><span class="lineNum">    2458 </span>                :<span class="lineCov">        340 :                         qualify_trace(optarg);</span></a>
<a name="2459"><span class="lineNum">    2459 </span>                :<span class="lineCov">        340 :                         break;</span></a>
<a name="2460"><span class="lineNum">    2460 </span>                :<span class="lineCov">        127 :                 case GETOPT_QUAL_ABBREV:</span></a>
<a name="2461"><span class="lineNum">    2461 </span>                :<span class="lineCov">        127 :                         qualify_abbrev(optarg);</span></a>
<a name="2462"><span class="lineNum">    2462 </span>                :<span class="lineCov">        127 :                         break;</span></a>
<a name="2463"><span class="lineNum">    2463 </span>                :<span class="lineCov">        127 :                 case GETOPT_QUAL_VERBOSE:</span></a>
<a name="2464"><span class="lineNum">    2464 </span>                :<span class="lineCov">        127 :                         qualify_verbose(optarg);</span></a>
<a name="2465"><span class="lineNum">    2465 </span>                :<span class="lineCov">        127 :                         break;</span></a>
<a name="2466"><span class="lineNum">    2466 </span>                :<span class="lineCov">        127 :                 case GETOPT_QUAL_RAW:</span></a>
<a name="2467"><span class="lineNum">    2467 </span>                :<span class="lineCov">        127 :                         qualify_raw(optarg);</span></a>
<a name="2468"><span class="lineNum">    2468 </span>                :<span class="lineCov">        127 :                         break;</span></a>
<a name="2469"><span class="lineNum">    2469 </span>                :<span class="lineCov">        113 :                 case GETOPT_QUAL_SIGNAL:</span></a>
<a name="2470"><span class="lineNum">    2470 </span>                :<span class="lineCov">        113 :                         qualify_signals(optarg);</span></a>
<a name="2471"><span class="lineNum">    2471 </span>                :<span class="lineCov">        113 :                         break;</span></a>
<a name="2472"><span class="lineNum">    2472 </span>                :<span class="lineCov">          4 :                 case GETOPT_QUAL_STATUS:</span></a>
<a name="2473"><span class="lineNum">    2473 </span>                :<span class="lineCov">          4 :                         qualify_status(optarg);</span></a>
<a name="2474"><span class="lineNum">    2474 </span>                :<span class="lineCov">          4 :                         break;</span></a>
<a name="2475"><span class="lineNum">    2475 </span>                :<span class="lineCov">         34 :                 case GETOPT_QUAL_READ:</span></a>
<a name="2476"><span class="lineNum">    2476 </span>                :<span class="lineCov">         34 :                         qualify_read(optarg);</span></a>
<a name="2477"><span class="lineNum">    2477 </span>                :<span class="lineCov">         34 :                         break;</span></a>
<a name="2478"><span class="lineNum">    2478 </span>                :<span class="lineCov">         34 :                 case GETOPT_QUAL_WRITE:</span></a>
<a name="2479"><span class="lineNum">    2479 </span>                :<span class="lineCov">         34 :                         qualify_write(optarg);</span></a>
<a name="2480"><span class="lineNum">    2480 </span>                :<span class="lineCov">         34 :                         break;</span></a>
<a name="2481"><span class="lineNum">    2481 </span>                :<span class="lineCov">        515 :                 case GETOPT_QUAL_FAULT:</span></a>
<a name="2482"><span class="lineNum">    2482 </span>                :<span class="lineCov">        515 :                         qualify_fault(optarg);</span></a>
<a name="2483"><span class="lineNum">    2483 </span>                :<span class="lineCov">        515 :                         break;</span></a>
<a name="2484"><span class="lineNum">    2484 </span>                :<span class="lineCov">        528 :                 case GETOPT_QUAL_INJECT:</span></a>
<a name="2485"><span class="lineNum">    2485 </span>                :<span class="lineCov">        528 :                         qualify_inject(optarg);</span></a>
<a name="2486"><span class="lineNum">    2486 </span>                :<span class="lineCov">        528 :                         break;</span></a>
<a name="2487"><span class="lineNum">    2487 </span>                :<span class="lineCov">          1 :                 case GETOPT_QUAL_KVM:</span></a>
<a name="2488"><span class="lineNum">    2488 </span>                :<span class="lineCov">          1 :                         qualify_kvm(optarg);</span></a>
<a name="2489"><span class="lineNum">    2489 </span>                :<span class="lineCov">          1 :                         break;</span></a>
<a name="2490"><span class="lineNum">    2490 </span>                :<span class="lineCov">         27 :                 case GETOPT_QUAL_QUIET:</span></a>
<a name="2491"><span class="lineNum">    2491 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 25 times"> + </span>]:<span class="lineCov">         27 :                         qualify_quiet(optarg ?: qflag_qual);</span></a>
<a name="2492"><span class="lineNum">    2492 </span>                :<span class="lineCov">         27 :                         break;</span></a>
<a name="2493"><span class="lineNum">    2493 </span>                :<span class="lineCov">         20 :                 case GETOPT_QUAL_DECODE_FD:</span></a>
<a name="2494"><span class="lineNum">    2494 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         20 :                         qualify_decode_fd(optarg ?: yflag_qual);</span></a>
<a name="2495"><span class="lineNum">    2495 </span>                :<span class="lineCov">         20 :                         break;</span></a>
<a name="2496"><span class="lineNum">    2496 </span>                :<span class="lineCov">        102 :                 case GETOPT_QUAL_DECODE_PID:</span></a>
<a name="2497"><span class="lineNum">    2497 </span>                :<span class="lineCov">        102 :                         qualify_decode_pid(optarg);</span></a>
<a name="2498"><span class="lineNum">    2498 </span>                :<span class="lineCov">        102 :                         break;</span></a>
<a name="2499"><span class="lineNum">    2499 </span>                :<span class="lineNoCov">          0 :                 default:</span></a>
<a name="2500"><span class="lineNum">    2500 </span>                :<span class="lineNoCov">          0 :                         error_msg_and_help(NULL);</span></a>
<a name="2501"><span class="lineNum">    2501 </span>                :<span class="lineCov">     119036 :                         break;</span></a>
<a name="2502"><span class="lineNum">    2502 </span>                :            :                 }</a>
<a name="2503"><span class="lineNum">    2503 </span>                :            :         }</a>
<a name="2504"><span class="lineNum">    2504 </span>                :            : </a>
<a name="2505"><span class="lineNum">    2505 </span>                :<span class="lineCov">      17606 :         argv += optind;</span></a>
<a name="2506"><span class="lineNum">    2506 </span>                :<span class="lineCov">      17606 :         argc -= optind;</span></a>
<a name="2507"><span class="lineNum">    2507 </span>                :            : </a>
<a name="2508"><span class="lineNum">    2508 </span>  [<span class="branchCov" title="Branch 0 was taken 17605 times"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchCov" title="Branch 2 was taken 17570 times"> + </span><span class="branchCov" title="Branch 3 was taken 35 times"> + </span> :<span class="lineCov">      17606 :         if (argc < 0 || (!nprocs && !argc)) {</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 193 times"> + </span><span class="branchCov" title="Branch 5 was taken 17377 times"> + </span>]
<a name="2509"><span class="lineNum">    2509 </span>                :<span class="lineCov">        194 :                 error_msg_and_help("must have PROG [ARGS] or -p PID");</span></a>
<a name="2510"><span class="lineNum">    2510 </span>                :            :         }</a>
<a name="2511"><span class="lineNum">    2511 </span>                :            : </a>
<a name="2512"><span class="lineNum">    2512 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 17404 times"> + </span>]:<span class="lineCov">      17412 :         if (daemonized_tracer_long) {</span></a>
<a name="2513"><span class="lineNum">    2513 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          8 :                 if (daemonized_tracer) {</span></a>
<a name="2514"><span class="lineNum">    2514 </span>                :<span class="lineCov">          3 :                         error_msg_and_die("-D and --daemonize cannot"</span></a>
<a name="2515"><span class="lineNum">    2515 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2516"><span class="lineNum">    2516 </span>                :            :                 } else {</a>
<a name="2517"><span class="lineNum">    2517 </span>                :<span class="lineCov">          5 :                         daemonized_tracer = daemonized_tracer_long;</span></a>
<a name="2518"><span class="lineNum">    2518 </span>                :            :                 }</a>
<a name="2519"><span class="lineNum">    2519 </span>                :            :         }</a>
<a name="2520"><span class="lineNum">    2520 </span>                :            : </a>
<a name="2521"><span class="lineNum">    2521 </span>  [<span class="branchCov" title="Branch 0 was taken 31 times"> + </span><span class="branchCov" title="Branch 1 was taken 17378 times"> + </span><span class="branchCov" title="Branch 2 was taken 9 times"> + </span><span class="branchCov" title="Branch 3 was taken 22 times"> + </span>]:<span class="lineCov">      17409 :         if (!argc && daemonized_tracer) {</span></a>
<a name="2522"><span class="lineNum">    2522 </span>                :<span class="lineCov">          9 :                 error_msg_and_help("PROG [ARGS] must be specified with "</span></a>
<a name="2523"><span class="lineNum">    2523 </span>                :            :                                    "-D/--daemonize");</a>
<a name="2524"><span class="lineNum">    2524 </span>                :            :         }</a>
<a name="2525"><span class="lineNum">    2525 </span>                :            : </a>
<a name="2526"><span class="lineNum">    2526 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 17399 times"> + </span>]:<span class="lineCov">      17400 :         if (daemonized_tracer > (unsigned int) MAX_DAEMONIZE_OPTS)</span></a>
<a name="2527"><span class="lineNum">    2527 </span>                :<span class="lineCov">          1 :                 error_msg_and_help("Too many -D's (%u), maximum supported -D "</span></a>
<a name="2528"><span class="lineNum">    2528 </span>                :            :                                    "count is %d",</a>
<a name="2529"><span class="lineNum">    2529 </span>                :            :                                    daemonized_tracer, MAX_DAEMONIZE_OPTS);</a>
<a name="2530"><span class="lineNum">    2530 </span>                :            : </a>
<a name="2531"><span class="lineNum">    2531 </span>        [<span class="branchCov" title="Branch 0 was taken 11 times"> + </span><span class="branchCov" title="Branch 1 was taken 17388 times"> + </span>]:<span class="lineCov">      17399 :         if (tflag_short) {</span></a>
<a name="2532"><span class="lineNum">    2532 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 7 times"> + </span>]:<span class="lineCov">         11 :                 if (tflag_long_set) {</span></a>
<a name="2533"><span class="lineNum">    2533 </span>                :<span class="lineCov">          4 :                         error_msg_and_die("-t and --absolute-timestamps cannot"</span></a>
<a name="2534"><span class="lineNum">    2534 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2535"><span class="lineNum">    2535 </span>                :            :                 }</a>
<a name="2536"><span class="lineNum">    2536 </span>                :            : </a>
<a name="2537"><span class="lineNum">    2537 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         11 :                 parse_ts_arg(tflag_short == 1 ? tflag_str :</span></a>
<a name="2538"><span class="lineNum">    2538 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          4 :                              tflag_short == 2 ? ttflag_str : tttflag_str);</span></a>
<a name="2539"><span class="lineNum">    2539 </span>                :            :         }</a>
<a name="2540"><span class="lineNum">    2540 </span>                :            : </a>
<a name="2541"><span class="lineNum">    2541 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 17388 times"> + </span>]:<span class="lineCov">      17395 :         if (xflag_long >= 0) {</span></a>
<a name="2542"><span class="lineNum">    2542 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          7 :                 if (xflag) {</span></a>
<a name="2543"><span class="lineNum">    2543 </span>                :<span class="lineCov">          2 :                         error_msg_and_die("-x and --strings-in-hex cannot"</span></a>
<a name="2544"><span class="lineNum">    2544 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2545"><span class="lineNum">    2545 </span>                :            :                 } else {</a>
<a name="2546"><span class="lineNum">    2546 </span>                :<span class="lineCov">          5 :                         xflag = xflag_long;</span></a>
<a name="2547"><span class="lineNum">    2547 </span>                :            :                 }</a>
<a name="2548"><span class="lineNum">    2548 </span>                :            :         }</a>
<a name="2549"><span class="lineNum">    2549 </span>                :            : </a>
<a name="2550"><span class="lineNum">    2550 </span>        [<span class="branchCov" title="Branch 0 was taken 99 times"> + </span><span class="branchCov" title="Branch 1 was taken 17294 times"> + </span>]:<span class="lineCov">      17393 :         if (yflag_short) {</span></a>
<a name="2551"><span class="lineNum">    2551 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 96 times"> + </span>]:<span class="lineCov">         99 :                 if (decode_fd_set_updated) {</span></a>
<a name="2552"><span class="lineNum">    2552 </span>                :<span class="lineCov">          3 :                         error_msg_and_die("-y and --decode-fds cannot"</span></a>
<a name="2553"><span class="lineNum">    2553 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2554"><span class="lineNum">    2554 </span>                :            :                 }</a>
<a name="2555"><span class="lineNum">    2555 </span>                :            : </a>
<a name="2556"><span class="lineNum">    2556 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 84 times"> + </span>]:<span class="lineCov">        108 :                 qualify_decode_fd(yflag_short == 1 ? yflag_qual : yyflag_qual);</span></a>
<a name="2557"><span class="lineNum">    2557 </span>                :            :         }</a>
<a name="2558"><span class="lineNum">    2558 </span>                :            : </a>
<a name="2559"><span class="lineNum">    2559 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 17387 times"> + </span>]:<span class="lineCov">      17390 :         if (is_number_in_set(DECODE_PID_COMM, decode_pid_set)) {</span></a>
<a name="2560"><span class="lineNum">    2560 </span>                :            :                 /*</a>
<a name="2561"><span class="lineNum">    2561 </span>                :            :                  * If --decode-pids=comm option comes after -p, comm fields</a>
<a name="2562"><span class="lineNum">    2562 </span>                :            :                  * of tcbs are not filled though tcbs are initialized.</a>
<a name="2563"><span class="lineNum">    2563 </span>                :            :                  * We must fill the fields here.</a>
<a name="2564"><span class="lineNum">    2564 </span>                :            :                  */</a>
<a name="2565"><span class="lineNum">    2565 </span>        [<span class="branchCov" title="Branch 0 was taken 16 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">         19 :                 for (unsigned int i = 0; i < tcbtabsize; ++i) {</span></a>
<a name="2566"><span class="lineNum">    2566 </span>                :<span class="lineCov">         16 :                         struct tcb *tcp = tcbtab[i];</span></a>
<a name="2567"><span class="lineNum">    2567 </span>        [<span class="branchCov" title="Branch 0 was taken 15 times"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">         16 :                         if (tcp->comm[0] == 0)</span></a>
<a name="2568"><span class="lineNum">    2568 </span>                :<span class="lineCov">         15 :                                 maybe_load_task_comm(tcp);</span></a>
<a name="2569"><span class="lineNum">    2569 </span>                :            :                 }</a>
<a name="2570"><span class="lineNum">    2570 </span>                :            :         }</a>
<a name="2571"><span class="lineNum">    2571 </span>                :            : </a>
<a name="2572"><span class="lineNum">    2572 </span>  [<span class="branchCov" title="Branch 0 was taken 10 times"> + </span><span class="branchCov" title="Branch 1 was taken 17380 times"> + </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span><span class="branchCov" title="Branch 3 was taken 9 times"> + </span>]:<span class="lineCov">      17390 :         if (seccomp_filtering && detach_on_execve) {</span></a>
<a name="2573"><span class="lineNum">    2573 </span>                :<span class="lineCov">          1 :                 error_msg("--seccomp-bpf is not enabled because"</span></a>
<a name="2574"><span class="lineNum">    2574 </span>                :            :                           " it is not compatible with -b");</a>
<a name="2575"><span class="lineNum">    2575 </span>                :<span class="lineCov">          1 :                 seccomp_filtering = false;</span></a>
<a name="2576"><span class="lineNum">    2576 </span>                :            :         }</a>
<a name="2577"><span class="lineNum">    2577 </span>                :            : </a>
<a name="2578"><span class="lineNum">    2578 </span>        [<span class="branchCov" title="Branch 0 was taken 2547 times"> + </span><span class="branchCov" title="Branch 1 was taken 14843 times"> + </span>]:<span class="lineCov">      17390 :         if (followfork_short) {</span></a>
<a name="2579"><span class="lineNum">    2579 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 2546 times"> + </span>]:<span class="lineCov">       2547 :                 if (followfork) {</span></a>
<a name="2580"><span class="lineNum">    2580 </span>                :<span class="lineCov">          1 :                         error_msg_and_die("-f and --follow-forks cannot"</span></a>
<a name="2581"><span class="lineNum">    2581 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2582"><span class="lineNum">    2582 </span>  [<span class="branchCov" title="Branch 0 was taken 2415 times"> + </span><span class="branchCov" title="Branch 1 was taken 131 times"> + </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span><span class="branchCov" title="Branch 3 was taken 2414 times"> + </span>]:<span class="lineCov">       2546 :                 } else if (followfork_short >= 2 && output_separately) {</span></a>
<a name="2583"><span class="lineNum">    2583 </span>                :<span class="lineCov">          1 :                         error_msg_and_die("-ff and --output-separately cannot"</span></a>
<a name="2584"><span class="lineNum">    2584 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2585"><span class="lineNum">    2585 </span>                :            :                 } else {</a>
<a name="2586"><span class="lineNum">    2586 </span>                :<span class="lineCov">       2545 :                         followfork = true;</span></a>
<a name="2587"><span class="lineNum">    2587 </span>                :<span class="lineCov">       2545 :                         output_separately = followfork_short >= 2;</span></a>
<a name="2588"><span class="lineNum">    2588 </span>                :            :                 }</a>
<a name="2589"><span class="lineNum">    2589 </span>                :            :         }</a>
<a name="2590"><span class="lineNum">    2590 </span>                :            : </a>
<a name="2591"><span class="lineNum">    2591 </span>        [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 17379 times"> + </span>]:<span class="lineCov">      17388 :         if (seccomp_filtering) {</span></a>
<a name="2592"><span class="lineNum">    2592 </span>  [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 1 time"> + </span> :<span class="lineCov">          9 :                 if (nprocs && (!argc || debug_flag))</span></a>
<span class="lineNum">         </span>         <span class="branchNoCov" title="Branch 4 was not taken"> - </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span>]
<a name="2593"><span class="lineNum">    2593 </span>                :<span class="lineCov">          1 :                         error_msg("--seccomp-bpf is not enabled for processes"</span></a>
<a name="2594"><span class="lineNum">    2594 </span>                :            :                                   " attached with -p");</a>
<a name="2595"><span class="lineNum">    2595 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 8 times"> + </span>]:<span class="lineCov">          9 :                 if (!followfork) {</span></a>
<a name="2596"><span class="lineNum">    2596 </span>                :<span class="lineCov">          1 :                         error_msg("--seccomp-bpf cannot be used without "</span></a>
<a name="2597"><span class="lineNum">    2597 </span>                :            :                                   "-f/--follow-forks, disabling");</a>
<a name="2598"><span class="lineNum">    2598 </span>                :<span class="lineCov">          1 :                         seccomp_filtering = false;</span></a>
<a name="2599"><span class="lineNum">    2599 </span>                :            :                 }</a>
<a name="2600"><span class="lineNum">    2600 </span>                :            :         }</a>
<a name="2601"><span class="lineNum">    2601 </span>                :            : </a>
<a name="2602"><span class="lineNum">    2602 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 17385 times"> + </span>]:<span class="lineCov">      17388 :         if (optF) {</span></a>
<a name="2603"><span class="lineNum">    2603 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          3 :                 if (followfork) {</span></a>
<a name="2604"><span class="lineNum">    2604 </span>                :<span class="lineCov">          1 :                         error_msg("deprecated option -F ignored");</span></a>
<a name="2605"><span class="lineNum">    2605 </span>                :            :                 } else {</a>
<a name="2606"><span class="lineNum">    2606 </span>                :<span class="lineCov">          2 :                         error_msg("option -F is deprecated, "</span></a>
<a name="2607"><span class="lineNum">    2607 </span>                :            :                                   "please use -f/--follow-forks instead");</a>
<a name="2608"><span class="lineNum">    2608 </span>                :<span class="lineCov">          2 :                         followfork = true;</span></a>
<a name="2609"><span class="lineNum">    2609 </span>                :            :                 }</a>
<a name="2610"><span class="lineNum">    2610 </span>                :            :         }</a>
<a name="2611"><span class="lineNum">    2611 </span>                :            : </a>
<a name="2612"><span class="lineNum">    2612 </span>  [<span class="branchCov" title="Branch 0 was taken 2418 times"> + </span><span class="branchCov" title="Branch 1 was taken 14970 times"> + </span><span class="branchCov" title="Branch 2 was taken 4 times"> + </span><span class="branchCov" title="Branch 3 was taken 2414 times"> + </span>]:<span class="lineCov">      17388 :         if (output_separately && cflag) {</span></a>
<a name="2613"><span class="lineNum">    2613 </span>                :<span class="lineCov">          4 :                 error_msg_and_help("(-c/--summary-only or -C/--summary) and"</span></a>
<a name="2614"><span class="lineNum">    2614 </span>                :            :                                    " -ff/--output-separately"</a>
<a name="2615"><span class="lineNum">    2615 </span>                :            :                                    " are mutually exclusive");</a>
<a name="2616"><span class="lineNum">    2616 </span>                :            :         }</a>
<a name="2617"><span class="lineNum">    2617 </span>                :            : </a>
<a name="2618"><span class="lineNum">    2618 </span>  [<span class="branchCov" title="Branch 0 was taken 34 times"> + </span><span class="branchCov" title="Branch 1 was taken 17350 times"> + </span><span class="branchCov" title="Branch 2 was taken 7 times"> + </span><span class="branchCov" title="Branch 3 was taken 27 times"> + </span>]:<span class="lineCov">      17384 :         if (count_wallclock && !cflag) {</span></a>
<a name="2619"><span class="lineNum">    2619 </span>                :<span class="lineCov">          7 :                 error_msg_and_help("-w/--summary-wall-clock must be given with"</span></a>
<a name="2620"><span class="lineNum">    2620 </span>                :            :                                    " (-c/--summary-only or -C/--summary)");</a>
<a name="2621"><span class="lineNum">    2621 </span>                :            :         }</a>
<a name="2622"><span class="lineNum">    2622 </span>                :            : </a>
<a name="2623"><span class="lineNum">    2623 </span>  [<span class="branchCov" title="Branch 0 was taken 6 times"> + </span><span class="branchCov" title="Branch 1 was taken 17371 times"> + </span><span class="branchCov" title="Branch 2 was taken 2 times"> + </span><span class="branchCov" title="Branch 3 was taken 4 times"> + </span>]:<span class="lineCov">      17377 :         if (columns_set && !cflag) {</span></a>
<a name="2624"><span class="lineNum">    2624 </span>                :<span class="lineCov">          2 :                 error_msg_and_help("-U/--summary-columns must be given with"</span></a>
<a name="2625"><span class="lineNum">    2625 </span>                :            :                                    " (-c/--summary-only or -C/--summary)");</a>
<a name="2626"><span class="lineNum">    2626 </span>                :            :         }</a>
<a name="2627"><span class="lineNum">    2627 </span>                :            : </a>
<a name="2628"><span class="lineNum">    2628 </span>  [<span class="branchCov" title="Branch 0 was taken 17 times"> + </span><span class="branchCov" title="Branch 1 was taken 17358 times"> + </span><span class="branchCov" title="Branch 2 was taken 1 time"> + </span><span class="branchCov" title="Branch 3 was taken 16 times"> + </span>]:<span class="lineCov">      17375 :         if (sortby_set && !cflag) {</span></a>
<a name="2629"><span class="lineNum">    2629 </span>                :<span class="lineCov">          1 :                 error_msg("-S/--summary-sort-by has no effect without"</span></a>
<a name="2630"><span class="lineNum">    2630 </span>                :            :                           " (-c/--summary-only or -C/--summary)");</a>
<a name="2631"><span class="lineNum">    2631 </span>                :            :         }</a>
<a name="2632"><span class="lineNum">    2632 </span>                :            : </a>
<a name="2633"><span class="lineNum">    2633 </span>        [<span class="branchCov" title="Branch 0 was taken 43 times"> + </span><span class="branchCov" title="Branch 1 was taken 17332 times"> + </span>]:<span class="lineCov">      17375 :         if (cflag == CFLAG_ONLY_STATS) {</span></a>
<a name="2634"><span class="lineNum">    2634 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 40 times"> + </span>]:<span class="lineCov">         43 :                 if (iflag)</span></a>
<a name="2635"><span class="lineNum">    2635 </span>                :<span class="lineCov">          3 :                         error_msg("-i/--instruction-pointer has no effect "</span></a>
<a name="2636"><span class="lineNum">    2636 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2637"><span class="lineNum">    2637 </span>                :<span class="lineCov">         43 :                 if (stack_trace_enabled)</span></a>
<a name="2638"><span class="lineNum">    2638 </span>                :            :                         error_msg("-k/--stack-traces has no effect "</a>
<a name="2639"><span class="lineNum">    2639 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2640"><span class="lineNum">    2640 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 40 times"> + </span>]:<span class="lineCov">         43 :                 if (nflag)</span></a>
<a name="2641"><span class="lineNum">    2641 </span>                :<span class="lineCov">          3 :                         error_msg("-n/--syscall-number has no effect "</span></a>
<a name="2642"><span class="lineNum">    2642 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2643"><span class="lineNum">    2643 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 41 times"> + </span>]:<span class="lineCov">         43 :                 if (rflag)</span></a>
<a name="2644"><span class="lineNum">    2644 </span>                :<span class="lineCov">          2 :                         error_msg("-r/--relative-timestamps has no effect "</span></a>
<a name="2645"><span class="lineNum">    2645 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2646"><span class="lineNum">    2646 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 41 times"> + </span>]:<span class="lineCov">         43 :                 if (tflag_format)</span></a>
<a name="2647"><span class="lineNum">    2647 </span>                :<span class="lineCov">          2 :                         error_msg("-t/--absolute-timestamps has no effect "</span></a>
<a name="2648"><span class="lineNum">    2648 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2649"><span class="lineNum">    2649 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 41 times"> + </span>]:<span class="lineCov">         43 :                 if (Tflag)</span></a>
<a name="2650"><span class="lineNum">    2650 </span>                :<span class="lineCov">          2 :                         error_msg("-T/--syscall-times has no effect "</span></a>
<a name="2651"><span class="lineNum">    2651 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2652"><span class="lineNum">    2652 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 41 times"> + </span>]:<span class="lineCov">         43 :                 if (!number_set_array_is_empty(decode_fd_set, 0))</span></a>
<a name="2653"><span class="lineNum">    2653 </span>                :<span class="lineCov">          2 :                         error_msg("-y/--decode-fds has no effect "</span></a>
<a name="2654"><span class="lineNum">    2654 </span>                :            :                                   "with -c/--summary-only");</a>
<a name="2655"><span class="lineNum">    2655 </span>                :            : #ifdef ENABLE_SECONTEXT</a>
<a name="2656"><span class="lineNum">    2656 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 42 times"> + </span>]:<span class="lineCov">         43 :                 if (!number_set_array_is_empty(secontext_set, 0))</span></a>
<a name="2657"><span class="lineNum">    2657 </span>                :<span class="lineCov">          1 :                         error_msg("--secontext has no effect with "</span></a>
<a name="2658"><span class="lineNum">    2658 </span>                :            :                                   "-c/--summary-only");</a>
<a name="2659"><span class="lineNum">    2659 </span>                :            : #endif</a>
<a name="2660"><span class="lineNum">    2660 </span>                :            :         }</a>
<a name="2661"><span class="lineNum">    2661 </span>                :            : </a>
<a name="2662"><span class="lineNum">    2662 </span>        [<span class="branchCov" title="Branch 0 was taken 50 times"> + </span><span class="branchCov" title="Branch 1 was taken 17325 times"> + </span>]:<span class="lineCov">      17375 :         if (!outfname) {</span></a>
<a name="2663"><span class="lineNum">    2663 </span>  [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 46 times"> + </span><span class="branchCov" title="Branch 2 was taken 2 times"> + </span><span class="branchCov" title="Branch 3 was taken 2 times"> + </span>]:<span class="lineCov">         50 :                 if (output_separately && !followfork)</span></a>
<a name="2664"><span class="lineNum">    2664 </span>                :<span class="lineCov">          2 :                         error_msg("--output-separately has no effect "</span></a>
<a name="2665"><span class="lineNum">    2665 </span>                :            :                                   "without -o/--output");</a>
<a name="2666"><span class="lineNum">    2666 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 48 times"> + </span>]:<span class="lineCov">         50 :                 if (open_append)</span></a>
<a name="2667"><span class="lineNum">    2667 </span>                :<span class="lineCov">          2 :                         error_msg("-A/--output-append-mode has no effect "</span></a>
<a name="2668"><span class="lineNum">    2668 </span>                :            :                                   "without -o/--output");</a>
<a name="2669"><span class="lineNum">    2669 </span>                :            :         }</a>
<a name="2670"><span class="lineNum">    2670 </span>                :            : </a>
<a name="2671"><span class="lineNum">    2671 </span>                :            : #ifndef HAVE_OPEN_MEMSTREAM</a>
<a name="2672"><span class="lineNum">    2672 </span>                :            :         if (!is_complete_set(status_set, NUMBER_OF_STATUSES))</a>
<a name="2673"><span class="lineNum">    2673 </span>                :            :                 error_msg_and_help("open_memstream is required to use -z, -Z, or -e status");</a>
<a name="2674"><span class="lineNum">    2674 </span>                :            : #endif</a>
<a name="2675"><span class="lineNum">    2675 </span>                :            : </a>
<a name="2676"><span class="lineNum">    2676 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 17371 times"> + </span>]:<span class="lineCov">      17375 :         if (zflags > 1)</span></a>
<a name="2677"><span class="lineNum">    2677 </span>                :<span class="lineCov">          4 :                 error_msg("Only the last of "</span></a>
<a name="2678"><span class="lineNum">    2678 </span>                :            :                           "-z/--successful-only/-Z/--failed-only options will "</a>
<a name="2679"><span class="lineNum">    2679 </span>                :            :                           "take effect. "</a>
<a name="2680"><span class="lineNum">    2680 </span>                :            :                           "See status qualifier for more complex filters.");</a>
<a name="2681"><span class="lineNum">    2681 </span>                :            : </a>
<a name="2682"><span class="lineNum">    2682 </span>        [<span class="branchCov" title="Branch 0 was taken 5432 times"> + </span><span class="branchCov" title="Branch 1 was taken 17375 times"> + </span>]:<span class="lineCov">      22807 :         for (size_t cnt = 0; cnt < pathtrace_count; ++cnt)</span></a>
<a name="2683"><span class="lineNum">    2683 </span>                :<span class="lineCov">       5432 :                 pathtrace_select(pathtrace_paths[cnt]);</span></a>
<a name="2684"><span class="lineNum">    2684 </span>                :<span class="lineCov">      17375 :         free(pathtrace_paths);</span></a>
<a name="2685"><span class="lineNum">    2685 </span>                :            : </a>
<a name="2686"><span class="lineNum">    2686 </span>                :<span class="lineCov">      17375 :         acolumn_spaces = xmalloc(acolumn + 1);</span></a>
<a name="2687"><span class="lineNum">    2687 </span>                :<span class="lineCov">      17375 :         memset(acolumn_spaces, ' ', acolumn);</span></a>
<a name="2688"><span class="lineNum">    2688 </span>                :<span class="lineCov">      17375 :         acolumn_spaces[acolumn] = '\0';</span></a>
<a name="2689"><span class="lineNum">    2689 </span>                :            : </a>
<a name="2690"><span class="lineNum">    2690 </span>                :<span class="lineCov">      17375 :         set_sighandler(SIGCHLD, SIG_DFL, &params_for_tracee.child_sa);</span></a>
<a name="2691"><span class="lineNum">    2691 </span>                :            : </a>
<a name="2692"><span class="lineNum">    2692 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="2693"><span class="lineNum">    2693 </span>                :            :         if (stack_trace_enabled)</a>
<a name="2694"><span class="lineNum">    2694 </span>                :            :                 unwind_init();</a>
<a name="2695"><span class="lineNum">    2695 </span>                :            : #endif</a>
<a name="2696"><span class="lineNum">    2696 </span>                :            : </a>
<a name="2697"><span class="lineNum">    2697 </span>                :            :         /* See if they want to run as another user. */</a>
<a name="2698"><span class="lineNum">    2698 </span>        [<span class="branchCov" title="Branch 0 was taken 20 times"> + </span><span class="branchCov" title="Branch 1 was taken 17355 times"> + </span>]:<span class="lineCov">      17375 :         if (username != NULL) {</span></a>
<a name="2699"><span class="lineNum">    2699 </span>                :<span class="lineCov">         20 :                 struct passwd *pent;</span></a>
<a name="2700"><span class="lineNum">    2700 </span>                :            : </a>
<a name="2701"><span class="lineNum">    2701 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 20 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">         20 :                 if (getuid() != 0 || geteuid() != 0) {</span></a>
<a name="2702"><span class="lineNum">    2702 </span>                :<span class="lineCov">         20 :                         error_msg_and_die("You must be root to use "</span></a>
<a name="2703"><span class="lineNum">    2703 </span>                :            :                                           "the -u/--username option");</a>
<a name="2704"><span class="lineNum">    2704 </span>                :            :                 }</a>
<a name="2705"><span class="lineNum">    2705 </span>                :<span class="lineNoCov">          0 :                 pent = getpwnam(username);</span></a>
<a name="2706"><span class="lineNum">    2706 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (pent == NULL) {</span></a>
<a name="2707"><span class="lineNum">    2707 </span>                :<span class="lineNoCov">          0 :                         error_msg_and_die("Cannot find user '%s'", username);</span></a>
<a name="2708"><span class="lineNum">    2708 </span>                :            :                 }</a>
<a name="2709"><span class="lineNum">    2709 </span>                :<span class="lineNoCov">          0 :                 run_uid = pent->pw_uid;</span></a>
<a name="2710"><span class="lineNum">    2710 </span>                :<span class="lineNoCov">          0 :                 run_gid = pent->pw_gid;</span></a>
<a name="2711"><span class="lineNum">    2711 </span>                :            :         } else {</a>
<a name="2712"><span class="lineNum">    2712 </span>                :<span class="lineCov">      17355 :                 run_uid = getuid();</span></a>
<a name="2713"><span class="lineNum">    2713 </span>                :<span class="lineCov">      17355 :                 run_gid = getgid();</span></a>
<a name="2714"><span class="lineNum">    2714 </span>                :            :         }</a>
<a name="2715"><span class="lineNum">    2715 </span>                :            : </a>
<a name="2716"><span class="lineNum">    2716 </span>        [<span class="branchCov" title="Branch 0 was taken 2601 times"> + </span><span class="branchCov" title="Branch 1 was taken 14754 times"> + </span>]:<span class="lineCov">      17355 :         if (followfork)</span></a>
<a name="2717"><span class="lineNum">    2717 </span>                :<span class="lineCov">       2601 :                 ptrace_setoptions |= PTRACE_O_TRACECLONE |</span></a>
<a name="2718"><span class="lineNum">    2718 </span>                :            :                                      PTRACE_O_TRACEFORK |</a>
<a name="2719"><span class="lineNum">    2719 </span>                :            :                                      PTRACE_O_TRACEVFORK;</a>
<a name="2720"><span class="lineNum">    2720 </span>                :            : </a>
<a name="2721"><span class="lineNum">    2721 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 17348 times"> + </span>]:<span class="lineCov">      17355 :         if (seccomp_filtering)</span></a>
<a name="2722"><span class="lineNum">    2722 </span>                :<span class="lineCov">          7 :                 check_seccomp_filter();</span></a>
<a name="2723"><span class="lineNum">    2723 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 17348 times"> + </span>]:<span class="lineCov">      17355 :         if (seccomp_filtering)</span></a>
<a name="2724"><span class="lineNum">    2724 </span>                :<span class="lineCov">          7 :                 ptrace_setoptions |= PTRACE_O_TRACESECCOMP;</span></a>
<a name="2725"><span class="lineNum">    2725 </span>                :            : </a>
<a name="2726"><span class="lineNum">    2726 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 17343 times"> + </span>]:<span class="lineCov">      17355 :         debug_msg("ptrace_setoptions = %#x", ptrace_setoptions);</span></a>
<a name="2727"><span class="lineNum">    2727 </span>                :<span class="lineCov">      17355 :         test_ptrace_seize();</span></a>
<a name="2728"><span class="lineNum">    2728 </span>                :<span class="lineCov">      17355 :         test_ptrace_get_syscall_info();</span></a>
<a name="2729"><span class="lineNum">    2729 </span>                :            : </a>
<a name="2730"><span class="lineNum">    2730 </span>                :            :         /*</a>
<a name="2731"><span class="lineNum">    2731 </span>                :            :          * Is something weird with our stdin and/or stdout -</a>
<a name="2732"><span class="lineNum">    2732 </span>                :            :          * for example, may they be not open? In this case,</a>
<a name="2733"><span class="lineNum">    2733 </span>                :            :          * ensure that none of the future opens uses them.</a>
<a name="2734"><span class="lineNum">    2734 </span>                :            :          *</a>
<a name="2735"><span class="lineNum">    2735 </span>                :            :          * This was seen in the wild when /proc/sys/kernel/core_pattern</a>
<a name="2736"><span class="lineNum">    2736 </span>                :            :          * was set to "|/bin/strace -o/tmp/LOG PROG":</a>
<a name="2737"><span class="lineNum">    2737 </span>                :            :          * kernel runs coredump helper with fd#0 open but fd#1 closed (!),</a>
<a name="2738"><span class="lineNum">    2738 </span>                :            :          * therefore LOG gets opened to fd#1, and fd#1 is closed by</a>
<a name="2739"><span class="lineNum">    2739 </span>                :            :          * "don't hold up stdin/out open" code soon after.</a>
<a name="2740"><span class="lineNum">    2740 </span>                :            :          */</a>
<a name="2741"><span class="lineNum">    2741 </span>                :<span class="lineCov">      17355 :         ensure_standard_fds_opened();</span></a>
<a name="2742"><span class="lineNum">    2742 </span>                :            : </a>
<a name="2743"><span class="lineNum">    2743 </span>                :            :         /* Check if they want to redirect the output. */</a>
<a name="2744"><span class="lineNum">    2744 </span>        [<span class="branchCov" title="Branch 0 was taken 17325 times"> + </span><span class="branchCov" title="Branch 1 was taken 30 times"> + </span>]:<span class="lineCov">      17355 :         if (outfname) {</span></a>
<a name="2745"><span class="lineNum">    2745 </span>                :            :                 /* See if they want to pipe the output. */</a>
<a name="2746"><span class="lineNum">    2746 </span>        [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 17316 times"> + </span>]:<span class="lineCov">      17325 :                 if (outfname[0] == '|' || outfname[0] == '!') {</span></a>
<a name="2747"><span class="lineNum">    2747 </span>                :            :                         /*</a>
<a name="2748"><span class="lineNum">    2748 </span>                :            :                          * We can't do the <outfname>.PID funny business</a>
<a name="2749"><span class="lineNum">    2749 </span>                :            :                          * when using popen, so prohibit it.</a>
<a name="2750"><span class="lineNum">    2750 </span>                :            :                          */</a>
<a name="2751"><span class="lineNum">    2751 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          9 :                         if (output_separately)</span></a>
<a name="2752"><span class="lineNum">    2752 </span>                :<span class="lineCov">          4 :                                 error_msg_and_help("piping the output and "</span></a>
<a name="2753"><span class="lineNum">    2753 </span>                :            :                                                    "-ff/--output-separately "</a>
<a name="2754"><span class="lineNum">    2754 </span>                :            :                                                    "are mutually exclusive");</a>
<a name="2755"><span class="lineNum">    2755 </span>                :<span class="lineCov">          5 :                         shared_log = strace_popen(outfname + 1);</span></a>
<a name="2756"><span class="lineNum">    2756 </span>        [<span class="branchCov" title="Branch 0 was taken 14910 times"> + </span><span class="branchCov" title="Branch 1 was taken 2406 times"> + </span>]:<span class="lineCov">      17316 :                 } else if (!output_separately) {</span></a>
<a name="2757"><span class="lineNum">    2757 </span>                :<span class="lineCov">      14910 :                         shared_log = strace_fopen(outfname);</span></a>
<a name="2758"><span class="lineNum">    2758 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2404 times"> + </span>]:<span class="lineCov">       2406 :                 } else if (strlen(outfname) >= PATH_MAX - sizeof(int) * 3) {</span></a>
<a name="2759"><span class="lineNum">    2759 </span>                :<span class="lineCov">          2 :                         errno = ENAMETOOLONG;</span></a>
<a name="2760"><span class="lineNum">    2760 </span>                :<span class="lineCov">          2 :                         perror_msg_and_die("%s", outfname);</span></a>
<a name="2761"><span class="lineNum">    2761 </span>                :            :                 }</a>
<a name="2762"><span class="lineNum">    2762 </span>                :            :         } else {</a>
<a name="2763"><span class="lineNum">    2763 </span>                :            :                 /* -ff without -o FILE is the same as single -f */</a>
<a name="2764"><span class="lineNum">    2764 </span>                :<span class="lineCov">         30 :                 output_separately = false;</span></a>
<a name="2765"><span class="lineNum">    2765 </span>                :            :         }</a>
<a name="2766"><span class="lineNum">    2766 </span>                :            : </a>
<a name="2767"><span class="lineNum">    2767 </span>  [<span class="branchCov" title="Branch 0 was taken 17314 times"> + </span><span class="branchCov" title="Branch 1 was taken 30 times"> + </span><span class="branchCov" title="Branch 2 was taken 17314 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span> :<span class="lineCov">      17344 :         if (!outfname || outfname[0] == '|' || outfname[0] == '!') {</span></a>
<span class="lineNum">         </span>         <span class="branchNoCov" title="Branch 4 was not taken"> - </span><span class="branchCov" title="Branch 5 was taken 17314 times"> + </span>]
<a name="2768"><span class="lineNum">    2768 </span>                :<span class="lineCov">         30 :                 setvbuf(shared_log, NULL, _IOLBF, 0);</span></a>
<a name="2769"><span class="lineNum">    2769 </span>                :            :         }</a>
<a name="2770"><span class="lineNum">    2770 </span>                :            : </a>
<a name="2771"><span class="lineNum">    2771 </span>                :            :         /*</a>
<a name="2772"><span class="lineNum">    2772 </span>                :            :          * argv[0]      -pPID   -oFILE  Default interactive setting</a>
<a name="2773"><span class="lineNum">    2773 </span>                :            :          * yes          *       0       INTR_WHILE_WAIT</a>
<a name="2774"><span class="lineNum">    2774 </span>                :            :          * no           1       0       INTR_WHILE_WAIT</a>
<a name="2775"><span class="lineNum">    2775 </span>                :            :          * yes          *       1       INTR_NEVER</a>
<a name="2776"><span class="lineNum">    2776 </span>                :            :          * no           1       1       INTR_WHILE_WAIT</a>
<a name="2777"><span class="lineNum">    2777 </span>                :            :          */</a>
<a name="2778"><span class="lineNum">    2778 </span>                :            : </a>
<a name="2779"><span class="lineNum">    2779 </span>  [<span class="branchCov" title="Branch 0 was taken 9 times"> + </span><span class="branchCov" title="Branch 1 was taken 17335 times"> + </span><span class="branchCov" title="Branch 2 was taken 6 times"> + </span><span class="branchCov" title="Branch 3 was taken 3 times"> + </span>]:<span class="lineCov">      17344 :         if (daemonized_tracer && !opt_intr)</span></a>
<a name="2780"><span class="lineNum">    2780 </span>                :<span class="lineCov">          6 :                 opt_intr = INTR_BLOCK_TSTP_TOO;</span></a>
<a name="2781"><span class="lineNum">    2781 </span>  [<span class="branchCov" title="Branch 0 was taken 17314 times"> + </span><span class="branchCov" title="Branch 1 was taken 30 times"> + </span><span class="branchCov" title="Branch 2 was taken 17311 times"> + </span><span class="branchCov" title="Branch 3 was taken 3 times"> + </span>]:<span class="lineCov">      17344 :         if (outfname && argc) {</span></a>
<a name="2782"><span class="lineNum">    2782 </span>        [<span class="branchCov" title="Branch 0 was taken 16823 times"> + </span><span class="branchCov" title="Branch 1 was taken 488 times"> + </span>]:<span class="lineCov">      17311 :                 if (!opt_intr)</span></a>
<a name="2783"><span class="lineNum">    2783 </span>                :<span class="lineCov">      16823 :                         opt_intr = INTR_NEVER;</span></a>
<a name="2784"><span class="lineNum">    2784 </span>  [<span class="branchCov" title="Branch 0 was taken 4650 times"> + </span><span class="branchCov" title="Branch 1 was taken 12661 times"> + </span><span class="branchCov" title="Branch 2 was taken 4637 times"> + </span><span class="branchCov" title="Branch 3 was taken 13 times"> + </span>]:<span class="lineCov">      17311 :                 if (!qflag_short && !quiet_set_updated)</span></a>
<a name="2785"><span class="lineNum">    2785 </span>                :<span class="lineCov">       4637 :                         qflag_short = 1;</span></a>
<a name="2786"><span class="lineNum">    2786 </span>                :            :         }</a>
<a name="2787"><span class="lineNum">    2787 </span>        [<span class="branchCov" title="Branch 0 was taken 33 times"> + </span><span class="branchCov" title="Branch 1 was taken 17311 times"> + </span>]:<span class="lineCov">      17344 :         if (!opt_intr)</span></a>
<a name="2788"><span class="lineNum">    2788 </span>                :<span class="lineCov">         33 :                 opt_intr = INTR_WHILE_WAIT;</span></a>
<a name="2789"><span class="lineNum">    2789 </span>                :            : </a>
<a name="2790"><span class="lineNum">    2790 </span>        [<span class="branchCov" title="Branch 0 was taken 17304 times"> + </span><span class="branchCov" title="Branch 1 was taken 40 times"> + </span>]:<span class="lineCov">      17344 :         if (qflag_short) {</span></a>
<a name="2791"><span class="lineNum">    2791 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 17300 times"> + </span>]:<span class="lineCov">      17304 :                 if (quiet_set_updated) {</span></a>
<a name="2792"><span class="lineNum">    2792 </span>                :<span class="lineCov">          4 :                         error_msg_and_die("-q and -e quiet/--quiet cannot"</span></a>
<a name="2793"><span class="lineNum">    2793 </span>                :            :                                           " be provided simultaneously");</a>
<a name="2794"><span class="lineNum">    2794 </span>                :            :                 }</a>
<a name="2795"><span class="lineNum">    2795 </span>                :            : </a>
<a name="2796"><span class="lineNum">    2796 </span>        [<span class="branchCov" title="Branch 0 was taken 12655 times"> + </span><span class="branchCov" title="Branch 1 was taken 4645 times"> + </span>]:<span class="lineCov">      29955 :                 qualify_quiet(qflag_short == 1 ? qflag_qual :</span></a>
<a name="2797"><span class="lineNum">    2797 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 12653 times"> + </span>]:<span class="lineCov">      12655 :                               qflag_short == 2 ? qqflag_qual : qqqflag_qual);</span></a>
<a name="2798"><span class="lineNum">    2798 </span>                :            :         }</a>
<a name="2799"><span class="lineNum">    2799 </span>                :            : </a>
<a name="2800"><span class="lineNum">    2800 </span>                :            :         /*</a>
<a name="2801"><span class="lineNum">    2801 </span>                :            :          * startup_child() must be called before the signal handlers get</a>
<a name="2802"><span class="lineNum">    2802 </span>                :            :          * installed below as they are inherited into the spawned process.</a>
<a name="2803"><span class="lineNum">    2803 </span>                :            :          * Also we do not need to be protected by them as during interruption</a>
<a name="2804"><span class="lineNum">    2804 </span>                :            :          * in the startup_child() mode we kill the spawned process anyway.</a>
<a name="2805"><span class="lineNum">    2805 </span>                :            :          */</a>
<a name="2806"><span class="lineNum">    2806 </span>        [<span class="branchCov" title="Branch 0 was taken 17333 times"> + </span><span class="branchCov" title="Branch 1 was taken 7 times"> + </span>]:<span class="lineCov">      17340 :         if (argc) {</span></a>
<a name="2807"><span class="lineNum">    2807 </span>                :<span class="lineCov">      17333 :                 char **new_environ = make_env(environ, env_changes,</span></a>
<a name="2808"><span class="lineNum">    2808 </span>                :            :                                               env_change_count);</a>
<a name="2809"><span class="lineNum">    2809 </span>                :<span class="lineCov">      17333 :                 free(env_changes);</span></a>
<a name="2810"><span class="lineNum">    2810 </span>                :            : </a>
<a name="2811"><span class="lineNum">    2811 </span>                :<span class="lineCov">      17333 :                 startup_child(argv, new_environ);</span></a>
<a name="2812"><span class="lineNum">    2812 </span>                :            : </a>
<a name="2813"><span class="lineNum">    2813 </span>                :            :                 /*</a>
<a name="2814"><span class="lineNum">    2814 </span>                :            :                  * On a NOMMU system, new_environ can be freed only after exec</a>
<a name="2815"><span class="lineNum">    2815 </span>                :            :                  * in child, so we leak it in that case, similar to pathname</a>
<a name="2816"><span class="lineNum">    2816 </span>                :            :                  * in startup_child().</a>
<a name="2817"><span class="lineNum">    2817 </span>                :            :                  */</a>
<a name="2818"><span class="lineNum">    2818 </span>        [<span class="branchCov" title="Branch 0 was taken 5 times"> + </span><span class="branchCov" title="Branch 1 was taken 17318 times"> + </span>]:<span class="lineCov">      17323 :                 if (new_environ != environ && !NOMMU_SYSTEM)</span></a>
<a name="2819"><span class="lineNum">    2819 </span>                :<span class="lineCov">          5 :                         free(new_environ);</span></a>
<a name="2820"><span class="lineNum">    2820 </span>                :            :         }</a>
<a name="2821"><span class="lineNum">    2821 </span>                :            : </a>
<a name="2822"><span class="lineNum">    2822 </span>                :<span class="lineCov">      17330 :         set_sighandler(SIGTTOU, SIG_IGN, NULL);</span></a>
<a name="2823"><span class="lineNum">    2823 </span>                :<span class="lineCov">      17330 :         set_sighandler(SIGTTIN, SIG_IGN, NULL);</span></a>
<a name="2824"><span class="lineNum">    2824 </span>        [<span class="branchCov" title="Branch 0 was taken 17212 times"> + </span><span class="branchCov" title="Branch 1 was taken 118 times"> + </span>]:<span class="lineCov">      17330 :         if (opt_intr != INTR_ANYWHERE) {</span></a>
<a name="2825"><span class="lineNum">    2825 </span>        [<span class="branchCov" title="Branch 0 was taken 118 times"> + </span><span class="branchCov" title="Branch 1 was taken 17094 times"> + </span>]:<span class="lineCov">      17212 :                 if (opt_intr == INTR_BLOCK_TSTP_TOO)</span></a>
<a name="2826"><span class="lineNum">    2826 </span>                :<span class="lineCov">        118 :                         set_sighandler(SIGTSTP, SIG_IGN, NULL);</span></a>
<a name="2827"><span class="lineNum">    2827 </span>                :            :                 /*</a>
<a name="2828"><span class="lineNum">    2828 </span>                :            :                  * In interactive mode (if no -o OUTFILE, or -p PID is used),</a>
<a name="2829"><span class="lineNum">    2829 </span>                :            :                  * fatal signals are handled asynchronously and acted</a>
<a name="2830"><span class="lineNum">    2830 </span>                :            :                  * when waiting for process state changes.</a>
<a name="2831"><span class="lineNum">    2831 </span>                :            :                  * In non-interactive mode these signals are ignored.</a>
<a name="2832"><span class="lineNum">    2832 </span>                :            :                  */</a>
<a name="2833"><span class="lineNum">    2833 </span>        [<span class="branchCov" title="Branch 0 was taken 17059 times"> + </span><span class="branchCov" title="Branch 1 was taken 153 times"> + </span>]:<span class="lineCov">      34271 :                 set_sighandler(SIGHUP, interactive ? interrupt : SIG_IGN, NULL);</span></a>
<a name="2834"><span class="lineNum">    2834 </span>        [<span class="branchCov" title="Branch 0 was taken 17059 times"> + </span><span class="branchCov" title="Branch 1 was taken 153 times"> + </span>]:<span class="lineCov">      34271 :                 set_sighandler(SIGINT, interactive ? interrupt : SIG_IGN, NULL);</span></a>
<a name="2835"><span class="lineNum">    2835 </span>        [<span class="branchCov" title="Branch 0 was taken 17059 times"> + </span><span class="branchCov" title="Branch 1 was taken 153 times"> + </span>]:<span class="lineCov">      34271 :                 set_sighandler(SIGQUIT, interactive ? interrupt : SIG_IGN, NULL);</span></a>
<a name="2836"><span class="lineNum">    2836 </span>        [<span class="branchCov" title="Branch 0 was taken 17059 times"> + </span><span class="branchCov" title="Branch 1 was taken 153 times"> + </span>]:<span class="lineCov">      34271 :                 set_sighandler(SIGPIPE, interactive ? interrupt : SIG_IGN, NULL);</span></a>
<a name="2837"><span class="lineNum">    2837 </span>        [<span class="branchCov" title="Branch 0 was taken 17059 times"> + </span><span class="branchCov" title="Branch 1 was taken 153 times"> + </span>]:<span class="lineCov">      34271 :                 set_sighandler(SIGTERM, interactive ? interrupt : SIG_IGN, NULL);</span></a>
<a name="2838"><span class="lineNum">    2838 </span>                :            :         }</a>
<a name="2839"><span class="lineNum">    2839 </span>                :            : </a>
<a name="2840"><span class="lineNum">    2840 </span>                :<span class="lineCov">      17330 :         sigemptyset(&timer_set);</span></a>
<a name="2841"><span class="lineNum">    2841 </span>                :<span class="lineCov">      17330 :         sigaddset(&timer_set, SIGALRM);</span></a>
<a name="2842"><span class="lineNum">    2842 </span>                :<span class="lineCov">      17330 :         sigprocmask(SIG_BLOCK, &timer_set, NULL);</span></a>
<a name="2843"><span class="lineNum">    2843 </span>                :<span class="lineCov">      17330 :         set_sighandler(SIGALRM, timer_sighandler, NULL);</span></a>
<a name="2844"><span class="lineNum">    2844 </span>                :            : </a>
<a name="2845"><span class="lineNum">    2845 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17330 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">      17330 :         if (nprocs != 0 || daemonized_tracer)</span></a>
<a name="2846"><span class="lineNum">    2846 </span>                :<span class="lineCov">      17330 :                 startup_attach();</span></a>
<a name="2847"><span class="lineNum">    2847 </span>                :            : </a>
<a name="2848"><span class="lineNum">    2848 </span>                :            :         /* Do we want pids printed in our -o OUTFILE?</a>
<a name="2849"><span class="lineNum">    2849 </span>                :            :          * -ff: no (every pid has its own file); or</a>
<a name="2850"><span class="lineNum">    2850 </span>                :            :          * -f: yes (there can be more pids in the future); or</a>
<a name="2851"><span class="lineNum">    2851 </span>                :            :          * -p PID1,PID2: yes (there are already more than one pid)</a>
<a name="2852"><span class="lineNum">    2852 </span>                :            :          */</a>
<a name="2853"><span class="lineNum">    2853 </span>  [<span class="branchCov" title="Branch 0 was taken 17313 times"> + </span><span class="branchCov" title="Branch 1 was taken 25 times"> + </span><span class="branchCov" title="Branch 2 was taken 14909 times"> + </span><span class="branchCov" title="Branch 3 was taken 2404 times"> + </span>]:<span class="lineCov">      17338 :         print_pid_pfx = outfname && !output_separately &&</span></a>
<a name="2854"><span class="lineNum">    2854 </span>  [<span class="branchCov" title="Branch 0 was taken 14721 times"> + </span><span class="branchCov" title="Branch 1 was taken 188 times"> + </span><span class="branchCov" title="Branch 2 was taken 14719 times"> + </span><span class="branchCov" title="Branch 3 was taken 2 times"> + </span>]:<span class="lineCov">      14909 :                 ((followfork && !output_separately) || nprocs > 1);</span></a>
<a name="2855"><span class="lineNum">    2855 </span>                :<span class="lineCov">      17338 : }</span></a>
<a name="2856"><span class="lineNum">    2856 </span>                :            : </a>
<a name="2857"><span class="lineNum">    2857 </span>                :            : static struct tcb *</a>
<a name="2858"><span class="lineNum">    2858 </span>                :<span class="lineCov">  176338126 : pid2tcb(const int pid)</span></a>
<a name="2859"><span class="lineNum">    2859 </span>                :            : {</a>
<a name="2860"><span class="lineNum">    2860 </span>        [<span class="branchCov" title="Branch 0 was taken 176338126 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">  176338126 :         if (pid <= 0)</span></a>
<a name="2861"><span class="lineNum">    2861 </span>                :            :                 return NULL;</a>
<a name="2862"><span class="lineNum">    2862 </span>                :            : </a>
<a name="2863"><span class="lineNum">    2863 </span>                :            : #define PID2TCB_CACHE_SIZE 1024U</a>
<a name="2864"><span class="lineNum">    2864 </span>                :            : #define PID2TCB_CACHE_MASK (PID2TCB_CACHE_SIZE - 1)</a>
<a name="2865"><span class="lineNum">    2865 </span>                :            : </a>
<a name="2866"><span class="lineNum">    2866 </span>                :<span class="lineCov">  176338126 :         static struct tcb *pid2tcb_cache[PID2TCB_CACHE_SIZE];</span></a>
<a name="2867"><span class="lineNum">    2867 </span>                :<span class="lineCov">  176338126 :         struct tcb **const ptcp = &pid2tcb_cache[pid & PID2TCB_CACHE_MASK];</span></a>
<a name="2868"><span class="lineNum">    2868 </span>                :<span class="lineCov">  176338126 :         struct tcb *tcp = *ptcp;</span></a>
<a name="2869"><span class="lineNum">    2869 </span>                :            : </a>
<a name="2870"><span class="lineNum">    2870 </span>  [<span class="branchCov" title="Branch 0 was taken 176279766 times"> + </span><span class="branchCov" title="Branch 1 was taken 58360 times"> + </span><span class="branchCov" title="Branch 2 was taken 9240 times"> + </span><span class="branchCov" title="Branch 3 was taken 176270526 times"> + </span>]:<span class="lineCov">  176338126 :         if (tcp && tcp->pid == pid)</span></a>
<a name="2871"><span class="lineNum">    2871 </span>                :            :                 return tcp;</a>
<a name="2872"><span class="lineNum">    2872 </span>                :            : </a>
<a name="2873"><span class="lineNum">    2873 </span>        [<span class="branchCov" title="Branch 0 was taken 4941050 times"> + </span><span class="branchCov" title="Branch 1 was taken 29680 times"> + </span>]:<span class="lineCov">    4970730 :         for (unsigned int i = 0; i < tcbtabsize; ++i) {</span></a>
<a name="2874"><span class="lineNum">    2874 </span>                :<span class="lineCov">    4941050 :                 tcp = tcbtab[i];</span></a>
<a name="2875"><span class="lineNum">    2875 </span>        [<span class="branchCov" title="Branch 0 was taken 37920 times"> + </span><span class="branchCov" title="Branch 1 was taken 4903130 times"> + </span>]:<span class="lineCov">    4941050 :                 if (tcp->pid == pid)</span></a>
<a name="2876"><span class="lineNum">    2876 </span>                :<span class="lineCov">      37920 :                         return *ptcp = tcp;</span></a>
<a name="2877"><span class="lineNum">    2877 </span>                :            :         }</a>
<a name="2878"><span class="lineNum">    2878 </span>                :            : </a>
<a name="2879"><span class="lineNum">    2879 </span>                :            :         return NULL;</a>
<a name="2880"><span class="lineNum">    2880 </span>                :            : }</a>
<a name="2881"><span class="lineNum">    2881 </span>                :            : </a>
<a name="2882"><span class="lineNum">    2882 </span>                :            : static void</a>
<a name="2883"><span class="lineNum">    2883 </span>                :<span class="lineCov">      22630 : cleanup(int fatal_sig)</span></a>
<a name="2884"><span class="lineNum">    2884 </span>                :            : {</a>
<a name="2885"><span class="lineNum">    2885 </span>        [<span class="branchCov" title="Branch 0 was taken 22626 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">      22630 :         if (!fatal_sig)</span></a>
<a name="2886"><span class="lineNum">    2886 </span>                :<span class="lineCov">      22626 :                 fatal_sig = SIGTERM;</span></a>
<a name="2887"><span class="lineNum">    2887 </span>                :            : </a>
<a name="2888"><span class="lineNum">    2888 </span>        [<span class="branchCov" title="Branch 0 was taken 293149 times"> + </span><span class="branchCov" title="Branch 1 was taken 22630 times"> + </span>]:<span class="lineCov">     315779 :         for (unsigned int i = 0; i < tcbtabsize; ++i) {</span></a>
<a name="2889"><span class="lineNum">    2889 </span>                :<span class="lineCov">     293149 :                 struct tcb *tcp = tcbtab[i];</span></a>
<a name="2890"><span class="lineNum">    2890 </span>        [<span class="branchCov" title="Branch 0 was taken 293117 times"> + </span><span class="branchCov" title="Branch 1 was taken 32 times"> + </span>]:<span class="lineCov">     293149 :                 if (!tcp->pid)</span></a>
<a name="2891"><span class="lineNum">    2891 </span>                :<span class="lineCov">     293117 :                         continue;</span></a>
<a name="2892"><span class="lineNum">    2892 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 32 times"> + </span>]:<span class="lineCov">         32 :                 debug_func_msg("looking at pid %u", tcp->pid);</span></a>
<a name="2893"><span class="lineNum">    2893 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 31 times"> + </span>]:<span class="lineCov">         32 :                 if (tcp->pid == strace_child) {</span></a>
<a name="2894"><span class="lineNum">    2894 </span>                :<span class="lineCov">          1 :                         kill(tcp->pid, SIGCONT);</span></a>
<a name="2895"><span class="lineNum">    2895 </span>                :<span class="lineCov">          1 :                         kill(tcp->pid, fatal_sig);</span></a>
<a name="2896"><span class="lineNum">    2896 </span>                :            :                 }</a>
<a name="2897"><span class="lineNum">    2897 </span>                :<span class="lineCov">         32 :                 detach(tcp);</span></a>
<a name="2898"><span class="lineNum">    2898 </span>                :            :         }</a>
<a name="2899"><span class="lineNum">    2899 </span>                :<span class="lineCov">      22630 : }</span></a>
<a name="2900"><span class="lineNum">    2900 </span>                :            : </a>
<a name="2901"><span class="lineNum">    2901 </span>                :            : static void</a>
<a name="2902"><span class="lineNum">    2902 </span>                :<span class="lineCov">          4 : interrupt(int sig)</span></a>
<a name="2903"><span class="lineNum">    2903 </span>                :            : {</a>
<a name="2904"><span class="lineNum">    2904 </span>                :<span class="lineCov">          4 :         interrupted = sig;</span></a>
<a name="2905"><span class="lineNum">    2905 </span>                :<span class="lineCov">          4 : }</span></a>
<a name="2906"><span class="lineNum">    2906 </span>                :            : </a>
<a name="2907"><span class="lineNum">    2907 </span>                :            : static void</a>
<a name="2908"><span class="lineNum">    2908 </span>                :<span class="lineCov">      75431 : print_debug_info(const int pid, int status)</span></a>
<a name="2909"><span class="lineNum">    2909 </span>                :            : {</a>
<a name="2910"><span class="lineNum">    2910 </span>                :<span class="lineCov">      75431 :         const unsigned int event = (unsigned int) status >> 16;</span></a>
<a name="2911"><span class="lineNum">    2911 </span>                :<span class="lineCov">      75431 :         char buf[sizeof("WIFEXITED,exitcode=%u") + sizeof(int)*3 /*paranoia:*/ + 16];</span></a>
<a name="2912"><span class="lineNum">    2912 </span>                :<span class="lineCov">      75431 :         char evbuf[sizeof(",EVENT_VFORK_DONE (%u)") + sizeof(int)*3 /*paranoia:*/ + 16];</span></a>
<a name="2913"><span class="lineNum">    2913 </span>                :            : </a>
<a name="2914"><span class="lineNum">    2914 </span>                :<span class="lineCov">      75431 :         strcpy(buf, "???");</span></a>
<a name="2915"><span class="lineNum">    2915 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 75431 times"> + </span>]:<span class="lineCov">      75431 :         if (WIFSIGNALED(status))</span></a>
<a name="2916"><span class="lineNum">    2916 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 xsprintf(buf, "WIFSIGNALED,%ssig=%s",</span></a>
<a name="2917"><span class="lineNum">    2917 </span>                :            :                                 WCOREDUMP(status) ? "core," : "",</a>
<a name="2918"><span class="lineNum">    2918 </span>                :            :                                 sprintsigname(WTERMSIG(status)));</a>
<a name="2919"><span class="lineNum">    2919 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 75419 times"> + </span>]:<span class="lineCov">      75431 :         if (WIFEXITED(status))</span></a>
<a name="2920"><span class="lineNum">    2920 </span>                :<span class="lineCov">         12 :                 xsprintf(buf, "WIFEXITED,exitcode=%u", WEXITSTATUS(status));</span></a>
<a name="2921"><span class="lineNum">    2921 </span>        [<span class="branchCov" title="Branch 0 was taken 75419 times"> + </span><span class="branchCov" title="Branch 1 was taken 12 times"> + </span>]:<span class="lineCov">      75431 :         if (WIFSTOPPED(status))</span></a>
<a name="2922"><span class="lineNum">    2922 </span>                :<span class="lineCov">      75419 :                 xsprintf(buf, "WIFSTOPPED,sig=%s",</span></a>
<a name="2923"><span class="lineNum">    2923 </span>                :            :                          sprintsigname(WSTOPSIG(status)));</a>
<a name="2924"><span class="lineNum">    2924 </span>                :<span class="lineCov">      75431 :         evbuf[0] = '\0';</span></a>
<a name="2925"><span class="lineNum">    2925 </span>        [<span class="branchCov" title="Branch 0 was taken 37 times"> + </span><span class="branchCov" title="Branch 1 was taken 75394 times"> + </span>]:<span class="lineCov">      75431 :         if (event != 0) {</span></a>
<a name="2926"><span class="lineNum">    2926 </span>                :<span class="lineCov">         37 :                 static const char *const event_names[] = {</span></a>
<a name="2927"><span class="lineNum">    2927 </span>                :            :                         [PTRACE_EVENT_CLONE] = "CLONE",</a>
<a name="2928"><span class="lineNum">    2928 </span>                :            :                         [PTRACE_EVENT_FORK]  = "FORK",</a>
<a name="2929"><span class="lineNum">    2929 </span>                :            :                         [PTRACE_EVENT_VFORK] = "VFORK",</a>
<a name="2930"><span class="lineNum">    2930 </span>                :            :                         [PTRACE_EVENT_VFORK_DONE] = "VFORK_DONE",</a>
<a name="2931"><span class="lineNum">    2931 </span>                :            :                         [PTRACE_EVENT_EXEC]  = "EXEC",</a>
<a name="2932"><span class="lineNum">    2932 </span>                :            :                         [PTRACE_EVENT_EXIT]  = "EXIT",</a>
<a name="2933"><span class="lineNum">    2933 </span>                :            :                         [PTRACE_EVENT_SECCOMP]  = "SECCOMP",</a>
<a name="2934"><span class="lineNum">    2934 </span>                :            :                         /* [PTRACE_EVENT_STOP (=128)] would make biggish array */</a>
<a name="2935"><span class="lineNum">    2935 </span>                :            :                 };</a>
<a name="2936"><span class="lineNum">    2936 </span>                :<span class="lineCov">         37 :                 const char *e = "??";</span></a>
<a name="2937"><span class="lineNum">    2937 </span>        [<span class="branchCov" title="Branch 0 was taken 13 times"> + </span><span class="branchCov" title="Branch 1 was taken 24 times"> + </span>]:<span class="lineCov">         37 :                 if (event < ARRAY_SIZE(event_names))</span></a>
<a name="2938"><span class="lineNum">    2938 </span>                :<span class="lineCov">         13 :                         e = event_names[event];</span></a>
<a name="2939"><span class="lineNum">    2939 </span>        [<span class="branchCov" title="Branch 0 was taken 24 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         24 :                 else if (event == PTRACE_EVENT_STOP)</span></a>
<a name="2940"><span class="lineNum">    2940 </span>                :<span class="lineCov">         24 :                         e = "STOP";</span></a>
<a name="2941"><span class="lineNum">    2941 </span>                :<span class="lineCov">         37 :                 xsprintf(evbuf, ",EVENT_%s (%u)", e, event);</span></a>
<a name="2942"><span class="lineNum">    2942 </span>                :            :         }</a>
<a name="2943"><span class="lineNum">    2943 </span>                :<span class="lineCov">      75431 :         error_msg("[wait(0x%06x) = %u] %s%s", status, pid, buf, evbuf);</span></a>
<a name="2944"><span class="lineNum">    2944 </span>                :<span class="lineCov">      75431 : }</span></a>
<a name="2945"><span class="lineNum">    2945 </span>                :            : </a>
<a name="2946"><span class="lineNum">    2946 </span>                :            : static struct tcb *</a>
<a name="2947"><span class="lineNum">    2947 </span>                :<span class="lineCov">      29680 : maybe_allocate_tcb(const int pid, int status)</span></a>
<a name="2948"><span class="lineNum">    2948 </span>                :            : {</a>
<a name="2949"><span class="lineNum">    2949 </span>        [<span class="branchCov" title="Branch 0 was taken 194 times"> + </span><span class="branchCov" title="Branch 1 was taken 29486 times"> + </span>]:<span class="lineCov">      29680 :         if (!WIFSTOPPED(status)) {</span></a>
<a name="2950"><span class="lineNum">    2950 </span>  [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 192 times"> + </span><span class="branchCov" title="Branch 2 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">        194 :                 if (detach_on_execve && pid == strace_child) {</span></a>
<a name="2951"><span class="lineNum">    2951 </span>                :            :                         /* example: strace -bexecve sh -c 'exec true' */</a>
<a name="2952"><span class="lineNum">    2952 </span>                :<span class="lineCov">          2 :                         strace_child = 0;</span></a>
<a name="2953"><span class="lineNum">    2953 </span>                :<span class="lineCov">          2 :                         return NULL;</span></a>
<a name="2954"><span class="lineNum">    2954 </span>                :            :                 }</a>
<a name="2955"><span class="lineNum">    2955 </span>        [<span class="branchCov" title="Branch 0 was taken 190 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">        192 :                 if (!is_number_in_set(QUIET_EXIT, quiet_set)) {</span></a>
<a name="2956"><span class="lineNum">    2956 </span>                :            :                         /*</a>
<a name="2957"><span class="lineNum">    2957 </span>                :            :                          * This can happen if we inherited an unknown child.</a>
<a name="2958"><span class="lineNum">    2958 </span>                :            :                          * Example: (sleep 1 & exec strace true)</a>
<a name="2959"><span class="lineNum">    2959 </span>                :            :                          */</a>
<a name="2960"><span class="lineNum">    2960 </span>                :<span class="lineCov">        190 :                         error_msg("Exit of unknown pid %u ignored", pid);</span></a>
<a name="2961"><span class="lineNum">    2961 </span>                :            :                 }</a>
<a name="2962"><span class="lineNum">    2962 </span>                :<span class="lineCov">        192 :                 return NULL;</span></a>
<a name="2963"><span class="lineNum">    2963 </span>                :            :         }</a>
<a name="2964"><span class="lineNum">    2964 </span>        [<span class="branchCov" title="Branch 0 was taken 29481 times"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">      29486 :         if (followfork) {</span></a>
<a name="2965"><span class="lineNum">    2965 </span>                :            :                 /* We assume it's a fork/vfork/clone child */</a>
<a name="2966"><span class="lineNum">    2966 </span>                :<span class="lineCov">      29481 :                 struct tcb *tcp = alloctcb(pid);</span></a>
<a name="2967"><span class="lineNum">    2967 </span>                :<span class="lineCov">      29481 :                 after_successful_attach(tcp, post_attach_sigstop);</span></a>
<a name="2968"><span class="lineNum">    2968 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 29477 times"> + </span>]:<span class="lineCov">      29481 :                 if (!is_number_in_set(QUIET_ATTACH, quiet_set))</span></a>
<a name="2969"><span class="lineNum">    2969 </span>                :<span class="lineCov">          4 :                         error_msg("Process %d attached", pid);</span></a>
<a name="2970"><span class="lineNum">    2970 </span>                :<span class="lineCov">      29481 :                 return tcp;</span></a>
<a name="2971"><span class="lineNum">    2971 </span>                :            :         } else {</a>
<a name="2972"><span class="lineNum">    2972 </span>                :            :                 /*</a>
<a name="2973"><span class="lineNum">    2973 </span>                :            :                  * This can happen if a clone call misused CLONE_PTRACE itself.</a>
<a name="2974"><span class="lineNum">    2974 </span>                :            :                  *</a>
<a name="2975"><span class="lineNum">    2975 </span>                :            :                  * There used to be a dance around possible re-injection of</a>
<a name="2976"><span class="lineNum">    2976 </span>                :            :                  * WSTOPSIG(status), but it was later removed as the only</a>
<a name="2977"><span class="lineNum">    2977 </span>                :            :                  * observable stop here is the initial ptrace-stop.</a>
<a name="2978"><span class="lineNum">    2978 </span>                :            :                  */</a>
<a name="2979"><span class="lineNum">    2979 </span>                :<span class="lineCov">          5 :                 ptrace(PTRACE_DETACH, pid, NULL, 0L);</span></a>
<a name="2980"><span class="lineNum">    2980 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          5 :                 if (!is_number_in_set(QUIET_ATTACH, quiet_set))</span></a>
<a name="2981"><span class="lineNum">    2981 </span>                :<span class="lineCov">          2 :                         error_msg("Detached unknown pid %d", pid);</span></a>
<a name="2982"><span class="lineNum">    2982 </span>                :<span class="lineCov">          5 :                 return NULL;</span></a>
<a name="2983"><span class="lineNum">    2983 </span>                :            :         }</a>
<a name="2984"><span class="lineNum">    2984 </span>                :            : }</a>
<a name="2985"><span class="lineNum">    2985 </span>                :            : </a>
<a name="2986"><span class="lineNum">    2986 </span>                :            : /*</a>
<a name="2987"><span class="lineNum">    2987 </span>                :            :  * Under Linux, execve changes pid to thread leader's pid, and we see this</a>
<a name="2988"><span class="lineNum">    2988 </span>                :            :  * changed pid on EVENT_EXEC and later, execve sysexit.  Leader "disappears"</a>
<a name="2989"><span class="lineNum">    2989 </span>                :            :  * without exit notification.  Let user know that, drop leader's tcb, and fix</a>
<a name="2990"><span class="lineNum">    2990 </span>                :            :  * up pid in execve thread's tcb.  Effectively, execve thread's tcb replaces</a>
<a name="2991"><span class="lineNum">    2991 </span>                :            :  * leader's tcb.</a>
<a name="2992"><span class="lineNum">    2992 </span>                :            :  *</a>
<a name="2993"><span class="lineNum">    2993 </span>                :            :  * BTW, leader is 'stuck undead' (doesn't report WIFEXITED on exit syscall)</a>
<a name="2994"><span class="lineNum">    2994 </span>                :            :  * in multi-threaded programs exactly in order to handle this case.</a>
<a name="2995"><span class="lineNum">    2995 </span>                :            :  */</a>
<a name="2996"><span class="lineNum">    2996 </span>                :            : static struct tcb *</a>
<a name="2997"><span class="lineNum">    2997 </span>                :<span class="lineCov">      17394 : maybe_switch_tcbs(struct tcb *tcp, const int pid)</span></a>
<a name="2998"><span class="lineNum">    2998 </span>                :            : {</a>
<a name="2999"><span class="lineNum">    2999 </span>                :            :         /*</a>
<a name="3000"><span class="lineNum">    3000 </span>                :            :          * PTRACE_GETEVENTMSG returns old pid starting from Linux 3.0.</a>
<a name="3001"><span class="lineNum">    3001 </span>                :            :          * On 2.6 and earlier it can return garbage.</a>
<a name="3002"><span class="lineNum">    3002 </span>                :            :          */</a>
<a name="3003"><span class="lineNum">    3003 </span>        [<span class="branchCov" title="Branch 0 was taken 17394 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17394 :         if (os_release < KERNEL_VERSION(3, 0, 0))</span></a>
<a name="3004"><span class="lineNum">    3004 </span>                :            :                 return NULL;</a>
<a name="3005"><span class="lineNum">    3005 </span>                :            : </a>
<a name="3006"><span class="lineNum">    3006 </span>                :<span class="lineCov">      17394 :         const long old_pid = tcb_wait_tab[tcp->wait_data_idx].msg;</span></a>
<a name="3007"><span class="lineNum">    3007 </span>                :            : </a>
<a name="3008"><span class="lineNum">    3008 </span>                :            :         /* Avoid truncation in pid2tcb() param passing */</a>
<a name="3009"><span class="lineNum">    3009 </span>  [<span class="branchCov" title="Branch 0 was taken 17394 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchCov" title="Branch 2 was taken 19 times"> + </span><span class="branchCov" title="Branch 3 was taken 17375 times"> + </span>]:<span class="lineCov">      17394 :         if (old_pid <= 0 || old_pid == pid)</span></a>
<a name="3010"><span class="lineNum">    3010 </span>                :            :                 return NULL;</a>
<a name="3011"><span class="lineNum">    3011 </span>        [<span class="branchCov" title="Branch 0 was taken 19 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         19 :         if ((unsigned long) old_pid > UINT_MAX)</span></a>
<a name="3012"><span class="lineNum">    3012 </span>                :            :                 return NULL;</a>
<a name="3013"><span class="lineNum">    3013 </span>                :<span class="lineCov">         19 :         struct tcb *execve_thread = pid2tcb(old_pid);</span></a>
<a name="3014"><span class="lineNum">    3014 </span>                :            :         /* It should be !NULL, but I feel paranoid */</a>
<a name="3015"><span class="lineNum">    3015 </span>        [<span class="branchCov" title="Branch 0 was taken 19 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         19 :         if (!execve_thread)</span></a>
<a name="3016"><span class="lineNum">    3016 </span>                :            :                 return NULL;</a>
<a name="3017"><span class="lineNum">    3017 </span>                :            : </a>
<a name="3018"><span class="lineNum">    3018 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 12 times"> + </span>]:<span class="lineCov">         19 :         if (execve_thread->curcol != 0) {</span></a>
<a name="3019"><span class="lineNum">    3019 </span>                :            :                 /*</a>
<a name="3020"><span class="lineNum">    3020 </span>                :            :                  * One case we are here is -ff, try</a>
<a name="3021"><span class="lineNum">    3021 </span>                :            :                  * "strace -oLOG -ff test/threaded_execve".</a>
<a name="3022"><span class="lineNum">    3022 </span>                :            :                  * Another case is demonstrated by</a>
<a name="3023"><span class="lineNum">    3023 </span>                :            :                  * tests/maybe_switch_current_tcp.c</a>
<a name="3024"><span class="lineNum">    3024 </span>                :            :                  */</a>
<a name="3025"><span class="lineNum">    3025 </span>                :<span class="lineCov">          7 :                 fprintf(execve_thread->outf, " <pid changed to %d ...>\n", pid);</span></a>
<a name="3026"><span class="lineNum">    3026 </span>                :            :                 /*execve_thread->curcol = 0; - no need, see code below */</a>
<a name="3027"><span class="lineNum">    3027 </span>                :            :         }</a>
<a name="3028"><span class="lineNum">    3028 </span>                :            :         /* Swap output FILEs and memstream (needed for -ff) */</a>
<a name="3029"><span class="lineNum">    3029 </span>                :<span class="lineCov">         19 :         FILE *fp = execve_thread->outf;</span></a>
<a name="3030"><span class="lineNum">    3030 </span>                :<span class="lineCov">         19 :         execve_thread->outf = tcp->outf;</span></a>
<a name="3031"><span class="lineNum">    3031 </span>                :<span class="lineCov">         19 :         tcp->outf = fp;</span></a>
<a name="3032"><span class="lineNum">    3032 </span>  [<span class="branchCov" title="Branch 0 was taken 17 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 17 times"> + </span>]:<span class="lineCov">         19 :         if (execve_thread->staged_output_data || tcp->staged_output_data) {</span></a>
<a name="3033"><span class="lineNum">    3033 </span>                :<span class="lineCov">          2 :                 struct staged_output_data *staged_output_data;</span></a>
<a name="3034"><span class="lineNum">    3034 </span>                :            : </a>
<a name="3035"><span class="lineNum">    3035 </span>                :<span class="lineCov">          2 :                 staged_output_data = execve_thread->staged_output_data;</span></a>
<a name="3036"><span class="lineNum">    3036 </span>                :<span class="lineCov">          2 :                 execve_thread->staged_output_data = tcp->staged_output_data;</span></a>
<a name="3037"><span class="lineNum">    3037 </span>                :<span class="lineCov">          2 :                 tcp->staged_output_data = staged_output_data;</span></a>
<a name="3038"><span class="lineNum">    3038 </span>                :            :         }</a>
<a name="3039"><span class="lineNum">    3039 </span>                :            : </a>
<a name="3040"><span class="lineNum">    3040 </span>                :            :         /* And their column positions */</a>
<a name="3041"><span class="lineNum">    3041 </span>                :<span class="lineCov">         19 :         execve_thread->curcol = tcp->curcol;</span></a>
<a name="3042"><span class="lineNum">    3042 </span>                :<span class="lineCov">         19 :         tcp->curcol = 0;</span></a>
<a name="3043"><span class="lineNum">    3043 </span>                :            :         /* Drop leader, but close execve'd thread outfile (if -ff) */</a>
<a name="3044"><span class="lineNum">    3044 </span>                :<span class="lineCov">         19 :         droptcb(tcp);</span></a>
<a name="3045"><span class="lineNum">    3045 </span>                :            :         /* Switch to the thread, reusing leader's outfile and pid */</a>
<a name="3046"><span class="lineNum">    3046 </span>                :<span class="lineCov">         19 :         tcp = execve_thread;</span></a>
<a name="3047"><span class="lineNum">    3047 </span>                :<span class="lineCov">         19 :         tcp->pid = pid;</span></a>
<a name="3048"><span class="lineNum">    3048 </span>        [<span class="branchCov" title="Branch 0 was taken 19 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         19 :         if (cflag != CFLAG_ONLY_STATS) {</span></a>
<a name="3049"><span class="lineNum">    3049 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 7 times"> + </span>]:<span class="lineCov">         19 :                 if (!is_number_in_set(QUIET_THREAD_EXECVE, quiet_set)) {</span></a>
<a name="3050"><span class="lineNum">    3050 </span>                :<span class="lineCov">         12 :                         printleader(tcp);</span></a>
<a name="3051"><span class="lineNum">    3051 </span>                :<span class="lineCov">         12 :                         tprintf("+++ superseded by execve in pid %lu +++\n",</span></a>
<a name="3052"><span class="lineNum">    3052 </span>                :            :                                 old_pid);</a>
<a name="3053"><span class="lineNum">    3053 </span>                :<span class="lineCov">         12 :                         line_ended();</span></a>
<a name="3054"><span class="lineNum">    3054 </span>                :            :                 }</a>
<a name="3055"><span class="lineNum">    3055 </span>                :            :                 /*</a>
<a name="3056"><span class="lineNum">    3056 </span>                :            :                  * Need to reopen memstream for thread</a>
<a name="3057"><span class="lineNum">    3057 </span>                :            :                  * as we closed it in droptcb.</a>
<a name="3058"><span class="lineNum">    3058 </span>                :            :                  */</a>
<a name="3059"><span class="lineNum">    3059 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 17 times"> + </span>]:<span class="lineCov">         19 :                 if (!is_complete_set(status_set, NUMBER_OF_STATUSES))</span></a>
<a name="3060"><span class="lineNum">    3060 </span>                :<span class="lineCov">          2 :                         strace_open_memstream(tcp);</span></a>
<a name="3061"><span class="lineNum">    3061 </span>                :<span class="lineCov">         19 :                 tcp->flags |= TCB_REPRINT;</span></a>
<a name="3062"><span class="lineNum">    3062 </span>                :            :         }</a>
<a name="3063"><span class="lineNum">    3063 </span>                :            : </a>
<a name="3064"><span class="lineNum">    3064 </span>                :            :         return tcp;</a>
<a name="3065"><span class="lineNum">    3065 </span>                :            : }</a>
<a name="3066"><span class="lineNum">    3066 </span>                :            : </a>
<a name="3067"><span class="lineNum">    3067 </span>                :            : static struct tcb *</a>
<a name="3068"><span class="lineNum">    3068 </span>                :<span class="lineCov">      17394 : maybe_switch_current_tcp(void)</span></a>
<a name="3069"><span class="lineNum">    3069 </span>                :            : {</a>
<a name="3070"><span class="lineNum">    3070 </span>                :<span class="lineCov">      17394 :         struct tcb *tcp = maybe_switch_tcbs(current_tcp, current_tcp->pid);</span></a>
<a name="3071"><span class="lineNum">    3071 </span>                :            : </a>
<a name="3072"><span class="lineNum">    3072 </span>        [<span class="branchCov" title="Branch 0 was taken 19 times"> + </span><span class="branchCov" title="Branch 1 was taken 17375 times"> + </span>]:<span class="lineCov">      17394 :         if (tcp)</span></a>
<a name="3073"><span class="lineNum">    3073 </span>                :<span class="lineCov">         19 :                 set_current_tcp(tcp);</span></a>
<a name="3074"><span class="lineNum">    3074 </span>                :            : </a>
<a name="3075"><span class="lineNum">    3075 </span>                :<span class="lineCov">      17394 :         return tcp;</span></a>
<a name="3076"><span class="lineNum">    3076 </span>                :            : }</a>
<a name="3077"><span class="lineNum">    3077 </span>                :            : </a>
<a name="3078"><span class="lineNum">    3078 </span>                :            : static void</a>
<a name="3079"><span class="lineNum">    3079 </span>                :<span class="lineCov">      10070 : print_signalled(struct tcb *tcp, const int pid, int status)</span></a>
<a name="3080"><span class="lineNum">    3080 </span>                :            : {</a>
<a name="3081"><span class="lineNum">    3081 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 10062 times"> + </span>]:<span class="lineCov">      10070 :         if (pid == strace_child) {</span></a>
<a name="3082"><span class="lineNum">    3082 </span>                :<span class="lineCov">          8 :                 exit_code = 0x100 | WTERMSIG(status);</span></a>
<a name="3083"><span class="lineNum">    3083 </span>                :<span class="lineCov">          8 :                 strace_child = 0;</span></a>
<a name="3084"><span class="lineNum">    3084 </span>                :            :         }</a>
<a name="3085"><span class="lineNum">    3085 </span>                :            : </a>
<a name="3086"><span class="lineNum">    3086 </span>        [<span class="branchCov" title="Branch 0 was taken 10070 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      10070 :         if (cflag != CFLAG_ONLY_STATS</span></a>
<a name="3087"><span class="lineNum">    3087 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 10066 times"> + </span>]:<span class="lineCov">      10070 :             && is_number_in_set(WTERMSIG(status), signal_set)) {</span></a>
<a name="3088"><span class="lineNum">    3088 </span>                :<span class="lineCov">          4 :                 printleader(tcp);</span></a>
<a name="3089"><span class="lineNum">    3089 </span>                :<span class="lineCov">          4 :                 tprintf("+++ killed by %s %s+++\n",</span></a>
<a name="3090"><span class="lineNum">    3090 </span>                :            :                         sprintsigname(WTERMSIG(status)),</a>
<a name="3091"><span class="lineNum">    3091 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          4 :                         WCOREDUMP(status) ? "(core dumped) " : "");</span></a>
<a name="3092"><span class="lineNum">    3092 </span>                :<span class="lineCov">          4 :                 line_ended();</span></a>
<a name="3093"><span class="lineNum">    3093 </span>                :            :         }</a>
<a name="3094"><span class="lineNum">    3094 </span>                :<span class="lineCov">      10070 : }</span></a>
<a name="3095"><span class="lineNum">    3095 </span>                :            : </a>
<a name="3096"><span class="lineNum">    3096 </span>                :            : static void</a>
<a name="3097"><span class="lineNum">    3097 </span>                :<span class="lineCov">      36729 : print_exited(struct tcb *tcp, const int pid, int status)</span></a>
<a name="3098"><span class="lineNum">    3098 </span>                :            : {</a>
<a name="3099"><span class="lineNum">    3099 </span>        [<span class="branchCov" title="Branch 0 was taken 17312 times"> + </span><span class="branchCov" title="Branch 1 was taken 19417 times"> + </span>]:<span class="lineCov">      36729 :         if (pid == strace_child) {</span></a>
<a name="3100"><span class="lineNum">    3100 </span>                :<span class="lineCov">      17312 :                 exit_code = WEXITSTATUS(status);</span></a>
<a name="3101"><span class="lineNum">    3101 </span>                :<span class="lineCov">      17312 :                 strace_child = 0;</span></a>
<a name="3102"><span class="lineNum">    3102 </span>                :            :         }</a>
<a name="3103"><span class="lineNum">    3103 </span>                :            : </a>
<a name="3104"><span class="lineNum">    3104 </span>  [<span class="branchCov" title="Branch 0 was taken 36656 times"> + </span><span class="branchCov" title="Branch 1 was taken 73 times"> + </span><span class="branchCov" title="Branch 2 was taken 10522 times"> + </span><span class="branchCov" title="Branch 3 was taken 26134 times"> + </span>]:<span class="lineCov">      73385 :         if (cflag != CFLAG_ONLY_STATS &&</span></a>
<a name="3105"><span class="lineNum">    3105 </span>                :<span class="lineCov">      36656 :             !is_number_in_set(QUIET_EXIT, quiet_set)) {</span></a>
<a name="3106"><span class="lineNum">    3106 </span>                :<span class="lineCov">      10522 :                 printleader(tcp);</span></a>
<a name="3107"><span class="lineNum">    3107 </span>                :<span class="lineCov">      10522 :                 tprintf("+++ exited with %d +++\n", WEXITSTATUS(status));</span></a>
<a name="3108"><span class="lineNum">    3108 </span>                :<span class="lineCov">      10522 :                 line_ended();</span></a>
<a name="3109"><span class="lineNum">    3109 </span>                :            :         }</a>
<a name="3110"><span class="lineNum">    3110 </span>                :<span class="lineCov">      36729 : }</span></a>
<a name="3111"><span class="lineNum">    3111 </span>                :            : </a>
<a name="3112"><span class="lineNum">    3112 </span>                :            : static void</a>
<a name="3113"><span class="lineNum">    3113 </span>                :<span class="lineCov">      81774 : print_stopped(struct tcb *tcp, const siginfo_t *si, const unsigned int sig)</span></a>
<a name="3114"><span class="lineNum">    3114 </span>                :            : {</a>
<a name="3115"><span class="lineNum">    3115 </span>        [<span class="branchCov" title="Branch 0 was taken 81702 times"> + </span><span class="branchCov" title="Branch 1 was taken 72 times"> + </span>]:<span class="lineCov">      81774 :         if (cflag != CFLAG_ONLY_STATS</span></a>
<a name="3116"><span class="lineNum">    3116 </span>        [<span class="branchCov" title="Branch 0 was taken 47119 times"> + </span><span class="branchCov" title="Branch 1 was taken 34583 times"> + </span>]:<span class="lineCov">      81702 :             && !hide_log(tcp)</span></a>
<a name="3117"><span class="lineNum">    3117 </span>        [<span class="branchCov" title="Branch 0 was taken 6254 times"> + </span><span class="branchCov" title="Branch 1 was taken 40865 times"> + </span>]:<span class="lineCov">      47119 :             && is_number_in_set(sig, signal_set)) {</span></a>
<a name="3118"><span class="lineNum">    3118 </span>                :<span class="lineCov">       6254 :                 printleader(tcp);</span></a>
<a name="3119"><span class="lineNum">    3119 </span>        [<span class="branchCov" title="Branch 0 was taken 6252 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">       6254 :                 if (si) {</span></a>
<a name="3120"><span class="lineNum">    3120 </span>                :<span class="lineCov">       6252 :                         tprintf("--- %s ", sprintsigname(sig));</span></a>
<a name="3121"><span class="lineNum">    3121 </span>                :<span class="lineCov">       6252 :                         printsiginfo(tcp, si);</span></a>
<a name="3122"><span class="lineNum">    3122 </span>                :<span class="lineCov">       6252 :                         tprints(" ---\n");</span></a>
<a name="3123"><span class="lineNum">    3123 </span>                :            :                 } else</a>
<a name="3124"><span class="lineNum">    3124 </span>                :<span class="lineCov">          2 :                         tprintf("--- stopped by %s ---\n", sprintsigname(sig));</span></a>
<a name="3125"><span class="lineNum">    3125 </span>                :<span class="lineCov">       6254 :                 line_ended();</span></a>
<a name="3126"><span class="lineNum">    3126 </span>                :            : </a>
<a name="3127"><span class="lineNum">    3127 </span>                :            : #ifdef ENABLE_STACKTRACE</a>
<a name="3128"><span class="lineNum">    3128 </span>                :            :                 if (stack_trace_enabled)</a>
<a name="3129"><span class="lineNum">    3129 </span>                :            :                         unwind_tcb_print(tcp);</a>
<a name="3130"><span class="lineNum">    3130 </span>                :            : #endif</a>
<a name="3131"><span class="lineNum">    3131 </span>                :            :         }</a>
<a name="3132"><span class="lineNum">    3132 </span>                :<span class="lineCov">      81774 : }</span></a>
<a name="3133"><span class="lineNum">    3133 </span>                :            : </a>
<a name="3134"><span class="lineNum">    3134 </span>                :            : static void</a>
<a name="3135"><span class="lineNum">    3135 </span>                :<span class="lineCov">      46824 : startup_tcb(struct tcb *tcp)</span></a>
<a name="3136"><span class="lineNum">    3136 </span>                :            : {</a>
<a name="3137"><span class="lineNum">    3137 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 46812 times"> + </span>]:<span class="lineCov">      46824 :         debug_msg("pid %d has TCB_STARTUP, initializing it", tcp->pid);</span></a>
<a name="3138"><span class="lineNum">    3138 </span>                :            : </a>
<a name="3139"><span class="lineNum">    3139 </span>                :<span class="lineCov">      46824 :         tcp->flags &= ~TCB_STARTUP;</span></a>
<a name="3140"><span class="lineNum">    3140 </span>                :            : </a>
<a name="3141"><span class="lineNum">    3141 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 46824 times"> + </span>]:<span class="lineCov">      46824 :         if (!use_seize) {</span></a>
<a name="3142"><span class="lineNum">    3142 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 debug_msg("setting opts 0x%x on pid %d",</span></a>
<a name="3143"><span class="lineNum">    3143 </span>                :            :                           ptrace_setoptions, tcp->pid);</a>
<a name="3144"><span class="lineNum">    3144 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {</span></a>
<a name="3145"><span class="lineNum">    3145 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                         if (errno != ESRCH) {</span></a>
<a name="3146"><span class="lineNum">    3146 </span>                :            :                                 /* Should never happen, really */</a>
<a name="3147"><span class="lineNum">    3147 </span>                :<span class="lineNoCov">          0 :                                 perror_msg_and_die("PTRACE_SETOPTIONS");</span></a>
<a name="3148"><span class="lineNum">    3148 </span>                :            :                         }</a>
<a name="3149"><span class="lineNum">    3149 </span>                :            :                 }</a>
<a name="3150"><span class="lineNum">    3150 </span>                :            :         }</a>
<a name="3151"><span class="lineNum">    3151 </span>                :            : </a>
<a name="3152"><span class="lineNum">    3152 </span>  [<span class="branchCov" title="Branch 0 was taken 20 times"> + </span><span class="branchCov" title="Branch 1 was taken 46804 times"> + </span><span class="branchCov" title="Branch 2 was taken 20 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">      46824 :         if ((tcp->flags & TCB_GRABBED) && (get_scno(tcp) == 1))</span></a>
<a name="3153"><span class="lineNum">    3153 </span>                :<span class="lineCov">         20 :                 tcp->s_prev_ent = tcp->s_ent;</span></a>
<a name="3154"><span class="lineNum">    3154 </span>                :            : </a>
<a name="3155"><span class="lineNum">    3155 </span>        [<span class="branchCov" title="Branch 0 was taken 74 times"> + </span><span class="branchCov" title="Branch 1 was taken 46750 times"> + </span>]:<span class="lineCov">      46824 :         if (cflag) {</span></a>
<a name="3156"><span class="lineNum">    3156 </span>                :<span class="lineCov">         74 :                 tcp->atime = tcp->stime;</span></a>
<a name="3157"><span class="lineNum">    3157 </span>                :            :         }</a>
<a name="3158"><span class="lineNum">    3158 </span>                :<span class="lineCov">      46824 : }</span></a>
<a name="3159"><span class="lineNum">    3159 </span>                :            : </a>
<a name="3160"><span class="lineNum">    3160 </span>                :            : static void</a>
<a name="3161"><span class="lineNum">    3161 </span>                :<span class="lineCov">      46668 : print_event_exit(struct tcb *tcp)</span></a>
<a name="3162"><span class="lineNum">    3162 </span>                :            : {</a>
<a name="3163"><span class="lineNum">    3163 </span>        [<span class="branchCov" title="Branch 0 was taken 389 times"> + </span><span class="branchCov" title="Branch 1 was taken 46279 times"> + </span>]:<span class="lineCov">      46668 :         if (entering(tcp) || filtered(tcp) || hide_log(tcp)</span></a>
<a name="3164"><span class="lineNum">    3164 </span>        [<span class="branchCov" title="Branch 0 was taken 326 times"> + </span><span class="branchCov" title="Branch 1 was taken 63 times"> + </span>]:<span class="lineCov">        389 :             || cflag == CFLAG_ONLY_STATS) {</span></a>
<a name="3165"><span class="lineNum">    3165 </span>                :            :                 return;</a>
<a name="3166"><span class="lineNum">    3166 </span>                :            :         }</a>
<a name="3167"><span class="lineNum">    3167 </span>                :            : </a>
<a name="3168"><span class="lineNum">    3168 </span>  [<span class="branchCov" title="Branch 0 was taken 324 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span><span class="branchCov" title="Branch 2 was taken 36 times"> + </span><span class="branchCov" title="Branch 3 was taken 288 times"> + </span> :<span class="lineCov">        326 :         if (!output_separately && printing_tcp && printing_tcp != tcp</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 12 times"> + </span><span class="branchCov" title="Branch 5 was taken 24 times"> + </span>]
<a name="3169"><span class="lineNum">    3169 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         12 :             && printing_tcp->curcol != 0) {</span></a>
<a name="3170"><span class="lineNum">    3170 </span>                :<span class="lineCov">         12 :                 set_current_tcp(printing_tcp);</span></a>
<a name="3171"><span class="lineNum">    3171 </span>                :<span class="lineCov">         12 :                 tprints(" <unfinished ...>\n");</span></a>
<a name="3172"><span class="lineNum">    3172 </span>                :<span class="lineCov">         12 :                 flush_tcp_output(printing_tcp);</span></a>
<a name="3173"><span class="lineNum">    3173 </span>                :<span class="lineCov">         12 :                 printing_tcp->curcol = 0;</span></a>
<a name="3174"><span class="lineNum">    3174 </span>                :<span class="lineCov">         12 :                 set_current_tcp(tcp);</span></a>
<a name="3175"><span class="lineNum">    3175 </span>                :            :         }</a>
<a name="3176"><span class="lineNum">    3176 </span>                :            : </a>
<a name="3177"><span class="lineNum">    3177 </span>                :<span class="lineCov">        326 :         print_syscall_resume(tcp);</span></a>
<a name="3178"><span class="lineNum">    3178 </span>                :            : </a>
<a name="3179"><span class="lineNum">    3179 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 319 times"> + </span>]:<span class="lineCov">        326 :         if (!(tcp->sys_func_rval & RVAL_DECODED)) {</span></a>
<a name="3180"><span class="lineNum">    3180 </span>                :            :                 /*</a>
<a name="3181"><span class="lineNum">    3181 </span>                :            :                  * The decoder has probably decided to print something</a>
<a name="3182"><span class="lineNum">    3182 </span>                :            :                  * on exiting syscall which is not going to happen.</a>
<a name="3183"><span class="lineNum">    3183 </span>                :            :                  */</a>
<a name="3184"><span class="lineNum">    3184 </span>                :<span class="lineCov">          7 :                 tprints(" <unfinished ...>");</span></a>
<a name="3185"><span class="lineNum">    3185 </span>                :            :         }</a>
<a name="3186"><span class="lineNum">    3186 </span>                :            : </a>
<a name="3187"><span class="lineNum">    3187 </span>                :<span class="lineCov">        326 :         printing_tcp = tcp;</span></a>
<a name="3188"><span class="lineNum">    3188 </span>                :<span class="lineCov">        326 :         tprints(") ");</span></a>
<a name="3189"><span class="lineNum">    3189 </span>                :<span class="lineCov">        326 :         tabto();</span></a>
<a name="3190"><span class="lineNum">    3190 </span>                :<span class="lineCov">        326 :         tprints("= ?\n");</span></a>
<a name="3191"><span class="lineNum">    3191 </span>        [<span class="branchCov" title="Branch 0 was taken 7 times"> + </span><span class="branchCov" title="Branch 1 was taken 319 times"> + </span>]:<span class="lineCov">        326 :         if (!is_complete_set(status_set, NUMBER_OF_STATUSES)) {</span></a>
<a name="3192"><span class="lineNum">    3192 </span>                :<span class="lineCov">          7 :                 bool publish = is_number_in_set(STATUS_UNFINISHED, status_set);</span></a>
<a name="3193"><span class="lineNum">    3193 </span>                :<span class="lineCov">          7 :                 strace_close_memstream(tcp, publish);</span></a>
<a name="3194"><span class="lineNum">    3194 </span>                :            :         }</a>
<a name="3195"><span class="lineNum">    3195 </span>                :<span class="lineCov">        326 :         line_ended();</span></a>
<a name="3196"><span class="lineNum">    3196 </span>                :            : }</a>
<a name="3197"><span class="lineNum">    3197 </span>                :            : </a>
<a name="3198"><span class="lineNum">    3198 </span>                :            : static size_t</a>
<a name="3199"><span class="lineNum">    3199 </span>                :            : trace_wait_data_size(struct tcb *tcp)</a>
<a name="3200"><span class="lineNum">    3200 </span>                :            : {</a>
<a name="3201"><span class="lineNum">    3201 </span>                :            :         return sizeof(struct tcb_wait_data);</a>
<a name="3202"><span class="lineNum">    3202 </span>                :            : }</a>
<a name="3203"><span class="lineNum">    3203 </span>                :            : </a>
<a name="3204"><span class="lineNum">    3204 </span>                :            : static struct tcb_wait_data *</a>
<a name="3205"><span class="lineNum">    3205 </span>                :<span class="lineCov">  176337908 : init_trace_wait_data(void *p)</span></a>
<a name="3206"><span class="lineNum">    3206 </span>                :            : {</a>
<a name="3207"><span class="lineNum">    3207 </span>                :<span class="lineCov">  176337908 :         struct tcb_wait_data *wd = p;</span></a>
<a name="3208"><span class="lineNum">    3208 </span>                :            : </a>
<a name="3209"><span class="lineNum">    3209 </span>                :<span class="lineCov">  176337908 :         memset(wd, 0, sizeof(*wd));</span></a>
<a name="3210"><span class="lineNum">    3210 </span>                :            : </a>
<a name="3211"><span class="lineNum">    3211 </span>                :<span class="lineCov">  176337908 :         return wd;</span></a>
<a name="3212"><span class="lineNum">    3212 </span>                :            : }</a>
<a name="3213"><span class="lineNum">    3213 </span>                :            : </a>
<a name="3214"><span class="lineNum">    3214 </span>                :            : static struct tcb_wait_data *</a>
<a name="3215"><span class="lineNum">    3215 </span>                :<span class="lineCov">        136 : copy_trace_wait_data(const struct tcb_wait_data *wd)</span></a>
<a name="3216"><span class="lineNum">    3216 </span>                :            : {</a>
<a name="3217"><span class="lineNum">    3217 </span>                :<span class="lineCov">        136 :         return xobjdup(wd);</span></a>
<a name="3218"><span class="lineNum">    3218 </span>                :            : }</a>
<a name="3219"><span class="lineNum">    3219 </span>                :            : </a>
<a name="3220"><span class="lineNum">    3220 </span>                :            : static void</a>
<a name="3221"><span class="lineNum">    3221 </span>                :<span class="lineCov">        136 : free_trace_wait_data(struct tcb_wait_data *wd)</span></a>
<a name="3222"><span class="lineNum">    3222 </span>                :            : {</a>
<a name="3223"><span class="lineNum">    3223 </span>                :<span class="lineCov">        136 :         free(wd);</span></a>
<a name="3224"><span class="lineNum">    3224 </span>                :            : }</a>
<a name="3225"><span class="lineNum">    3225 </span>                :            : </a>
<a name="3226"><span class="lineNum">    3226 </span>                :            : static void</a>
<a name="3227"><span class="lineNum">    3227 </span>                :<span class="lineCov">  176338039 : tcb_wait_tab_check_size(const size_t size)</span></a>
<a name="3228"><span class="lineNum">    3228 </span>                :            : {</a>
<a name="3229"><span class="lineNum">    3229 </span>        [<span class="branchCov" title="Branch 0 was taken 22394 times"> + </span><span class="branchCov" title="Branch 1 was taken 176338039 times"> + </span>]:<span class="lineCov">  176360433 :         while (size >= tcb_wait_tab_size) {</span></a>
<a name="3230"><span class="lineNum">    3230 </span>                :<span class="lineCov">      22394 :                 tcb_wait_tab = xgrowarray(tcb_wait_tab,</span></a>
<a name="3231"><span class="lineNum">    3231 </span>                :            :                                           &tcb_wait_tab_size,</a>
<a name="3232"><span class="lineNum">    3232 </span>                :            :                                           sizeof(tcb_wait_tab[0]));</a>
<a name="3233"><span class="lineNum">    3233 </span>                :            :         }</a>
<a name="3234"><span class="lineNum">    3234 </span>                :<span class="lineCov">  176338039 : }</span></a>
<a name="3235"><span class="lineNum">    3235 </span>                :            : </a>
<a name="3236"><span class="lineNum">    3236 </span>                :            : static const struct tcb_wait_data *</a>
<a name="3237"><span class="lineNum">    3237 </span>                :<span class="lineCov">  176355377 : next_event(void)</span></a>
<a name="3238"><span class="lineNum">    3238 </span>                :            : {</a>
<a name="3239"><span class="lineNum">    3239 </span>        [<span class="branchCov" title="Branch 0 was taken 176355373 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">  176355377 :         if (interrupted)</span></a>
<a name="3240"><span class="lineNum">    3240 </span>                :            :                 return NULL;</a>
<a name="3241"><span class="lineNum">    3241 </span>                :            : </a>
<a name="3242"><span class="lineNum">    3242 </span>                :<span class="lineCov">  176355373 :         invalidate_umove_cache();</span></a>
<a name="3243"><span class="lineNum">    3243 </span>                :            : </a>
<a name="3244"><span class="lineNum">    3244 </span>                :<span class="lineCov">  176355373 :         struct tcb *tcp = NULL;</span></a>
<a name="3245"><span class="lineNum">    3245 </span>                :<span class="lineCov">  176355373 :         struct list_item *elem;</span></a>
<a name="3246"><span class="lineNum">    3246 </span>                :            : </a>
<a name="3247"><span class="lineNum">    3247 </span>                :<span class="lineCov">  176355373 :         static EMPTY_LIST(pending_tcps);</span></a>
<a name="3248"><span class="lineNum">    3248 </span>                :            :         /* Handle the queued tcbs before waiting for new events.  */</a>
<a name="3249"><span class="lineNum">    3249 </span>        [<span class="branchCov" title="Branch 0 was taken 23796859 times"> + </span><span class="branchCov" title="Branch 1 was taken 152558514 times"> + </span>]:<span class="lineCov">  176355373 :         if (!list_is_empty(&pending_tcps))</span></a>
<a name="3250"><span class="lineNum">    3250 </span>                :<span class="lineCov">   23796859 :                 goto next_event_get_tcp;</span></a>
<a name="3251"><span class="lineNum">    3251 </span>                :            : </a>
<a name="3252"><span class="lineNum">    3252 </span>                :<span class="lineCov">  152558514 :         static struct tcb *extra_tcp;</span></a>
<a name="3253"><span class="lineNum">    3253 </span>                :<span class="lineCov">  152558514 :         static size_t wait_extra_data_idx;</span></a>
<a name="3254"><span class="lineNum">    3254 </span>                :            :         /* Handle the extra tcb event.  */</a>
<a name="3255"><span class="lineNum">    3255 </span>        [<span class="branchCov" title="Branch 0 was taken 105 times"> + </span><span class="branchCov" title="Branch 1 was taken 152558409 times"> + </span>]:<span class="lineCov">  152558514 :         if (extra_tcp) {</span></a>
<a name="3256"><span class="lineNum">    3256 </span>                :<span class="lineCov">        105 :                 tcp = extra_tcp;</span></a>
<a name="3257"><span class="lineNum">    3257 </span>                :<span class="lineCov">        105 :                 extra_tcp = NULL;</span></a>
<a name="3258"><span class="lineNum">    3258 </span>                :<span class="lineCov">        105 :                 tcp->wait_data_idx = wait_extra_data_idx;</span></a>
<a name="3259"><span class="lineNum">    3259 </span>                :            : </a>
<a name="3260"><span class="lineNum">    3260 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 105 times"> + </span>]:<span class="lineCov">        105 :                 debug_msg("dequeued extra event for pid %u", tcp->pid);</span></a>
<a name="3261"><span class="lineNum">    3261 </span>                :<span class="lineCov">        105 :                 goto next_event_exit;</span></a>
<a name="3262"><span class="lineNum">    3262 </span>                :            :         }</a>
<a name="3263"><span class="lineNum">    3263 </span>                :            : </a>
<a name="3264"><span class="lineNum">    3264 </span>                :            :         /*</a>
<a name="3265"><span class="lineNum">    3265 </span>                :            :          * Used to exit simply when nprocs hits zero, but in this testcase:</a>
<a name="3266"><span class="lineNum">    3266 </span>                :            :          *  int main(void) { _exit(!!fork()); }</a>
<a name="3267"><span class="lineNum">    3267 </span>                :            :          * under strace -f, parent sometimes (rarely) manages</a>
<a name="3268"><span class="lineNum">    3268 </span>                :            :          * to exit before we see the first stop of the child,</a>
<a name="3269"><span class="lineNum">    3269 </span>                :            :          * and we are losing track of it:</a>
<a name="3270"><span class="lineNum">    3270 </span>                :            :          *  19923 clone(...) = 19924</a>
<a name="3271"><span class="lineNum">    3271 </span>                :            :          *  19923 exit_group(1)     = ?</a>
<a name="3272"><span class="lineNum">    3272 </span>                :            :          *  19923 +++ exited with 1 +++</a>
<a name="3273"><span class="lineNum">    3273 </span>                :            :          * Exiting only when wait() returns ECHILD works better.</a>
<a name="3274"><span class="lineNum">    3274 </span>                :            :          */</a>
<a name="3275"><span class="lineNum">    3275 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 152558409 times"> + </span>]:<span class="lineCov">  152558409 :         if (popen_pid != 0) {</span></a>
<a name="3276"><span class="lineNum">    3276 </span>                :            :                 /* However, if -o|logger is in use, we can't do that.</a>
<a name="3277"><span class="lineNum">    3277 </span>                :            :                  * Can work around that by double-forking the logger,</a>
<a name="3278"><span class="lineNum">    3278 </span>                :            :                  * but that loses the ability to wait for its completion</a>
<a name="3279"><span class="lineNum">    3279 </span>                :            :                  * on exit. Oh well...</a>
<a name="3280"><span class="lineNum">    3280 </span>                :            :                  */</a>
<a name="3281"><span class="lineNum">    3281 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 if (nprocs == 0)</span></a>
<a name="3282"><span class="lineNum">    3282 </span>                :            :                         return NULL;</a>
<a name="3283"><span class="lineNum">    3283 </span>                :            :         }</a>
<a name="3284"><span class="lineNum">    3284 </span>                :            : </a>
<a name="3285"><span class="lineNum">    3285 </span>                :<span class="lineCov">  152558409 :         const bool unblock_delay_timer = is_delay_timer_armed();</span></a>
<a name="3286"><span class="lineNum">    3286 </span>                :            : </a>
<a name="3287"><span class="lineNum">    3287 </span>                :            :         /*</a>
<a name="3288"><span class="lineNum">    3288 </span>                :            :          * The window of opportunity to handle expirations</a>
<a name="3289"><span class="lineNum">    3289 </span>                :            :          * of the delay timer opens here.</a>
<a name="3290"><span class="lineNum">    3290 </span>                :            :          *</a>
<a name="3291"><span class="lineNum">    3291 </span>                :            :          * Unblock the signal handler for the delay timer</a>
<a name="3292"><span class="lineNum">    3292 </span>                :            :          * iff the delay timer is already created.</a>
<a name="3293"><span class="lineNum">    3293 </span>                :            :          */</a>
<a name="3294"><span class="lineNum">    3294 </span>        [<span class="branchCov" title="Branch 0 was taken 418 times"> + </span><span class="branchCov" title="Branch 1 was taken 152557991 times"> + </span>]:<span class="lineCov">  152558409 :         if (unblock_delay_timer)</span></a>
<a name="3295"><span class="lineNum">    3295 </span>                :<span class="lineCov">        418 :                 sigprocmask(SIG_UNBLOCK, &timer_set, NULL);</span></a>
<a name="3296"><span class="lineNum">    3296 </span>                :            : </a>
<a name="3297"><span class="lineNum">    3297 </span>                :            :         /*</a>
<a name="3298"><span class="lineNum">    3298 </span>                :            :          * If the delay timer has expired, then its expiration</a>
<a name="3299"><span class="lineNum">    3299 </span>                :            :          * has been handled already by the signal handler.</a>
<a name="3300"><span class="lineNum">    3300 </span>                :            :          *</a>
<a name="3301"><span class="lineNum">    3301 </span>                :            :          * If the delay timer expires during wait4(),</a>
<a name="3302"><span class="lineNum">    3302 </span>                :            :          * then the system call will be interrupted and</a>
<a name="3303"><span class="lineNum">    3303 </span>                :            :          * the expiration will be handled by the signal handler.</a>
<a name="3304"><span class="lineNum">    3304 </span>                :            :          */</a>
<a name="3305"><span class="lineNum">    3305 </span>                :<span class="lineCov">  152558409 :         int status;</span></a>
<a name="3306"><span class="lineNum">    3306 </span>                :<span class="lineCov">  152558409 :         struct rusage ru;</span></a>
<a name="3307"><span class="lineNum">    3307 </span>        [<span class="branchCov" title="Branch 0 was taken 152341101 times"> + </span><span class="branchCov" title="Branch 1 was taken 217308 times"> + </span>]:<span class="lineCov">  304899510 :         int pid = wait4(-1, &status, __WALL, (cflag ? &ru : NULL));</span></a>
<a name="3308"><span class="lineNum">    3308 </span>                :<span class="lineCov">  152558409 :         int wait_errno = errno;</span></a>
<a name="3309"><span class="lineNum">    3309 </span>                :            : </a>
<a name="3310"><span class="lineNum">    3310 </span>                :            :         /*</a>
<a name="3311"><span class="lineNum">    3311 </span>                :            :          * The window of opportunity to handle expirations</a>
<a name="3312"><span class="lineNum">    3312 </span>                :            :          * of the delay timer closes here.</a>
<a name="3313"><span class="lineNum">    3313 </span>                :            :          *</a>
<a name="3314"><span class="lineNum">    3314 </span>                :            :          * Block the signal handler for the delay timer</a>
<a name="3315"><span class="lineNum">    3315 </span>                :            :          * iff it was unblocked earlier.</a>
<a name="3316"><span class="lineNum">    3316 </span>                :            :          */</a>
<a name="3317"><span class="lineNum">    3317 </span>        [<span class="branchCov" title="Branch 0 was taken 418 times"> + </span><span class="branchCov" title="Branch 1 was taken 152557991 times"> + </span>]:<span class="lineCov">  152558409 :         if (unblock_delay_timer) {</span></a>
<a name="3318"><span class="lineNum">    3318 </span>                :<span class="lineCov">        418 :                 sigprocmask(SIG_BLOCK, &timer_set, NULL);</span></a>
<a name="3319"><span class="lineNum">    3319 </span>                :            : </a>
<a name="3320"><span class="lineNum">    3320 </span>        [<span class="branchCov" title="Branch 0 was taken 418 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">        418 :                 if (restart_failed)</span></a>
<a name="3321"><span class="lineNum">    3321 </span>                :            :                         return NULL;</a>
<a name="3322"><span class="lineNum">    3322 </span>                :            :         }</a>
<a name="3323"><span class="lineNum">    3323 </span>                :            : </a>
<a name="3324"><span class="lineNum">    3324 </span>                :            :         size_t wait_tab_pos = 0;</a>
<a name="3325"><span class="lineNum">    3325 </span>                :            :         bool wait_nohang = false;</a>
<a name="3326"><span class="lineNum">    3326 </span>                :            : </a>
<a name="3327"><span class="lineNum">    3327 </span>                :            :         /*</a>
<a name="3328"><span class="lineNum">    3328 </span>                :            :          * Wait for new events until wait4() returns 0 (meaning that there's</a>
<a name="3329"><span class="lineNum">    3329 </span>                :            :          * nothing more to wait for for now), or a second event for some tcb</a>
<a name="3330"><span class="lineNum">    3330 </span>                :            :          * appears (which may happen if a tracee was SIGKILL'ed, for example).</a>
<a name="3331"><span class="lineNum">    3331 </span>                :            :          */</a>
<a name="3332"><span class="lineNum">    3332 </span>                :<span class="lineCov">  505234413 :         for (;;) {</span></a>
<a name="3333"><span class="lineNum">    3333 </span>                :<span class="lineCov">  328896411 :                 struct tcb_wait_data *wd;</span></a>
<a name="3334"><span class="lineNum">    3334 </span>                :            : </a>
<a name="3335"><span class="lineNum">    3335 </span>        [<span class="branchCov" title="Branch 0 was taken 34796 times"> + </span><span class="branchCov" title="Branch 1 was taken 328861615 times"> + </span>]:<span class="lineCov">  328896411 :                 if (pid < 0) {</span></a>
<a name="3336"><span class="lineNum">    3336 </span>        [<span class="branchCov" title="Branch 0 was taken 34667 times"> + </span><span class="branchCov" title="Branch 1 was taken 129 times"> + </span>]:<span class="lineCov">      34796 :                         if (wait_errno == EINTR)</span></a>
<a name="3337"><span class="lineNum">    3337 </span>                :            :                                 break;</a>
<a name="3338"><span class="lineNum">    3338 </span>        [<span class="branchCov" title="Branch 0 was taken 17333 times"> + </span><span class="branchCov" title="Branch 1 was taken 17334 times"> + </span>]:<span class="lineCov">      34667 :                         if (wait_nohang)</span></a>
<a name="3339"><span class="lineNum">    3339 </span>                :            :                                 break;</a>
<a name="3340"><span class="lineNum">    3340 </span>  [<span class="branchCov" title="Branch 0 was taken 17334 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 17334 times"> + </span>]:<span class="lineCov">      17334 :                         if (nprocs == 0 && wait_errno == ECHILD)</span></a>
<a name="3341"><span class="lineNum">    3341 </span>                :            :                                 return NULL;</a>
<a name="3342"><span class="lineNum">    3342 </span>                :            :                         /*</a>
<a name="3343"><span class="lineNum">    3343 </span>                :            :                          * If nprocs > 0, ECHILD is not expected,</a>
<a name="3344"><span class="lineNum">    3344 </span>                :            :                          * treat it as any other error here:</a>
<a name="3345"><span class="lineNum">    3345 </span>                :            :                          */</a>
<a name="3346"><span class="lineNum">    3346 </span>                :<span class="lineNoCov">          0 :                         errno = wait_errno;</span></a>
<a name="3347"><span class="lineNum">    3347 </span>                :<span class="lineNoCov">          0 :                         perror_msg_and_die("wait4(__WALL)");</span></a>
<a name="3348"><span class="lineNum">    3348 </span>                :            :                 }</a>
<a name="3349"><span class="lineNum">    3349 </span>                :            : </a>
<a name="3350"><span class="lineNum">    3350 </span>        [<span class="branchCov" title="Branch 0 was taken 152523508 times"> + </span><span class="branchCov" title="Branch 1 was taken 176338107 times"> + </span>]:<span class="lineCov">  328861615 :                 if (!pid)</span></a>
<a name="3351"><span class="lineNum">    3351 </span>                :            :                         break;</a>
<a name="3352"><span class="lineNum">    3352 </span>                :            : </a>
<a name="3353"><span class="lineNum">    3353 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 176338107 times"> + </span>]:<span class="lineCov">  176338107 :                 if (pid == popen_pid) {</span></a>
<a name="3354"><span class="lineNum">    3354 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                         if (!WIFSTOPPED(status))</span></a>
<a name="3355"><span class="lineNum">    3355 </span>                :<span class="lineNoCov">          0 :                                 popen_pid = 0;</span></a>
<a name="3356"><span class="lineNum">    3356 </span>                :            :                         break;</a>
<a name="3357"><span class="lineNum">    3357 </span>                :            :                 }</a>
<a name="3358"><span class="lineNum">    3358 </span>                :            : </a>
<a name="3359"><span class="lineNum">    3359 </span>        [<span class="branchCov" title="Branch 0 was taken 75431 times"> + </span><span class="branchCov" title="Branch 1 was taken 176262676 times"> + </span>]:<span class="lineCov">  176338107 :                 if (debug_flag)</span></a>
<a name="3360"><span class="lineNum">    3360 </span>                :<span class="lineCov">      75431 :                         print_debug_info(pid, status);</span></a>
<a name="3361"><span class="lineNum">    3361 </span>                :            : </a>
<a name="3362"><span class="lineNum">    3362 </span>                :            :                 /* Look up 'pid' in our table. */</a>
<a name="3363"><span class="lineNum">    3363 </span>                :<span class="lineCov">  176338107 :                 tcp = pid2tcb(pid);</span></a>
<a name="3364"><span class="lineNum">    3364 </span>                :            : </a>
<a name="3365"><span class="lineNum">    3365 </span>        [<span class="branchCov" title="Branch 0 was taken 29680 times"> + </span><span class="branchCov" title="Branch 1 was taken 176308427 times"> + </span>]:<span class="lineCov">  176338107 :                 if (!tcp) {</span></a>
<a name="3366"><span class="lineNum">    3366 </span>                :<span class="lineCov">      29680 :                         tcp = maybe_allocate_tcb(pid, status);</span></a>
<a name="3367"><span class="lineNum">    3367 </span>        [<span class="branchCov" title="Branch 0 was taken 199 times"> + </span><span class="branchCov" title="Branch 1 was taken 29481 times"> + </span>]:<span class="lineCov">      29680 :                         if (!tcp)</span></a>
<a name="3368"><span class="lineNum">    3368 </span>                :<span class="lineCov">        199 :                                 goto next_event_wait_next;</span></a>
<a name="3369"><span class="lineNum">    3369 </span>                :            :                 }</a>
<a name="3370"><span class="lineNum">    3370 </span>                :            : </a>
<a name="3371"><span class="lineNum">    3371 </span>        [<span class="branchCov" title="Branch 0 was taken 222158 times"> + </span><span class="branchCov" title="Branch 1 was taken 176115750 times"> + </span>]:<span class="lineCov">  176337908 :                 if (cflag) {</span></a>
<a name="3372"><span class="lineNum">    3372 </span>                :<span class="lineCov">     222158 :                         tcp->stime.tv_sec = ru.ru_stime.tv_sec;</span></a>
<a name="3373"><span class="lineNum">    3373 </span>                :<span class="lineCov">     222158 :                         tcp->stime.tv_nsec = ru.ru_stime.tv_usec * 1000;</span></a>
<a name="3374"><span class="lineNum">    3374 </span>                :            :                 }</a>
<a name="3375"><span class="lineNum">    3375 </span>                :            : </a>
<a name="3376"><span class="lineNum">    3376 </span>                :<span class="lineCov">  176337908 :                 tcb_wait_tab_check_size(wait_tab_pos);</span></a>
<a name="3377"><span class="lineNum">    3377 </span>                :            : </a>
<a name="3378"><span class="lineNum">    3378 </span>                :            :                 /* Initialise a new wait data structure.  */</a>
<a name="3379"><span class="lineNum">    3379 </span>                :<span class="lineCov">  176337908 :                 wd = tcb_wait_tab + wait_tab_pos;</span></a>
<a name="3380"><span class="lineNum">    3380 </span>                :<span class="lineCov">  176337908 :                 init_trace_wait_data(wd);</span></a>
<a name="3381"><span class="lineNum">    3381 </span>                :<span class="lineCov">  176337908 :                 wd->status = status;</span></a>
<a name="3382"><span class="lineNum">    3382 </span>                :            : </a>
<a name="3383"><span class="lineNum">    3383 </span>        [<span class="branchCov" title="Branch 0 was taken 10070 times"> + </span><span class="branchCov" title="Branch 1 was taken 176327838 times"> + </span>]:<span class="lineCov">  176337908 :                 if (WIFSIGNALED(status)) {</span></a>
<a name="3384"><span class="lineNum">    3384 </span>                :<span class="lineCov">      10070 :                         wd->te = TE_SIGNALLED;</span></a>
<a name="3385"><span class="lineNum">    3385 </span>        [<span class="branchCov" title="Branch 0 was taken 36729 times"> + </span><span class="branchCov" title="Branch 1 was taken 176291109 times"> + </span>]:<span class="lineCov">  176327838 :                 } else if (WIFEXITED(status)) {</span></a>
<a name="3386"><span class="lineNum">    3386 </span>                :<span class="lineCov">      36729 :                         wd->te = TE_EXITED;</span></a>
<a name="3387"><span class="lineNum">    3387 </span>                :            :                 } else {</a>
<a name="3388"><span class="lineNum">    3388 </span>                :            :                         /*</a>
<a name="3389"><span class="lineNum">    3389 </span>                :            :                          * As WCONTINUED flag has not been specified to wait4,</a>
<a name="3390"><span class="lineNum">    3390 </span>                :            :                          * it cannot be WIFCONTINUED(status), so the only case</a>
<a name="3391"><span class="lineNum">    3391 </span>                :            :                          * that remains is WIFSTOPPED(status).</a>
<a name="3392"><span class="lineNum">    3392 </span>                :            :                          */</a>
<a name="3393"><span class="lineNum">    3393 </span>                :            : </a>
<a name="3394"><span class="lineNum">    3394 </span>                :<span class="lineCov">  176291109 :                         const unsigned int sig = WSTOPSIG(status);</span></a>
<a name="3395"><span class="lineNum">    3395 </span>                :<span class="lineCov">  176291109 :                         const unsigned int event = (unsigned int) status >> 16;</span></a>
<a name="3396"><span class="lineNum">    3396 </span>                :            : </a>
<a name="3397"><span class="lineNum">    3397 </span>  [<span class="branchCov" title="Branch 0 was taken 176129619 times"> + </span><span class="branchCov" title="Branch 1 was taken 64403 times"> + </span><span class="branchCov" title="Branch 2 was taken 17394 times"> + </span><span class="branchCov" title="Branch 3 was taken 46668 times"> + </span> :<span class="lineCov">  176291109 :                         switch (event) {</span></a>
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 4 was taken 3544 times"> + </span><span class="branchCov" title="Branch 5 was taken 29481 times"> + </span>]
<a name="3398"><span class="lineNum">    3398 </span>                :<span class="lineCov">  176129619 :                         case 0:</span></a>
<a name="3399"><span class="lineNum">    3399 </span>                :            :                                 /*</a>
<a name="3400"><span class="lineNum">    3400 </span>                :            :                                  * Is this post-attach SIGSTOP?</a>
<a name="3401"><span class="lineNum">    3401 </span>                :            :                                  * Interestingly, the process may stop</a>
<a name="3402"><span class="lineNum">    3402 </span>                :            :                                  * with STOPSIG equal to some other signal</a>
<a name="3403"><span class="lineNum">    3403 </span>                :            :                                  * than SIGSTOP if we happened to attach</a>
<a name="3404"><span class="lineNum">    3404 </span>                :            :                                  * just before the process takes a signal.</a>
<a name="3405"><span class="lineNum">    3405 </span>                :            :                                  */</a>
<a name="3406"><span class="lineNum">    3406 </span>        [<span class="branchCov" title="Branch 0 was taken 59 times"> + </span><span class="branchCov" title="Branch 1 was taken 176129560 times"> + </span>]:<span class="lineCov">  176129619 :                                 if (sig == SIGSTOP &&</span></a>
<a name="3407"><span class="lineNum">    3407 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 59 times"> + </span>]:<span class="lineCov">         59 :                                     (tcp->flags & TCB_IGNORE_ONE_SIGSTOP)) {</span></a>
<a name="3408"><span class="lineNum">    3408 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                                         debug_func_msg("ignored SIGSTOP on "</span></a>
<a name="3409"><span class="lineNum">    3409 </span>                :            :                                                        "pid %d", tcp->pid);</a>
<a name="3410"><span class="lineNum">    3410 </span>                :<span class="lineNoCov">          0 :                                         tcp->flags &= ~TCB_IGNORE_ONE_SIGSTOP;</span></a>
<a name="3411"><span class="lineNum">    3411 </span>                :<span class="lineNoCov">          0 :                                         wd->te = TE_RESTART;</span></a>
<a name="3412"><span class="lineNum">    3412 </span>        [<span class="branchCov" title="Branch 0 was taken 176065228 times"> + </span><span class="branchCov" title="Branch 1 was taken 64391 times"> + </span>]:<span class="lineCov">  176129619 :                                 } else if (sig == syscall_trap_sig) {</span></a>
<a name="3413"><span class="lineNum">    3413 </span>                :<span class="lineCov">  176065228 :                                         wd->te = TE_SYSCALL_STOP;</span></a>
<a name="3414"><span class="lineNum">    3414 </span>                :            :                                 } else {</a>
<a name="3415"><span class="lineNum">    3415 </span>                :            :                                         /*</a>
<a name="3416"><span class="lineNum">    3416 </span>                :            :                                          * True if tracee is stopped by signal</a>
<a name="3417"><span class="lineNum">    3417 </span>                :            :                                          * (as opposed to "tracee received</a>
<a name="3418"><span class="lineNum">    3418 </span>                :            :                                          * signal").</a>
<a name="3419"><span class="lineNum">    3419 </span>                :            :                                          * TODO: shouldn't we check for</a>
<a name="3420"><span class="lineNum">    3420 </span>                :            :                                          * errno == EINVAL too?</a>
<a name="3421"><span class="lineNum">    3421 </span>                :            :                                          * We can get ESRCH instead, you know...</a>
<a name="3422"><span class="lineNum">    3422 </span>                :            :                                          */</a>
<a name="3423"><span class="lineNum">    3423 </span>                :<span class="lineCov">      64391 :                                         bool stopped = ptrace(PTRACE_GETSIGINFO,</span></a>
<a name="3424"><span class="lineNum">    3424 </span>                :            :                                                 pid, 0, &wd->si) < 0;</a>
<a name="3425"><span class="lineNum">    3425 </span>                :            : </a>
<a name="3426"><span class="lineNum">    3426 </span>                :<span class="lineCov">      64391 :                                         wd->te = stopped ? TE_GROUP_STOP</span></a>
<a name="3427"><span class="lineNum">    3427 </span>        [<span class="branchCov" title="Branch 0 was taken 64391 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      64391 :                                                          : TE_SIGNAL_DELIVERY_STOP;</span></a>
<a name="3428"><span class="lineNum">    3428 </span>                :            :                                 }</a>
<a name="3429"><span class="lineNum">    3429 </span>                :            :                                 break;</a>
<a name="3430"><span class="lineNum">    3430 </span>                :<span class="lineCov">      64403 :                         case PTRACE_EVENT_STOP:</span></a>
<a name="3431"><span class="lineNum">    3431 </span>                :            :                                 /*</a>
<a name="3432"><span class="lineNum">    3432 </span>                :            :                                  * PTRACE_INTERRUPT-stop or group-stop.</a>
<a name="3433"><span class="lineNum">    3433 </span>                :            :                                  * PTRACE_INTERRUPT-stop has sig == SIGTRAP here.</a>
<a name="3434"><span class="lineNum">    3434 </span>                :            :                                  */</a>
<a name="3435"><span class="lineNum">    3435 </span>        [<span class="branchCov" title="Branch 0 was taken 17383 times"> + </span><span class="branchCov" title="Branch 1 was taken 47020 times"> + </span>]:<span class="lineCov">      64403 :                                 switch (sig) {</span></a>
<a name="3436"><span class="lineNum">    3436 </span>                :<span class="lineCov">      17383 :                                 case SIGSTOP:</span></a>
<a name="3437"><span class="lineNum">    3437 </span>                :            :                                 case SIGTSTP:</a>
<a name="3438"><span class="lineNum">    3438 </span>                :            :                                 case SIGTTIN:</a>
<a name="3439"><span class="lineNum">    3439 </span>                :            :                                 case SIGTTOU:</a>
<a name="3440"><span class="lineNum">    3440 </span>                :<span class="lineCov">      17383 :                                         wd->te = TE_GROUP_STOP;</span></a>
<a name="3441"><span class="lineNum">    3441 </span>                :<span class="lineCov">      17383 :                                         break;</span></a>
<a name="3442"><span class="lineNum">    3442 </span>                :<span class="lineCov">      47020 :                                 default:</span></a>
<a name="3443"><span class="lineNum">    3443 </span>                :<span class="lineCov">      47020 :                                         wd->te = TE_RESTART;</span></a>
<a name="3444"><span class="lineNum">    3444 </span>                :            :                                 }</a>
<a name="3445"><span class="lineNum">    3445 </span>                :            :                                 break;</a>
<a name="3446"><span class="lineNum">    3446 </span>                :<span class="lineCov">      17394 :                         case PTRACE_EVENT_EXEC:</span></a>
<a name="3447"><span class="lineNum">    3447 </span>                :            :                                         /*</a>
<a name="3448"><span class="lineNum">    3448 </span>                :            :                                          * TODO: shouldn't we check for</a>
<a name="3449"><span class="lineNum">    3449 </span>                :            :                                          * errno == EINVAL here, too?</a>
<a name="3450"><span class="lineNum">    3450 </span>                :            :                                          * We can get ESRCH instead, you know...</a>
<a name="3451"><span class="lineNum">    3451 </span>                :            :                                          */</a>
<a name="3452"><span class="lineNum">    3452 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17394 times"> + </span>]:<span class="lineCov">      17394 :                                 if (ptrace(PTRACE_GETEVENTMSG, pid, NULL,</span></a>
<a name="3453"><span class="lineNum">    3453 </span>                :            :                                     &wd->msg) < 0)</a>
<a name="3454"><span class="lineNum">    3454 </span>                :<span class="lineNoCov">          0 :                                         wd->msg = 0;</span></a>
<a name="3455"><span class="lineNum">    3455 </span>                :            : </a>
<a name="3456"><span class="lineNum">    3456 </span>                :<span class="lineCov">      17394 :                                 wd->te = TE_STOP_BEFORE_EXECVE;</span></a>
<a name="3457"><span class="lineNum">    3457 </span>                :<span class="lineCov">      17394 :                                 break;</span></a>
<a name="3458"><span class="lineNum">    3458 </span>                :<span class="lineCov">      46668 :                         case PTRACE_EVENT_EXIT:</span></a>
<a name="3459"><span class="lineNum">    3459 </span>                :<span class="lineCov">      46668 :                                 wd->te = TE_STOP_BEFORE_EXIT;</span></a>
<a name="3460"><span class="lineNum">    3460 </span>                :<span class="lineCov">      46668 :                                 break;</span></a>
<a name="3461"><span class="lineNum">    3461 </span>                :<span class="lineCov">       3544 :                         case PTRACE_EVENT_SECCOMP:</span></a>
<a name="3462"><span class="lineNum">    3462 </span>                :<span class="lineCov">       3544 :                                 wd->te = TE_SECCOMP;</span></a>
<a name="3463"><span class="lineNum">    3463 </span>                :<span class="lineCov">       3544 :                                 break;</span></a>
<a name="3464"><span class="lineNum">    3464 </span>                :<span class="lineCov">      29481 :                         default:</span></a>
<a name="3465"><span class="lineNum">    3465 </span>                :<span class="lineCov">      29481 :                                 wd->te = TE_RESTART;</span></a>
<a name="3466"><span class="lineNum">    3466 </span>                :            :                         }</a>
<a name="3467"><span class="lineNum">    3467 </span>                :            :                 }</a>
<a name="3468"><span class="lineNum">    3468 </span>                :            : </a>
<a name="3469"><span class="lineNum">    3469 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 176337908 times"> + </span>]:<span class="lineCov">  176337908 :                 if (!wd->te)</span></a>
<a name="3470"><span class="lineNum">    3470 </span>                :<span class="lineNoCov">          0 :                         error_func_msg("Tracing event hasn't been determined "</span></a>
<a name="3471"><span class="lineNum">    3471 </span>                :            :                                        "for pid %d, status %0#x", pid, status);</a>
<a name="3472"><span class="lineNum">    3472 </span>                :            : </a>
<a name="3473"><span class="lineNum">    3473 </span>        [<span class="branchCov" title="Branch 0 was taken 105 times"> + </span><span class="branchCov" title="Branch 1 was taken 176337803 times"> + </span>]:<span class="lineCov">  176337908 :                 if (!list_is_empty(&tcp->wait_list)) {</span></a>
<a name="3474"><span class="lineNum">    3474 </span>                :<span class="lineCov">        105 :                         wait_extra_data_idx = wait_tab_pos;</span></a>
<a name="3475"><span class="lineNum">    3475 </span>                :<span class="lineCov">        105 :                         extra_tcp = tcp;</span></a>
<a name="3476"><span class="lineNum">    3476 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 105 times"> + </span>]:<span class="lineCov">        105 :                         debug_func_msg("queued extra pid %d", tcp->pid);</span></a>
<a name="3477"><span class="lineNum">    3477 </span>                :            :                 } else {</a>
<a name="3478"><span class="lineNum">    3478 </span>                :<span class="lineCov">  176337803 :                         tcp->wait_data_idx = wait_tab_pos;</span></a>
<a name="3479"><span class="lineNum">    3479 </span>        [<span class="branchCov" title="Branch 0 was taken 75431 times"> + </span><span class="branchCov" title="Branch 1 was taken 176262372 times"> + </span>]:<span class="lineCov">  176337803 :                         list_append(&pending_tcps, &tcp->wait_list);</span></a>
<a name="3480"><span class="lineNum">    3480 </span>        [<span class="branchCov" title="Branch 0 was taken 75431 times"> + </span><span class="branchCov" title="Branch 1 was taken 176262372 times"> + </span>]:<span class="lineCov">  176337803 :                         debug_func_msg("queued pid %d", tcp->pid);</span></a>
<a name="3481"><span class="lineNum">    3481 </span>                :            :                 }</a>
<a name="3482"><span class="lineNum">    3482 </span>                :            : </a>
<a name="3483"><span class="lineNum">    3483 </span>                :<span class="lineCov">  176337908 :                 wait_tab_pos++;</span></a>
<a name="3484"><span class="lineNum">    3484 </span>                :            : </a>
<a name="3485"><span class="lineNum">    3485 </span>        [<span class="branchCov" title="Branch 0 was taken 105 times"> + </span><span class="branchCov" title="Branch 1 was taken 176337803 times"> + </span>]:<span class="lineCov">  176337908 :                 if (extra_tcp)</span></a>
<a name="3486"><span class="lineNum">    3486 </span>                :            :                         break;</a>
<a name="3487"><span class="lineNum">    3487 </span>                :            : </a>
<a name="3488"><span class="lineNum">    3488 </span>                :<span class="lineCov">  176337803 : next_event_wait_next:</span></a>
<a name="3489"><span class="lineNum">    3489 </span>        [<span class="branchCov" title="Branch 0 was taken 176115844 times"> + </span><span class="branchCov" title="Branch 1 was taken 222158 times"> + </span>]:<span class="lineCov">  352453846 :                 pid = wait4(-1, &status, __WALL | WNOHANG, (cflag ? &ru : NULL));</span></a>
<a name="3490"><span class="lineNum">    3490 </span>                :<span class="lineCov">  176338002 :                 wait_errno = errno;</span></a>
<a name="3491"><span class="lineNum">    3491 </span>                :<span class="lineCov">  176338002 :                 wait_nohang = true;</span></a>
<a name="3492"><span class="lineNum">    3492 </span>                :            :         }</a>
<a name="3493"><span class="lineNum">    3493 </span>                :            : </a>
<a name="3494"><span class="lineNum">    3494 </span>                :<span class="lineCov">  152541075 : next_event_get_tcp:</span></a>
<a name="3495"><span class="lineNum">    3495 </span>                :<span class="lineCov">  176337934 :         elem = list_remove_head(&pending_tcps);</span></a>
<a name="3496"><span class="lineNum">    3496 </span>                :            : </a>
<a name="3497"><span class="lineNum">    3497 </span>        [<span class="branchCov" title="Branch 0 was taken 131 times"> + </span><span class="branchCov" title="Branch 1 was taken 176337803 times"> + </span>]:<span class="lineCov">  176337934 :         if (!elem) {</span></a>
<a name="3498"><span class="lineNum">    3498 </span>                :<span class="lineCov">        131 :                 tcb_wait_tab_check_size(0);</span></a>
<a name="3499"><span class="lineNum">    3499 </span>                :<span class="lineCov">        131 :                 memset(tcb_wait_tab, 0, sizeof(*tcb_wait_tab));</span></a>
<a name="3500"><span class="lineNum">    3500 </span>                :<span class="lineCov">        131 :                 tcb_wait_tab->te = TE_NEXT;</span></a>
<a name="3501"><span class="lineNum">    3501 </span>                :            : </a>
<a name="3502"><span class="lineNum">    3502 </span>                :<span class="lineCov">        131 :                 return tcb_wait_tab;</span></a>
<a name="3503"><span class="lineNum">    3503 </span>                :            :         } else {</a>
<a name="3504"><span class="lineNum">    3504 </span>                :<span class="lineCov">  176337803 :                 tcp = list_elem(elem, struct tcb, wait_list);</span></a>
<a name="3505"><span class="lineNum">    3505 </span>        [<span class="branchCov" title="Branch 0 was taken 176262372 times"> + </span><span class="branchCov" title="Branch 1 was taken 75431 times"> + </span>]:<span class="lineCov">  176337803 :                 debug_func_msg("dequeued pid %d", tcp->pid);</span></a>
<a name="3506"><span class="lineNum">    3506 </span>                :            :         }</a>
<a name="3507"><span class="lineNum">    3507 </span>                :            : </a>
<a name="3508"><span class="lineNum">    3508 </span>                :<span class="lineCov">  176262372 : next_event_exit:</span></a>
<a name="3509"><span class="lineNum">    3509 </span>                :            :         /* Is this the very first time we see this tracee stopped? */</a>
<a name="3510"><span class="lineNum">    3510 </span>        [<span class="branchCov" title="Branch 0 was taken 46824 times"> + </span><span class="branchCov" title="Branch 1 was taken 176291084 times"> + </span>]:<span class="lineCov">  176337908 :         if (tcp->flags & TCB_STARTUP)</span></a>
<a name="3511"><span class="lineNum">    3511 </span>                :<span class="lineCov">      46824 :                 startup_tcb(tcp);</span></a>
<a name="3512"><span class="lineNum">    3512 </span>                :            : </a>
<a name="3513"><span class="lineNum">    3513 </span>                :<span class="lineCov">  176337908 :         clear_regs(tcp);</span></a>
<a name="3514"><span class="lineNum">    3514 </span>                :            : </a>
<a name="3515"><span class="lineNum">    3515 </span>                :            :         /* Set current output file */</a>
<a name="3516"><span class="lineNum">    3516 </span>                :<span class="lineCov">  176337908 :         set_current_tcp(tcp);</span></a>
<a name="3517"><span class="lineNum">    3517 </span>                :            : </a>
<a name="3518"><span class="lineNum">    3518 </span>                :<span class="lineCov">  176337908 :         return tcb_wait_tab + tcp->wait_data_idx;</span></a>
<a name="3519"><span class="lineNum">    3519 </span>                :            : }</a>
<a name="3520"><span class="lineNum">    3520 </span>                :            : </a>
<a name="3521"><span class="lineNum">    3521 </span>                :            : static int</a>
<a name="3522"><span class="lineNum">    3522 </span>                :<span class="lineCov">  176068769 : trace_syscall(struct tcb *tcp, unsigned int *sig)</span></a>
<a name="3523"><span class="lineNum">    3523 </span>                :            : {</a>
<a name="3524"><span class="lineNum">    3524 </span>        [<span class="branchCov" title="Branch 0 was taken 88049616 times"> + </span><span class="branchCov" title="Branch 1 was taken 88019153 times"> + </span>]:<span class="lineCov">  176068769 :         if (entering(tcp)) {</span></a>
<a name="3525"><span class="lineNum">    3525 </span>                :<span class="lineCov">   88049616 :                 int res = syscall_entering_decode(tcp);</span></a>
<a name="3526"><span class="lineNum">    3526 </span>     [<span class="branchCov" title="Branch 0 was taken 88049518 times"> + </span><span class="branchCov" title="Branch 1 was taken 98 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span>]:<span class="lineCov">   88049616 :                 switch (res) {</span></a>
<a name="3527"><span class="lineNum">    3527 </span>                :            :                 case 0:</a>
<a name="3528"><span class="lineNum">    3528 </span>                :            :                         return 0;</a>
<a name="3529"><span class="lineNum">    3529 </span>                :<span class="lineCov">   88049518 :                 case 1:</span></a>
<a name="3530"><span class="lineNum">    3530 </span>                :<span class="lineCov">   88049518 :                         res = syscall_entering_trace(tcp, sig);</span></a>
<a name="3531"><span class="lineNum">    3531 </span>                :            :                 }</a>
<a name="3532"><span class="lineNum">    3532 </span>                :<span class="lineCov">   88049616 :                 syscall_entering_finish(tcp, res);</span></a>
<a name="3533"><span class="lineNum">    3533 </span>                :<span class="lineCov">   88049616 :                 return res;</span></a>
<a name="3534"><span class="lineNum">    3534 </span>                :            :         } else {</a>
<a name="3535"><span class="lineNum">    3535 </span>                :<span class="lineCov">   88019153 :                 struct timespec ts = {};</span></a>
<a name="3536"><span class="lineNum">    3536 </span>                :<span class="lineCov">   88019153 :                 int res = syscall_exiting_decode(tcp, &ts);</span></a>
<a name="3537"><span class="lineNum">    3537 </span>        [<span class="branchCov" title="Branch 0 was taken 1144821 times"> + </span><span class="branchCov" title="Branch 1 was taken 86874332 times"> + </span>]:<span class="lineCov">   88019153 :                 if (res != 0) {</span></a>
<a name="3538"><span class="lineNum">    3538 </span>                :<span class="lineCov">    1144821 :                         res = syscall_exiting_trace(tcp, &ts, res);</span></a>
<a name="3539"><span class="lineNum">    3539 </span>                :            :                 }</a>
<a name="3540"><span class="lineNum">    3540 </span>                :<span class="lineCov">   88019153 :                 syscall_exiting_finish(tcp);</span></a>
<a name="3541"><span class="lineNum">    3541 </span>                :<span class="lineCov">   88019153 :                 return res;</span></a>
<a name="3542"><span class="lineNum">    3542 </span>                :            :         }</a>
<a name="3543"><span class="lineNum">    3543 </span>                :            : }</a>
<a name="3544"><span class="lineNum">    3544 </span>                :            : </a>
<a name="3545"><span class="lineNum">    3545 </span>                :            : /* Returns true iff the main trace loop has to continue. */</a>
<a name="3546"><span class="lineNum">    3546 </span>                :            : static bool</a>
<a name="3547"><span class="lineNum">    3547 </span>                :<span class="lineCov">  176355513 : dispatch_event(const struct tcb_wait_data *wd)</span></a>
<a name="3548"><span class="lineNum">    3548 </span>                :            : {</a>
<a name="3549"><span class="lineNum">    3549 </span>                :<span class="lineCov">  176355513 :         unsigned int restart_op;</span></a>
<a name="3550"><span class="lineNum">    3550 </span>                :<span class="lineCov">  176355513 :         unsigned int restart_sig = 0;</span></a>
<a name="3551"><span class="lineNum">    3551 </span>        [<span class="branchCov" title="Branch 0 was taken 176338175 times"> + </span><span class="branchCov" title="Branch 1 was taken 17338 times"> + </span>]:<span class="lineCov">  176355513 :         enum trace_event te = wd ? wd->te : TE_BREAK;</span></a>
<a name="3552"><span class="lineNum">    3552 </span>                :            :         /*</a>
<a name="3553"><span class="lineNum">    3553 </span>                :            :          * Copy wd->status to a non-const variable to workaround glibc bugs</a>
<a name="3554"><span class="lineNum">    3554 </span>                :            :          * around union wait fixed by glibc commit glibc-2.24~391</a>
<a name="3555"><span class="lineNum">    3555 </span>                :            :          */</a>
<a name="3556"><span class="lineNum">    3556 </span>        [<span class="branchCov" title="Branch 0 was taken 176338175 times"> + </span><span class="branchCov" title="Branch 1 was taken 17338 times"> + </span>]:<span class="lineCov">  176355513 :         int status = wd ? wd->status : 0;</span></a>
<a name="3557"><span class="lineNum">    3557 </span>                :            : </a>
<a name="3558"><span class="lineNum">    3558 </span>  [<span class="branchCov" title="Branch 0 was taken 176338177 times"> + </span><span class="branchCov" title="Branch 1 was taken 17336 times"> + </span><span class="branchCov" title="Branch 2 was taken 7140 times"> + </span><span class="branchCov" title="Branch 3 was taken 176331037 times"> + </span>]:<span class="lineCov">  176355513 :         if (current_tcp && has_seccomp_filter(current_tcp))</span></a>
<a name="3559"><span class="lineNum">    3559 </span>                :<span class="lineCov">       7140 :                 restart_op = seccomp_filter_restart_operator(current_tcp);</span></a>
<a name="3560"><span class="lineNum">    3560 </span>                :            :         else</a>
<a name="3561"><span class="lineNum">    3561 </span>                :            :                 restart_op = PTRACE_SYSCALL;</a>
<a name="3562"><span class="lineNum">    3562 </span>                :            : </a>
<a name="3563"><span class="lineNum">    3563 </span>  [<span class="branchCov" title="Branch 0 was taken 131 times"> + </span><span class="branchCov" title="Branch 1 was taken 3544 times"> + </span><span class="branchCov" title="Branch 2 was taken 176065228 times"> + </span><span class="branchCov" title="Branch 3 was taken 64391 times"> + </span> :<span class="lineCov">  176355513 :         switch (te) {</span></a>
<span class="lineNum">         </span><span class="branchCov" title="Branch 4 was taken 10070 times"> + </span><span class="branchCov" title="Branch 5 was taken 17383 times"> + </span><span class="branchCov" title="Branch 6 was taken 36729 times"> + </span><span class="branchCov" title="Branch 7 was taken 17394 times"> + </span><span class="branchCov" title="Branch 8 was taken 46668 times"> + </span> 
<span class="lineNum">         </span>         <span class="branchCov" title="Branch 9 was taken 76637 times"> + </span><span class="branchCov" title="Branch 10 was taken 17338 times"> + </span>]
<a name="3564"><span class="lineNum">    3564 </span>                :            :         case TE_BREAK:</a>
<a name="3565"><span class="lineNum">    3565 </span>                :            :                 return false;</a>
<a name="3566"><span class="lineNum">    3566 </span>                :            : </a>
<a name="3567"><span class="lineNum">    3567 </span>                :<span class="lineCov">        131 :         case TE_NEXT:</span></a>
<a name="3568"><span class="lineNum">    3568 </span>                :<span class="lineCov">        131 :                 return true;</span></a>
<a name="3569"><span class="lineNum">    3569 </span>                :            : </a>
<a name="3570"><span class="lineNum">    3570 </span>                :            :         case TE_RESTART:</a>
<a name="3571"><span class="lineNum">    3571 </span>                :            :                 break;</a>
<a name="3572"><span class="lineNum">    3572 </span>                :            : </a>
<a name="3573"><span class="lineNum">    3573 </span>                :<span class="lineCov">       3544 :         case TE_SECCOMP:</span></a>
<a name="3574"><span class="lineNum">    3574 </span>        [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 3541 times"> + </span>]:<span class="lineCov">       3544 :                 if (!has_seccomp_filter(current_tcp)) {</span></a>
<a name="3575"><span class="lineNum">    3575 </span>                :            :                         /*</a>
<a name="3576"><span class="lineNum">    3576 </span>                :            :                          * We don't know if forks/clones have a seccomp filter</a>
<a name="3577"><span class="lineNum">    3577 </span>                :            :                          * when they are created, but we can detect it when we</a>
<a name="3578"><span class="lineNum">    3578 </span>                :            :                          * have a seccomp-stop.</a>
<a name="3579"><span class="lineNum">    3579 </span>                :            :                          * In such a case, if !seccomp_before_sysentry, we have</a>
<a name="3580"><span class="lineNum">    3580 </span>                :            :                          * already processed the syscall entry, so we avoid</a>
<a name="3581"><span class="lineNum">    3581 </span>                :            :                          * processing it a second time.</a>
<a name="3582"><span class="lineNum">    3582 </span>                :            :                          */</a>
<a name="3583"><span class="lineNum">    3583 </span>                :<span class="lineCov">          3 :                         current_tcp->flags |= TCB_SECCOMP_FILTER;</span></a>
<a name="3584"><span class="lineNum">    3584 </span>                :<span class="lineCov">          3 :                         restart_op = PTRACE_SYSCALL;</span></a>
<a name="3585"><span class="lineNum">    3585 </span>                :<span class="lineCov">          3 :                         break;</span></a>
<a name="3586"><span class="lineNum">    3586 </span>                :            :                 }</a>
<a name="3587"><span class="lineNum">    3587 </span>                :            : </a>
<a name="3588"><span class="lineNum">    3588 </span>        [<span class="branchCov" title="Branch 0 was taken 3541 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">       3541 :                 if (seccomp_before_sysentry) {</span></a>
<a name="3589"><span class="lineNum">    3589 </span>                :            :                         restart_op = PTRACE_SYSCALL;</a>
<a name="3590"><span class="lineNum">    3590 </span>                :            :                         break;</a>
<a name="3591"><span class="lineNum">    3591 </span>                :            :                 }</a>
<a name="3592"><span class="lineNum">    3592 </span>                :<span class="lineCov">  176068769 :                 ATTRIBUTE_FALLTHROUGH;</span></a>
<a name="3593"><span class="lineNum">    3593 </span>                :            : </a>
<a name="3594"><span class="lineNum">    3594 </span>                :            :         case TE_SYSCALL_STOP:</a>
<a name="3595"><span class="lineNum">    3595 </span>        [<span class="branchCov" title="Branch 0 was taken 176068671 times"> + </span><span class="branchCov" title="Branch 1 was taken 98 times"> + </span>]:<span class="lineCov">  176068769 :                 if (trace_syscall(current_tcp, &restart_sig) < 0) {</span></a>
<a name="3596"><span class="lineNum">    3596 </span>                :            :                         /*</a>
<a name="3597"><span class="lineNum">    3597 </span>                :            :                          * ptrace() failed in trace_syscall().</a>
<a name="3598"><span class="lineNum">    3598 </span>                :            :                          * Likely a result of process disappearing mid-flight.</a>
<a name="3599"><span class="lineNum">    3599 </span>                :            :                          * Observed case: exit_group() or SIGKILL terminating</a>
<a name="3600"><span class="lineNum">    3600 </span>                :            :                          * all processes in thread group.</a>
<a name="3601"><span class="lineNum">    3601 </span>                :            :                          * We assume that ptrace error was caused by process death.</a>
<a name="3602"><span class="lineNum">    3602 </span>                :            :                          * We used to detach(current_tcp) here, but since we no</a>
<a name="3603"><span class="lineNum">    3603 </span>                :            :                          * longer implement "detach before death" policy/hack,</a>
<a name="3604"><span class="lineNum">    3604 </span>                :            :                          * we can let this process to report its death to us</a>
<a name="3605"><span class="lineNum">    3605 </span>                :            :                          * normally, via WIFEXITED or WIFSIGNALED wait status.</a>
<a name="3606"><span class="lineNum">    3606 </span>                :            :                          */</a>
<a name="3607"><span class="lineNum">    3607 </span>                :            :                         return true;</a>
<a name="3608"><span class="lineNum">    3608 </span>                :            :                 }</a>
<a name="3609"><span class="lineNum">    3609 </span>        [<span class="branchCov" title="Branch 0 was taken 7084 times"> + </span><span class="branchCov" title="Branch 1 was taken 176061587 times"> + </span>]:<span class="lineCov">  176068671 :                 if (has_seccomp_filter(current_tcp)) {</span></a>
<a name="3610"><span class="lineNum">    3610 </span>                :            :                         /*</a>
<a name="3611"><span class="lineNum">    3611 </span>                :            :                          * Syscall and seccomp stops can happen in different</a>
<a name="3612"><span class="lineNum">    3612 </span>                :            :                          * orders depending on kernel.  strace tests this in</a>
<a name="3613"><span class="lineNum">    3613 </span>                :            :                          * check_seccomp_order_tracer().</a>
<a name="3614"><span class="lineNum">    3614 </span>                :            :                          *</a>
<a name="3615"><span class="lineNum">    3615 </span>                :            :                          * Linux 3.5--4.7:</a>
<a name="3616"><span class="lineNum">    3616 </span>                :            :                          * (seccomp-stop before syscall-entry-stop)</a>
<a name="3617"><span class="lineNum">    3617 </span>                :            :                          *         +--> seccomp-stop ->-PTRACE_SYSCALL->-+</a>
<a name="3618"><span class="lineNum">    3618 </span>                :            :                          *         |                                     |</a>
<a name="3619"><span class="lineNum">    3619 </span>                :            :                          *     PTRACE_CONT                   syscall-entry-stop</a>
<a name="3620"><span class="lineNum">    3620 </span>                :            :                          *         |                                     |</a>
<a name="3621"><span class="lineNum">    3621 </span>                :            :                          * syscall-exit-stop <---PTRACE_SYSCALL-----<----+</a>
<a name="3622"><span class="lineNum">    3622 </span>                :            :                          *</a>
<a name="3623"><span class="lineNum">    3623 </span>                :            :                          * Linux 4.8+:</a>
<a name="3624"><span class="lineNum">    3624 </span>                :            :                          * (seccomp-stop after syscall-entry-stop)</a>
<a name="3625"><span class="lineNum">    3625 </span>                :            :                          *                 syscall-entry-stop</a>
<a name="3626"><span class="lineNum">    3626 </span>                :            :                          *</a>
<a name="3627"><span class="lineNum">    3627 </span>                :            :                          *         +---->-----PTRACE_CONT---->----+</a>
<a name="3628"><span class="lineNum">    3628 </span>                :            :                          *         |                              |</a>
<a name="3629"><span class="lineNum">    3629 </span>                :            :                          *  syscall-exit-stop               seccomp-stop</a>
<a name="3630"><span class="lineNum">    3630 </span>                :            :                          *         |                              |</a>
<a name="3631"><span class="lineNum">    3631 </span>                :            :                          *         +----<----PTRACE_SYSCALL---<---+</a>
<a name="3632"><span class="lineNum">    3632 </span>                :            :                          *</a>
<a name="3633"><span class="lineNum">    3633 </span>                :            :                          * Note in Linux 4.8+, we restart in PTRACE_CONT</a>
<a name="3634"><span class="lineNum">    3634 </span>                :            :                          * after syscall-exit to skip the syscall-entry-stop.</a>
<a name="3635"><span class="lineNum">    3635 </span>                :            :                          * The next seccomp-stop will be treated as a syscall</a>
<a name="3636"><span class="lineNum">    3636 </span>                :            :                          * entry.</a>
<a name="3637"><span class="lineNum">    3637 </span>                :            :                          *</a>
<a name="3638"><span class="lineNum">    3638 </span>                :            :                          * The line below implements this behavior.</a>
<a name="3639"><span class="lineNum">    3639 </span>                :            :                          * Note that exiting(current_tcp) actually marks</a>
<a name="3640"><span class="lineNum">    3640 </span>                :            :                          * a syscall-entry-stop because the flag was inverted</a>
<a name="3641"><span class="lineNum">    3641 </span>                :            :                          * in the above call to trace_syscall.</a>
<a name="3642"><span class="lineNum">    3642 </span>                :            :                          */</a>
<a name="3643"><span class="lineNum">    3643 </span>        [<span class="branchCov" title="Branch 0 was taken 3543 times"> + </span><span class="branchCov" title="Branch 1 was taken 3541 times"> + </span>]:<span class="lineCov">       7084 :                         restart_op = exiting(current_tcp) ? PTRACE_SYSCALL : PTRACE_CONT;</span></a>
<a name="3644"><span class="lineNum">    3644 </span>                :            :                 }</a>
<a name="3645"><span class="lineNum">    3645 </span>                :            :                 break;</a>
<a name="3646"><span class="lineNum">    3646 </span>                :            : </a>
<a name="3647"><span class="lineNum">    3647 </span>                :<span class="lineCov">      64391 :         case TE_SIGNAL_DELIVERY_STOP:</span></a>
<a name="3648"><span class="lineNum">    3648 </span>                :<span class="lineCov">      64391 :                 restart_sig = WSTOPSIG(status);</span></a>
<a name="3649"><span class="lineNum">    3649 </span>                :<span class="lineCov">      64391 :                 print_stopped(current_tcp, &wd->si, restart_sig);</span></a>
<a name="3650"><span class="lineNum">    3650 </span>                :<span class="lineCov">      64391 :                 break;</span></a>
<a name="3651"><span class="lineNum">    3651 </span>                :            : </a>
<a name="3652"><span class="lineNum">    3652 </span>                :<span class="lineCov">      10070 :         case TE_SIGNALLED:</span></a>
<a name="3653"><span class="lineNum">    3653 </span>                :<span class="lineCov">      10070 :                 print_signalled(current_tcp, current_tcp->pid, status);</span></a>
<a name="3654"><span class="lineNum">    3654 </span>                :<span class="lineCov">      10070 :                 droptcb(current_tcp);</span></a>
<a name="3655"><span class="lineNum">    3655 </span>                :<span class="lineCov">      10070 :                 return true;</span></a>
<a name="3656"><span class="lineNum">    3656 </span>                :            : </a>
<a name="3657"><span class="lineNum">    3657 </span>                :<span class="lineCov">      17383 :         case TE_GROUP_STOP:</span></a>
<a name="3658"><span class="lineNum">    3658 </span>                :<span class="lineCov">      17383 :                 restart_sig = WSTOPSIG(status);</span></a>
<a name="3659"><span class="lineNum">    3659 </span>                :<span class="lineCov">      17383 :                 print_stopped(current_tcp, NULL, restart_sig);</span></a>
<a name="3660"><span class="lineNum">    3660 </span>        [<span class="branchCov" title="Branch 0 was taken 17383 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">      17383 :                 if (use_seize) {</span></a>
<a name="3661"><span class="lineNum">    3661 </span>                :            :                         /*</a>
<a name="3662"><span class="lineNum">    3662 </span>                :            :                          * This ends ptrace-stop, but does *not* end group-stop.</a>
<a name="3663"><span class="lineNum">    3663 </span>                :            :                          * This makes stopping signals work properly on straced</a>
<a name="3664"><span class="lineNum">    3664 </span>                :            :                          * process (that is, process really stops. It used to</a>
<a name="3665"><span class="lineNum">    3665 </span>                :            :                          * continue to run).</a>
<a name="3666"><span class="lineNum">    3666 </span>                :            :                          */</a>
<a name="3667"><span class="lineNum">    3667 </span>                :<span class="lineCov">      17383 :                         restart_op = PTRACE_LISTEN;</span></a>
<a name="3668"><span class="lineNum">    3668 </span>                :<span class="lineCov">      17383 :                         restart_sig = 0;</span></a>
<a name="3669"><span class="lineNum">    3669 </span>                :            :                 }</a>
<a name="3670"><span class="lineNum">    3670 </span>                :            :                 break;</a>
<a name="3671"><span class="lineNum">    3671 </span>                :            : </a>
<a name="3672"><span class="lineNum">    3672 </span>                :<span class="lineCov">      36729 :         case TE_EXITED:</span></a>
<a name="3673"><span class="lineNum">    3673 </span>                :<span class="lineCov">      36729 :                 print_exited(current_tcp, current_tcp->pid, status);</span></a>
<a name="3674"><span class="lineNum">    3674 </span>                :<span class="lineCov">      36729 :                 droptcb(current_tcp);</span></a>
<a name="3675"><span class="lineNum">    3675 </span>                :<span class="lineCov">      36729 :                 return true;</span></a>
<a name="3676"><span class="lineNum">    3676 </span>                :            : </a>
<a name="3677"><span class="lineNum">    3677 </span>                :<span class="lineCov">      17394 :         case TE_STOP_BEFORE_EXECVE:</span></a>
<a name="3678"><span class="lineNum">    3678 </span>                :            :                 /* The syscall succeeded, clear the flag.  */</a>
<a name="3679"><span class="lineNum">    3679 </span>                :<span class="lineCov">      17394 :                 current_tcp->flags &= ~TCB_CHECK_EXEC_SYSCALL;</span></a>
<a name="3680"><span class="lineNum">    3680 </span>                :            :                 /*</a>
<a name="3681"><span class="lineNum">    3681 </span>                :            :                  * Check that we are inside syscall now (next event after</a>
<a name="3682"><span class="lineNum">    3682 </span>                :            :                  * PTRACE_EVENT_EXEC should be for syscall exiting).  If it is</a>
<a name="3683"><span class="lineNum">    3683 </span>                :            :                  * not the case, we might have a situation when we attach to a</a>
<a name="3684"><span class="lineNum">    3684 </span>                :            :                  * process and the first thing we see is a PTRACE_EVENT_EXEC</a>
<a name="3685"><span class="lineNum">    3685 </span>                :            :                  * and all the following syscall state tracking is screwed up</a>
<a name="3686"><span class="lineNum">    3686 </span>                :            :                  * otherwise.</a>
<a name="3687"><span class="lineNum">    3687 </span>                :            :                  */</a>
<a name="3688"><span class="lineNum">    3688 </span>  [<span class="branchCov" title="Branch 0 was taken 17375 times"> + </span><span class="branchCov" title="Branch 1 was taken 19 times"> + </span><span class="branchNoCov" title="Branch 2 was not taken"> - </span><span class="branchCov" title="Branch 3 was taken 17375 times"> + </span>]:<span class="lineCov">      17394 :                 if (!maybe_switch_current_tcp() && entering(current_tcp)) {</span></a>
<a name="3689"><span class="lineNum">    3689 </span>                :<span class="lineNoCov">          0 :                         int ret;</span></a>
<a name="3690"><span class="lineNum">    3690 </span>                :            : </a>
<a name="3691"><span class="lineNum">    3691 </span>                :<span class="lineNoCov">          0 :                         error_msg("Stray PTRACE_EVENT_EXEC from pid %d"</span></a>
<a name="3692"><span class="lineNum">    3692 </span>                :            :                                   ", trying to recover...",</a>
<a name="3693"><span class="lineNum">    3693 </span>                :            :                                   current_tcp->pid);</a>
<a name="3694"><span class="lineNum">    3694 </span>                :            : </a>
<a name="3695"><span class="lineNum">    3695 </span>                :<span class="lineNoCov">          0 :                         current_tcp->flags |= TCB_RECOVERING;</span></a>
<a name="3696"><span class="lineNum">    3696 </span>                :<span class="lineNoCov">          0 :                         ret = trace_syscall(current_tcp, &restart_sig);</span></a>
<a name="3697"><span class="lineNum">    3697 </span>                :<span class="lineNoCov">          0 :                         current_tcp->flags &= ~TCB_RECOVERING;</span></a>
<a name="3698"><span class="lineNum">    3698 </span>                :            : </a>
<a name="3699"><span class="lineNum">    3699 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :                         if (ret < 0) {</span></a>
<a name="3700"><span class="lineNum">    3700 </span>                :            :                                 /* The reason is described in TE_SYSCALL_STOP */</a>
<a name="3701"><span class="lineNum">    3701 </span>                :            :                                 return true;</a>
<a name="3702"><span class="lineNum">    3702 </span>                :            :                         }</a>
<a name="3703"><span class="lineNum">    3703 </span>                :            :                 }</a>
<a name="3704"><span class="lineNum">    3704 </span>                :            : </a>
<a name="3705"><span class="lineNum">    3705 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 17390 times"> + </span>]:<span class="lineCov">      17394 :                 if (detach_on_execve) {</span></a>
<a name="3706"><span class="lineNum">    3706 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :                         if (current_tcp->flags & TCB_SKIP_DETACH_ON_FIRST_EXEC) {</span></a>
<a name="3707"><span class="lineNum">    3707 </span>                :<span class="lineCov">          2 :                                 current_tcp->flags &= ~TCB_SKIP_DETACH_ON_FIRST_EXEC;</span></a>
<a name="3708"><span class="lineNum">    3708 </span>                :            :                         } else {</a>
<a name="3709"><span class="lineNum">    3709 </span>                :<span class="lineCov">          2 :                                 detach(current_tcp); /* do "-b execve" thingy */</span></a>
<a name="3710"><span class="lineNum">    3710 </span>                :<span class="lineCov">          2 :                                 return true;</span></a>
<a name="3711"><span class="lineNum">    3711 </span>                :            :                         }</a>
<a name="3712"><span class="lineNum">    3712 </span>                :            :                 }</a>
<a name="3713"><span class="lineNum">    3713 </span>                :            :                 break;</a>
<a name="3714"><span class="lineNum">    3714 </span>                :            : </a>
<a name="3715"><span class="lineNum">    3715 </span>                :<span class="lineCov">      46668 :         case TE_STOP_BEFORE_EXIT:</span></a>
<a name="3716"><span class="lineNum">    3716 </span>                :<span class="lineCov">      46668 :                 print_event_exit(current_tcp);</span></a>
<a name="3717"><span class="lineNum">    3717 </span>                :<span class="lineCov">      46668 :                 break;</span></a>
<a name="3718"><span class="lineNum">    3718 </span>                :            :         }</a>
<a name="3719"><span class="lineNum">    3719 </span>                :            : </a>
<a name="3720"><span class="lineNum">    3720 </span>                :            :         /* We handled quick cases, we are permitted to interrupt now. */</a>
<a name="3721"><span class="lineNum">    3721 </span>        [<span class="branchCov" title="Branch 0 was taken 176291145 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">  176291145 :         if (interrupted)</span></a>
<a name="3722"><span class="lineNum">    3722 </span>                :            :                 return false;</a>
<a name="3723"><span class="lineNum">    3723 </span>                :            : </a>
<a name="3724"><span class="lineNum">    3724 </span>                :            :         /* If the process is being delayed, do not ptrace_restart just yet */</a>
<a name="3725"><span class="lineNum">    3725 </span>        [<span class="branchCov" title="Branch 0 was taken 136 times"> + </span><span class="branchCov" title="Branch 1 was taken 176291009 times"> + </span>]:<span class="lineCov">  176291145 :         if (syscall_delayed(current_tcp)) {</span></a>
<a name="3726"><span class="lineNum">    3726 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 136 times"> + </span>]:<span class="lineCov">        136 :                 if (current_tcp->delayed_wait_data)</span></a>
<a name="3727"><span class="lineNum">    3727 </span>                :<span class="lineNoCov">          0 :                         error_func_msg("pid %d has delayed wait data set"</span></a>
<a name="3728"><span class="lineNum">    3728 </span>                :            :                                        " already", current_tcp->pid);</a>
<a name="3729"><span class="lineNum">    3729 </span>                :            : </a>
<a name="3730"><span class="lineNum">    3730 </span>                :<span class="lineCov">        136 :                 current_tcp->delayed_wait_data = copy_trace_wait_data(wd);</span></a>
<a name="3731"><span class="lineNum">    3731 </span>                :            : </a>
<a name="3732"><span class="lineNum">    3732 </span>                :<span class="lineCov">        136 :                 return true;</span></a>
<a name="3733"><span class="lineNum">    3733 </span>                :            :         }</a>
<a name="3734"><span class="lineNum">    3734 </span>                :            : </a>
<a name="3735"><span class="lineNum">    3735 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 176291009 times"> + </span>]:<span class="lineCov">  176291009 :         if (ptrace_restart(restart_op, current_tcp, restart_sig) < 0) {</span></a>
<a name="3736"><span class="lineNum">    3736 </span>                :            :                 /* Note: ptrace_restart emitted error message */</a>
<a name="3737"><span class="lineNum">    3737 </span>                :<span class="lineNoCov">          0 :                 exit_code = 1;</span></a>
<a name="3738"><span class="lineNum">    3738 </span>                :<span class="lineNoCov">          0 :                 return false;</span></a>
<a name="3739"><span class="lineNum">    3739 </span>                :            :         }</a>
<a name="3740"><span class="lineNum">    3740 </span>                :            :         return true;</a>
<a name="3741"><span class="lineNum">    3741 </span>                :            : }</a>
<a name="3742"><span class="lineNum">    3742 </span>                :            : </a>
<a name="3743"><span class="lineNum">    3743 </span>                :            : static bool</a>
<a name="3744"><span class="lineNum">    3744 </span>                :<span class="lineCov">        136 : restart_delayed_tcb(struct tcb *const tcp)</span></a>
<a name="3745"><span class="lineNum">    3745 </span>                :            : {</a>
<a name="3746"><span class="lineNum">    3746 </span>                :<span class="lineCov">        136 :         struct tcb_wait_data *wd = tcp->delayed_wait_data;</span></a>
<a name="3747"><span class="lineNum">    3747 </span>                :            : </a>
<a name="3748"><span class="lineNum">    3748 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 136 times"> + </span>]:<span class="lineCov">        136 :         if (!wd) {</span></a>
<a name="3749"><span class="lineNum">    3749 </span>                :<span class="lineNoCov">          0 :                 error_func_msg("No delayed wait data found for pid %d",</span></a>
<a name="3750"><span class="lineNum">    3750 </span>                :            :                                tcp->pid);</a>
<a name="3751"><span class="lineNum">    3751 </span>                :<span class="lineNoCov">          0 :                 wd = init_trace_wait_data(alloca(trace_wait_data_size(tcp)));</span></a>
<a name="3752"><span class="lineNum">    3752 </span>                :            :         }</a>
<a name="3753"><span class="lineNum">    3753 </span>                :            : </a>
<a name="3754"><span class="lineNum">    3754 </span>                :<span class="lineCov">        136 :         wd->te = TE_RESTART;</span></a>
<a name="3755"><span class="lineNum">    3755 </span>                :            : </a>
<a name="3756"><span class="lineNum">    3756 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 136 times"> + </span>]:<span class="lineCov">        136 :         debug_func_msg("pid %d", tcp->pid);</span></a>
<a name="3757"><span class="lineNum">    3757 </span>                :            : </a>
<a name="3758"><span class="lineNum">    3758 </span>                :<span class="lineCov">        136 :         tcp->flags &= ~TCB_DELAYED;</span></a>
<a name="3759"><span class="lineNum">    3759 </span>                :            : </a>
<a name="3760"><span class="lineNum">    3760 </span>                :<span class="lineCov">        136 :         struct tcb *const prev_tcp = current_tcp;</span></a>
<a name="3761"><span class="lineNum">    3761 </span>                :<span class="lineCov">        136 :         current_tcp = tcp;</span></a>
<a name="3762"><span class="lineNum">    3762 </span>                :<span class="lineCov">        136 :         bool ret = dispatch_event(wd);</span></a>
<a name="3763"><span class="lineNum">    3763 </span>                :<span class="lineCov">        136 :         current_tcp = prev_tcp;</span></a>
<a name="3764"><span class="lineNum">    3764 </span>                :            : </a>
<a name="3765"><span class="lineNum">    3765 </span>                :<span class="lineCov">        136 :         free_trace_wait_data(tcp->delayed_wait_data);</span></a>
<a name="3766"><span class="lineNum">    3766 </span>                :<span class="lineCov">        136 :         tcp->delayed_wait_data = NULL;</span></a>
<a name="3767"><span class="lineNum">    3767 </span>                :            : </a>
<a name="3768"><span class="lineNum">    3768 </span>                :<span class="lineCov">        136 :         return ret;</span></a>
<a name="3769"><span class="lineNum">    3769 </span>                :            : }</a>
<a name="3770"><span class="lineNum">    3770 </span>                :            : </a>
<a name="3771"><span class="lineNum">    3771 </span>                :            : static bool</a>
<a name="3772"><span class="lineNum">    3772 </span>                :<span class="lineCov">        136 : restart_delayed_tcbs(void)</span></a>
<a name="3773"><span class="lineNum">    3773 </span>                :            : {</a>
<a name="3774"><span class="lineNum">    3774 </span>                :<span class="lineCov">        136 :         struct tcb *tcp_next = NULL;</span></a>
<a name="3775"><span class="lineNum">    3775 </span>                :<span class="lineCov">        136 :         struct timespec ts_now;</span></a>
<a name="3776"><span class="lineNum">    3776 </span>                :            : </a>
<a name="3777"><span class="lineNum">    3777 </span>                :<span class="lineCov">        136 :         clock_gettime(CLOCK_MONOTONIC, &ts_now);</span></a>
<a name="3778"><span class="lineNum">    3778 </span>                :            : </a>
<a name="3779"><span class="lineNum">    3779 </span>        [<span class="branchCov" title="Branch 0 was taken 2176 times"> + </span><span class="branchCov" title="Branch 1 was taken 136 times"> + </span>]:<span class="lineCov">       2312 :         for (size_t i = 0; i < tcbtabsize; i++) {</span></a>
<a name="3780"><span class="lineNum">    3780 </span>                :<span class="lineCov">       2176 :                 struct tcb *tcp = tcbtab[i];</span></a>
<a name="3781"><span class="lineNum">    3781 </span>                :            : </a>
<a name="3782"><span class="lineNum">    3782 </span>  [<span class="branchCov" title="Branch 0 was taken 612 times"> + </span><span class="branchCov" title="Branch 1 was taken 1564 times"> + </span><span class="branchCov" title="Branch 2 was taken 484 times"> + </span><span class="branchCov" title="Branch 3 was taken 128 times"> + </span>]:<span class="lineCov">       2176 :                 if (tcp->pid && syscall_delayed(tcp)) {</span></a>
<a name="3783"><span class="lineNum">    3783 </span>        [<span class="branchCov" title="Branch 0 was taken 136 times"> + </span><span class="branchCov" title="Branch 1 was taken 348 times"> + </span>]:<span class="lineCov">        484 :                         if (ts_cmp(&ts_now, &tcp->delay_expiration_time) > 0) {</span></a>
<a name="3784"><span class="lineNum">    3784 </span>        [<span class="branchCov" title="Branch 0 was taken 136 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">        136 :                                 if (!restart_delayed_tcb(tcp))</span></a>
<a name="3785"><span class="lineNum">    3785 </span>                :            :                                         return false;</a>
<a name="3786"><span class="lineNum">    3786 </span>                :            :                         } else {</a>
<a name="3787"><span class="lineNum">    3787 </span>                :            :                                 /* Check whether this tcb is the next.  */</a>
<a name="3788"><span class="lineNum">    3788 </span>  [<span class="branchCov" title="Branch 0 was taken 224 times"> + </span><span class="branchCov" title="Branch 1 was taken 124 times"> + </span><span class="branchCov" title="Branch 2 was taken 80 times"> + </span><span class="branchCov" title="Branch 3 was taken 144 times"> + </span>]:<span class="lineCov">        572 :                                 if (!tcp_next ||</span></a>
<a name="3789"><span class="lineNum">    3789 </span>                :<span class="lineCov">        224 :                                     ts_cmp(&tcp_next->delay_expiration_time,</span></a>
<a name="3790"><span class="lineNum">    3790 </span>                :            :                                            &tcp->delay_expiration_time) > 0) {</a>
<a name="3791"><span class="lineNum">    3791 </span>                :            :                                         tcp_next = tcp;</a>
<a name="3792"><span class="lineNum">    3792 </span>                :            :                                 }</a>
<a name="3793"><span class="lineNum">    3793 </span>                :            :                         }</a>
<a name="3794"><span class="lineNum">    3794 </span>                :            :                 }</a>
<a name="3795"><span class="lineNum">    3795 </span>                :            :         }</a>
<a name="3796"><span class="lineNum">    3796 </span>                :            : </a>
<a name="3797"><span class="lineNum">    3797 </span>        [<span class="branchCov" title="Branch 0 was taken 124 times"> + </span><span class="branchCov" title="Branch 1 was taken 12 times"> + </span>]:<span class="lineCov">        136 :         if (tcp_next)</span></a>
<a name="3798"><span class="lineNum">    3798 </span>                :<span class="lineCov">        124 :                 arm_delay_timer(tcp_next);</span></a>
<a name="3799"><span class="lineNum">    3799 </span>                :            : </a>
<a name="3800"><span class="lineNum">    3800 </span>                :            :         return true;</a>
<a name="3801"><span class="lineNum">    3801 </span>                :            : }</a>
<a name="3802"><span class="lineNum">    3802 </span>                :            : </a>
<a name="3803"><span class="lineNum">    3803 </span>                :            : /*</a>
<a name="3804"><span class="lineNum">    3804 </span>                :            :  * As this signal handler does a lot of work that is not suitable</a>
<a name="3805"><span class="lineNum">    3805 </span>                :            :  * for signal handlers, extra care must be taken to ensure that</a>
<a name="3806"><span class="lineNum">    3806 </span>                :            :  * it is enabled only in those places where it's safe.</a>
<a name="3807"><span class="lineNum">    3807 </span>                :            :  */</a>
<a name="3808"><span class="lineNum">    3808 </span>                :            : static void</a>
<a name="3809"><span class="lineNum">    3809 </span>                :<span class="lineCov">        136 : timer_sighandler(int sig)</span></a>
<a name="3810"><span class="lineNum">    3810 </span>                :            : {</a>
<a name="3811"><span class="lineNum">    3811 </span>                :<span class="lineCov">        136 :         delay_timer_expired();</span></a>
<a name="3812"><span class="lineNum">    3812 </span>                :            : </a>
<a name="3813"><span class="lineNum">    3813 </span>        [<span class="branchCov" title="Branch 0 was taken 136 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">        136 :         if (restart_failed)</span></a>
<a name="3814"><span class="lineNum">    3814 </span>                :            :                 return;</a>
<a name="3815"><span class="lineNum">    3815 </span>                :            : </a>
<a name="3816"><span class="lineNum">    3816 </span>                :<span class="lineCov">        136 :         int saved_errno = errno;</span></a>
<a name="3817"><span class="lineNum">    3817 </span>                :            : </a>
<a name="3818"><span class="lineNum">    3818 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 136 times"> + </span>]:<span class="lineCov">        136 :         if (!restart_delayed_tcbs())</span></a>
<a name="3819"><span class="lineNum">    3819 </span>                :<span class="lineNoCov">          0 :                 restart_failed = 1;</span></a>
<a name="3820"><span class="lineNum">    3820 </span>                :            : </a>
<a name="3821"><span class="lineNum">    3821 </span>                :<span class="lineCov">        136 :         errno = saved_errno;</span></a>
<a name="3822"><span class="lineNum">    3822 </span>                :            : }</a>
<a name="3823"><span class="lineNum">    3823 </span>                :            : </a>
<a name="3824"><span class="lineNum">    3824 </span>                :            : static void ATTRIBUTE_NORETURN</a>
<a name="3825"><span class="lineNum">    3825 </span>                :<span class="lineCov">      17338 : terminate(void)</span></a>
<a name="3826"><span class="lineNum">    3826 </span>                :            : {</a>
<a name="3827"><span class="lineNum">    3827 </span>                :<span class="lineCov">      17338 :         int sig = interrupted;</span></a>
<a name="3828"><span class="lineNum">    3828 </span>                :            : </a>
<a name="3829"><span class="lineNum">    3829 </span>                :<span class="lineCov">      17338 :         cleanup(sig);</span></a>
<a name="3830"><span class="lineNum">    3830 </span>        [<span class="branchCov" title="Branch 0 was taken 34 times"> + </span><span class="branchCov" title="Branch 1 was taken 17304 times"> + </span>]:<span class="lineCov">      17338 :         if (cflag)</span></a>
<a name="3831"><span class="lineNum">    3831 </span>                :<span class="lineCov">         34 :                 call_summary(shared_log);</span></a>
<a name="3832"><span class="lineNum">    3832 </span>                :<span class="lineCov">      17338 :         fflush(NULL);</span></a>
<a name="3833"><span class="lineNum">    3833 </span>        [<span class="branchCov" title="Branch 0 was taken 14909 times"> + </span><span class="branchCov" title="Branch 1 was taken 2429 times"> + </span>]:<span class="lineCov">      17338 :         if (shared_log != stderr)</span></a>
<a name="3834"><span class="lineNum">    3834 </span>                :<span class="lineCov">      14909 :                 fclose(shared_log);</span></a>
<a name="3835"><span class="lineNum">    3835 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 17338 times"> + </span>]:<span class="lineCov">      17338 :         if (popen_pid) {</span></a>
<a name="3836"><span class="lineNum">    3836 </span>  [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :                 while (waitpid(popen_pid, NULL, 0) < 0 && errno == EINTR)</span></a>
<a name="3837"><span class="lineNum">    3837 </span>                :            :                         ;</a>
<a name="3838"><span class="lineNum">    3838 </span>                :            :         }</a>
<a name="3839"><span class="lineNum">    3839 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 17334 times"> + </span>]:<span class="lineCov">      17338 :         if (sig) {</span></a>
<a name="3840"><span class="lineNum">    3840 </span>                :<span class="lineCov">          4 :                 exit_code = 0x100 | sig;</span></a>
<a name="3841"><span class="lineNum">    3841 </span>                :            :         }</a>
<a name="3842"><span class="lineNum">    3842 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchCov" title="Branch 1 was taken 17326 times"> + </span>]:<span class="lineCov">      17338 :         if (exit_code > 0xff) {</span></a>
<a name="3843"><span class="lineNum">    3843 </span>                :            :                 /* Avoid potential core file clobbering.  */</a>
<a name="3844"><span class="lineNum">    3844 </span>                :<span class="lineCov">         12 :                 struct_rlimit rlim = {0, 0};</span></a>
<a name="3845"><span class="lineNum">    3845 </span>                :<span class="lineCov">         12 :                 set_rlimit(RLIMIT_CORE, &rlim);</span></a>
<a name="3846"><span class="lineNum">    3846 </span>                :            : </a>
<a name="3847"><span class="lineNum">    3847 </span>                :            :                 /* Child was killed by a signal, mimic that.  */</a>
<a name="3848"><span class="lineNum">    3848 </span>                :<span class="lineCov">         12 :                 exit_code &= 0xff;</span></a>
<a name="3849"><span class="lineNum">    3849 </span>                :<span class="lineCov">         12 :                 signal(exit_code, SIG_DFL);</span></a>
<a name="3850"><span class="lineNum">    3850 </span>                :<span class="lineCov">         12 :                 GCOV_DUMP;</span></a>
<a name="3851"><span class="lineNum">    3851 </span>                :<span class="lineNoCov">          0 :                 raise(exit_code);</span></a>
<a name="3852"><span class="lineNum">    3852 </span>                :            : </a>
<a name="3853"><span class="lineNum">    3853 </span>                :            :                 /* Unblock the signal.  */</a>
<a name="3854"><span class="lineNum">    3854 </span>                :<span class="lineNoCov">          0 :                 sigset_t mask;</span></a>
<a name="3855"><span class="lineNum">    3855 </span>                :<span class="lineNoCov">          0 :                 sigemptyset(&mask);</span></a>
<a name="3856"><span class="lineNum">    3856 </span>                :<span class="lineNoCov">          0 :                 sigaddset(&mask, exit_code);</span></a>
<a name="3857"><span class="lineNum">    3857 </span>                :<span class="lineNoCov">          0 :                 GCOV_DUMP;</span></a>
<a name="3858"><span class="lineNum">    3858 </span>                :<span class="lineNoCov">          0 :                 sigprocmask(SIG_UNBLOCK, &mask, NULL);</span></a>
<a name="3859"><span class="lineNum">    3859 </span>                :            : </a>
<a name="3860"><span class="lineNum">    3860 </span>                :            :                 /* Paranoia - what if this signal is not fatal?</a>
<a name="3861"><span class="lineNum">    3861 </span>                :            :                    Exit with 128 + signo then.  */</a>
<a name="3862"><span class="lineNum">    3862 </span>                :<span class="lineNoCov">          0 :                 exit_code += 128;</span></a>
<a name="3863"><span class="lineNum">    3863 </span>                :            :         }</a>
<a name="3864"><span class="lineNum">    3864 </span>                :<span class="lineCov">      17326 :         exit(exit_code);</span></a>
<a name="3865"><span class="lineNum">    3865 </span>                :            : }</a>
<a name="3866"><span class="lineNum">    3866 </span>                :            : </a>
<a name="3867"><span class="lineNum">    3867 </span>                :            : int</a>
<a name="3868"><span class="lineNum">    3868 </span>                :<span class="lineCov">      23834 : main(int argc, char *argv[])</span></a>
<a name="3869"><span class="lineNum">    3869 </span>                :            : {</a>
<a name="3870"><span class="lineNum">    3870 </span>                :<span class="lineCov">      23834 :         setlocale(LC_ALL, "");</span></a>
<a name="3871"><span class="lineNum">    3871 </span>                :<span class="lineCov">      23834 :         init(argc, argv);</span></a>
<a name="3872"><span class="lineNum">    3872 </span>                :            : </a>
<a name="3873"><span class="lineNum">    3873 </span>                :<span class="lineCov">      17338 :         exit_code = !nprocs;</span></a>
<a name="3874"><span class="lineNum">    3874 </span>                :            : </a>
<a name="3875"><span class="lineNum">    3875 </span>        [<span class="branchCov" title="Branch 0 was taken 176338039 times"> + </span><span class="branchCov" title="Branch 1 was taken 17338 times"> + </span>]:<span class="lineCov">  176355377 :         while (dispatch_event(next_event()))</span></a>
<a name="3876"><span class="lineNum">    3876 </span>                :            :                 ;</a>
<a name="3877"><span class="lineNum">    3877 </span>                :<span class="lineCov">      17338 :         terminate();</span></a>
<a name="3878"><span class="lineNum">    3878 </span>                :            : }</a>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.14</a></td></tr>
  </table>
  <br>

</body>
</html>