LCOV - code coverage report
Current view: top level - strace_git - futex.c (source / functions) Hit Total Coverage
Test: strace-4.16.0.69.f1ea-dirty Code Coverage Lines: 69 69 100.0 %
Date: 2017-03-18 00:38:52 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 17 17 100.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2002-2003 Roland McGrath  <roland@redhat.com>
       3                 :            :  * Copyright (c) 2007-2008 Ulrich Drepper <drepper@redhat.com>
       4                 :            :  * Copyright (c) 2009 Andreas Schwab <schwab@redhat.com>
       5                 :            :  * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
       6                 :            :  * All rights reserved.
       7                 :            :  *
       8                 :            :  * Redistribution and use in source and binary forms, with or without
       9                 :            :  * modification, are permitted provided that the following conditions
      10                 :            :  * are met:
      11                 :            :  * 1. Redistributions of source code must retain the above copyright
      12                 :            :  *    notice, this list of conditions and the following disclaimer.
      13                 :            :  * 2. Redistributions in binary form must reproduce the above copyright
      14                 :            :  *    notice, this list of conditions and the following disclaimer in the
      15                 :            :  *    documentation and/or other materials provided with the distribution.
      16                 :            :  * 3. The name of the author may not be used to endorse or promote products
      17                 :            :  *    derived from this software without specific prior written permission.
      18                 :            :  *
      19                 :            :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
      20                 :            :  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      21                 :            :  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
      22                 :            :  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
      23                 :            :  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      24                 :            :  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      25                 :            :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      26                 :            :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      27                 :            :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      28                 :            :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      29                 :            :  */
      30                 :            : 
      31                 :            : #include "defs.h"
      32                 :            : 
      33                 :            : #ifndef FUTEX_PRIVATE_FLAG
      34                 :            : # define FUTEX_PRIVATE_FLAG 128
      35                 :            : #endif
      36                 :            : #ifndef FUTEX_CLOCK_REALTIME
      37                 :            : # define FUTEX_CLOCK_REALTIME 256
      38                 :            : #endif
      39                 :            : 
      40                 :            : #include "xlat/futexops.h"
      41                 :            : #include "xlat/futexwakeops.h"
      42                 :            : #include "xlat/futexwakecmps.h"
      43                 :            : 
      44                 :       1308 : SYS_FUNC(futex)
      45                 :            : {
      46                 :       1308 :         const kernel_ulong_t uaddr = tcp->u_arg[0];
      47                 :       1308 :         const int op = tcp->u_arg[1];
      48                 :       1308 :         const int cmd = op & 127;
      49                 :       1308 :         const kernel_ulong_t timeout = tcp->u_arg[3];
      50                 :       1308 :         const kernel_ulong_t uaddr2 = tcp->u_arg[4];
      51                 :       1308 :         const unsigned int val = tcp->u_arg[2];
      52                 :       1308 :         const unsigned int val2 = tcp->u_arg[3];
      53                 :       1308 :         const unsigned int val3 = tcp->u_arg[5];
      54                 :            : 
      55                 :       1308 :         printaddr(uaddr);
      56                 :       1308 :         tprints(", ");
      57                 :       1308 :         printxval(futexops, op, "FUTEX_???");
      58   [ +  +  +  +  :       1308 :         switch (cmd) {
          +  +  +  +  +  
                   +  + ]
      59                 :            :         case FUTEX_WAIT:
      60                 :         84 :                 tprintf(", %u", val);
      61                 :         84 :                 tprints(", ");
      62                 :         84 :                 print_timespec(tcp, timeout);
      63                 :         84 :                 break;
      64                 :            :         case FUTEX_LOCK_PI:
      65                 :         48 :                 tprints(", ");
      66                 :         48 :                 print_timespec(tcp, timeout);
      67                 :         48 :                 break;
      68                 :            :         case FUTEX_WAIT_BITSET:
      69                 :         72 :                 tprintf(", %u", val);
      70                 :         72 :                 tprints(", ");
      71                 :         72 :                 print_timespec(tcp, timeout);
      72                 :         72 :                 tprintf(", %#x", val3);
      73                 :         72 :                 break;
      74                 :            :         case FUTEX_WAKE_BITSET:
      75                 :         60 :                 tprintf(", %u", val);
      76                 :         60 :                 tprintf(", %#x", val3);
      77                 :         60 :                 break;
      78                 :            :         case FUTEX_REQUEUE:
      79                 :         48 :                 tprintf(", %u", val);
      80                 :         48 :                 tprintf(", %u, ", val2);
      81                 :         48 :                 printaddr(uaddr2);
      82                 :         48 :                 break;
      83                 :            :         case FUTEX_CMP_REQUEUE:
      84                 :            :         case FUTEX_CMP_REQUEUE_PI:
      85                 :        120 :                 tprintf(", %u", val);
      86                 :        120 :                 tprintf(", %u, ", val2);
      87                 :        120 :                 printaddr(uaddr2);
      88                 :        120 :                 tprintf(", %u", val3);
      89                 :        120 :                 break;
      90                 :            :         case FUTEX_WAKE_OP:
      91                 :        600 :                 tprintf(", %u", val);
      92                 :        600 :                 tprintf(", %u, ", val2);
      93                 :        600 :                 printaddr(uaddr2);
      94                 :        600 :                 tprints(", ");
      95         [ +  + ]:        600 :                 if ((val3 >> 28) & 8)
      96                 :        120 :                         tprints("FUTEX_OP_OPARG_SHIFT<<28|");
      97         [ +  + ]:        600 :                 if (printxval(futexwakeops, (val3 >> 28) & 0x7, NULL))
      98                 :        504 :                         tprints("<<28");
      99                 :            :                 else
     100                 :         96 :                         tprints("<<28 /* FUTEX_OP_??? */");
     101                 :        600 :                 tprintf("|%#x<<12|", (val3 >> 12) & 0xfff);
     102         [ +  + ]:        600 :                 if (printxval(futexwakecmps, (val3 >> 24) & 0xf, NULL))
     103                 :        432 :                         tprints("<<24");
     104                 :            :                 else
     105                 :        168 :                         tprints("<<24 /* FUTEX_OP_CMP_??? */");
     106                 :        600 :                 tprintf("|%#x", val3 & 0xfff);
     107                 :        600 :                 break;
     108                 :            :         case FUTEX_WAIT_REQUEUE_PI:
     109                 :         48 :                 tprintf(", %u", val);
     110                 :         48 :                 tprints(", ");
     111                 :         48 :                 print_timespec(tcp, timeout);
     112                 :         48 :                 tprints(", ");
     113                 :         48 :                 printaddr(uaddr2);
     114                 :         48 :                 break;
     115                 :            :         case FUTEX_FD:
     116                 :            :         case FUTEX_WAKE:
     117                 :        108 :                 tprintf(", %u", val);
     118                 :        108 :                 break;
     119                 :            :         case FUTEX_UNLOCK_PI:
     120                 :            :         case FUTEX_TRYLOCK_PI:
     121                 :         96 :                 break;
     122                 :            :         default:
     123                 :         24 :                 tprintf(", %u", val);
     124                 :         24 :                 tprints(", ");
     125                 :         24 :                 printaddr(timeout);
     126                 :         24 :                 tprints(", ");
     127                 :         24 :                 printaddr(uaddr2);
     128                 :         24 :                 tprintf(", %#x", val3);
     129                 :         24 :                 break;
     130                 :            :         }
     131                 :            : 
     132                 :       1308 :         return RVAL_DECODED;
     133                 :            : }

Generated by: LCOV version 1.12