LCOV - code coverage report
Current view: top level - strace - numa.c (source / functions) Hit Total Coverage
Test: strace-4.18.0.129.97bbb Code Coverage Lines: 75 75 100.0 %
Date: 2017-07-31 03:46:08 Functions: 10 10 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 18 88.9 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2003-2007 Ulrich Drepper <drepper@redhat.com>
       3                 :            :  * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
       4                 :            :  * Copyright (c) 2016-2017 The strace developers.
       5                 :            :  * All rights reserved.
       6                 :            :  *
       7                 :            :  * Redistribution and use in source and binary forms, with or without
       8                 :            :  * modification, are permitted provided that the following conditions
       9                 :            :  * are met:
      10                 :            :  * 1. Redistributions of source code must retain the above copyright
      11                 :            :  *    notice, this list of conditions and the following disclaimer.
      12                 :            :  * 2. Redistributions in binary form must reproduce the above copyright
      13                 :            :  *    notice, this list of conditions and the following disclaimer in the
      14                 :            :  *    documentation and/or other materials provided with the distribution.
      15                 :            :  * 3. The name of the author may not be used to endorse or promote products
      16                 :            :  *    derived from this software without specific prior written permission.
      17                 :            :  *
      18                 :            :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
      19                 :            :  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      20                 :            :  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
      21                 :            :  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
      22                 :            :  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      23                 :            :  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      24                 :            :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      25                 :            :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      26                 :            :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      27                 :            :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      28                 :            :  */
      29                 :            : 
      30                 :            : #include "defs.h"
      31                 :            : 
      32                 :            : static bool
      33                 :        191 : print_node(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
      34                 :            : {
      35         [ +  + ]:        191 :         if (elem_size < sizeof(kernel_ulong_t)) {
      36                 :         94 :                 tprintf("%#0*x", (int) elem_size * 2 + 2,
      37                 :            :                         *(unsigned int *) elem_buf);
      38                 :            :         } else {
      39                 :         97 :                 tprintf("%#0*" PRI_klx, (int) elem_size * 2 + 2,
      40                 :            :                         *(kernel_ulong_t *) elem_buf);
      41                 :            :         }
      42                 :            : 
      43                 :        191 :         return true;
      44                 :            : }
      45                 :            : 
      46                 :            : static void
      47                 :        124 : print_nodemask(struct tcb *const tcp, const kernel_ulong_t addr,
      48                 :            :                const kernel_ulong_t maxnodes)
      49                 :            : {
      50                 :        124 :         const unsigned int bits_per_long = 8 * current_wordsize;
      51                 :        124 :         const kernel_ulong_t nmemb =
      52                 :        124 :                 (maxnodes + bits_per_long - 2) / bits_per_long;
      53                 :            : 
      54 [ +  - ][ +  + ]:        124 :         if (nmemb < maxnodes / bits_per_long ||
      55                 :        124 :             (maxnodes && !nmemb)) {
      56                 :          4 :                 printaddr(addr);
      57                 :          4 :                 return;
      58                 :            :         }
      59                 :            : 
      60                 :            :         kernel_ulong_t buf;
      61                 :        120 :         print_array(tcp, addr, nmemb, &buf, current_wordsize,
      62                 :            :                     umoven_or_printaddr, print_node, 0);
      63                 :            : }
      64                 :            : 
      65                 :          2 : SYS_FUNC(migrate_pages)
      66                 :            : {
      67                 :          2 :         tprintf("%d, %" PRI_klu ", ", (int) tcp->u_arg[0], tcp->u_arg[1]);
      68                 :          2 :         print_nodemask(tcp, tcp->u_arg[2], tcp->u_arg[1]);
      69                 :          2 :         tprints(", ");
      70                 :          2 :         print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[1]);
      71                 :            : 
      72                 :          2 :         return RVAL_DECODED;
      73                 :            : }
      74                 :            : 
      75                 :            : #include "xlat/policies.h"
      76                 :            : #include "xlat/mbindflags.h"
      77                 :            : 
      78                 :          2 : SYS_FUNC(mbind)
      79                 :            : {
      80                 :          2 :         printaddr(tcp->u_arg[0]);
      81                 :          2 :         tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
      82                 :          2 :         printxval64(policies, tcp->u_arg[2], "MPOL_???");
      83                 :          2 :         tprints(", ");
      84                 :          2 :         print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[4]);
      85                 :          2 :         tprintf(", %" PRI_klu ", ", tcp->u_arg[4]);
      86                 :          2 :         printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
      87                 :            : 
      88                 :          2 :         return RVAL_DECODED;
      89                 :            : }
      90                 :            : 
      91                 :         80 : SYS_FUNC(set_mempolicy)
      92                 :            : {
      93                 :         80 :         printxval(policies, tcp->u_arg[0], "MPOL_???");
      94                 :         80 :         tprints(", ");
      95                 :         80 :         print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
      96                 :         80 :         tprintf(", %" PRI_klu, tcp->u_arg[2]);
      97                 :            : 
      98                 :         80 :         return RVAL_DECODED;
      99                 :            : }
     100                 :            : 
     101                 :            : #include "xlat/mempolicyflags.h"
     102                 :            : 
     103                 :         76 : SYS_FUNC(get_mempolicy)
     104                 :            : {
     105         [ +  + ]:         76 :         if (exiting(tcp)) {
     106                 :            :                 int pol;
     107         [ +  + ]:         38 :                 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &pol)) {
     108                 :          4 :                         tprints("[");
     109                 :          4 :                         printxval(policies, pol, "MPOL_???");
     110                 :          4 :                         tprints("]");
     111                 :            :                 }
     112                 :         38 :                 tprints(", ");
     113                 :         38 :                 print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
     114                 :         38 :                 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
     115                 :         38 :                 printaddr(tcp->u_arg[3]);
     116                 :         38 :                 tprints(", ");
     117                 :         38 :                 printflags64(mempolicyflags, tcp->u_arg[4], "MPOL_???");
     118                 :            :         }
     119                 :         76 :         return 0;
     120                 :            : }
     121                 :            : 
     122                 :            : #include "xlat/move_pages_flags.h"
     123                 :            : 
     124                 :            : static bool
     125                 :         54 : print_addr(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
     126                 :            : {
     127                 :            :         kernel_ulong_t addr;
     128                 :            : 
     129         [ +  + ]:         54 :         if (elem_size < sizeof(addr)) {
     130                 :         27 :                 addr = *(unsigned int *) elem_buf;
     131                 :            :         } else {
     132                 :         27 :                 addr = *(kernel_ulong_t *) elem_buf;
     133                 :            :         }
     134                 :            : 
     135                 :         54 :         printaddr(addr);
     136                 :            : 
     137                 :         54 :         return true;
     138                 :            : }
     139                 :            : 
     140                 :            : static bool
     141                 :         18 : print_status(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
     142                 :            : {
     143                 :         18 :         const int status = *(int *) elem_buf;
     144                 :            : 
     145 [ +  + ][ +  - ]:         18 :         if (status < 0 && (unsigned) -status < nerrnos)
     146                 :          6 :                 tprintf("-%s", errnoent[-status]);
     147                 :            :         else
     148                 :         12 :                 tprintf("%d", status);
     149                 :            : 
     150                 :         18 :         return true;
     151                 :            : }
     152                 :            : 
     153                 :            : static bool
     154                 :         36 : print_int(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
     155                 :            : {
     156                 :         36 :         tprintf("%d", *(int *) elem_buf);
     157                 :            : 
     158                 :         36 :         return true;
     159                 :            : }
     160                 :            : 
     161                 :         60 : SYS_FUNC(move_pages)
     162                 :            : {
     163                 :         60 :         const kernel_ulong_t npages = tcp->u_arg[1];
     164                 :            :         kernel_ulong_t buf;
     165                 :            : 
     166         [ +  + ]:         60 :         if (entering(tcp)) {
     167                 :         30 :                 tprintf("%d, %" PRI_klu ", ", (int) tcp->u_arg[0], npages);
     168                 :         30 :                 print_array(tcp, tcp->u_arg[2], npages, &buf, current_wordsize,
     169                 :            :                             umoven_or_printaddr, print_addr, 0);
     170                 :         30 :                 tprints(", ");
     171                 :         30 :                 print_array(tcp, tcp->u_arg[3], npages, &buf, sizeof(int),
     172                 :            :                             umoven_or_printaddr, print_int, 0);
     173                 :         30 :                 tprints(", ");
     174                 :            :         } else {
     175                 :         30 :                 print_array(tcp, tcp->u_arg[4], npages, &buf, sizeof(int),
     176                 :            :                             umoven_or_printaddr, print_status, 0);
     177                 :         30 :                 tprints(", ");
     178                 :         30 :                 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
     179                 :            :         }
     180                 :         60 :         return 0;
     181                 :            : }

Generated by: LCOV version 1.11