LCOV - code coverage report
Current view: top level - /opt/artdaq/srcs/trace/src_example/userspace - basic_c.c (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 21 0
Test Date: 2026-10-29 00:35:58 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*  This file (basic_c.c) was created by Ron Rechenmacher <ron@fnal.gov> on
       2              :         Dec 13, 2015. "TERMS AND CONDITIONS" governing this file are in the README
       3              :         or COPYING file. If you do not have such a file, one can be obtained by
       4              :         contacting Ron or Fermi Lab in Batavia IL, 60510, phone: 630-840-3000.
       5              :         $RCSfile: .emacs.gnu,v $
       6              :         rev="$Revision: 1702 $$Date: 2025-01-28 12:48:14 -0600 (Tue, 28 Jan 2025) $";
       7              :         */
       8              : /*
       9              :     # Just:
      10              :     basic_c
      11              :     basic_c | grep 'before OK' && basic_c | grep 'after OK' && echo ALL OK || echo 'all NOT OK!!!!!'
      12              :  */
      13              : /*#define _GNU_SOURCE*/ /* Defined by compiler flags now to kill the sched_getcpu error once and for all */
      14              : #include <stdio.h>      /* printf */
      15              : struct basic_c_s {
      16              :         char ver1[0x1000];
      17              :         char ver2[0x1000];
      18              : };
      19              : 
      20              : static struct basic_c_s before= {{0}, {0}};
      21              : #include "TRACE/trace.h" /* TRACE */
      22              : static struct basic_c_s after= {{0}, {0}};
      23              : 
      24            0 : int main(void)
      25              : {
      26            0 :         unsigned ii;
      27            0 :         unsigned char *byte_ptr;
      28            0 :         printf("printf - main start\n");
      29              : 
      30            0 :         TRACE(10, "TRACE - 0 args");
      31            0 :         TRACE(20,
      32              :                   "TRACE - 35 args "
      33              :                   "%d %d %d %d %d %d %d %d %d %d "
      34              :                   "%d %d %d %d %d %d %d %d %d %d "
      35              :                   "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
      36              :                   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
      37              :                   34, 35);
      38              : 
      39              :         /* Currently, TRACE supports 0-35 args after the format, if you accidently put 36 args,
      40              :            the trace macros thinks the number of args is the 36th arg :(
      41              :            This example also shows that if one accidentally puts a lvl > 63, the macro mask the lower bits */
      42              : #ifdef TOO_MANY_ARGS
      43              :         TRACE(30 + 64,
      44              :                   "TRACE - 35 args "
      45              :                   "%d %d %d %d %d %d %d %d %d %d "
      46              :                   "%d %d %d %d %d %d %d %d %d %d "
      47              :                   "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
      48              :                   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
      49              :                   34, 35, 6);
      50              : #endif
      51              : 
      52            0 :         printf("\
      53              :       &before[0]=%p\n\
      54              : &traceControl[0]=%p\n\
      55              :        &after[0]=%p\n\
      56              : ",
      57              :                    (void *)&before, (void *)&traceControl[0], (void *)&after);
      58              : 
      59              :         /* The following is meant to test the trace "disabled" case --
      60              :            to make sure that no writing beyond the trace variable storage occurs.
      61              :            With the 2016.01.21 (revision 486) of the trace.h file, changing the
      62              :        size of the disabled traceControl variable from 2 to 1 will cause
      63              :            overwriting of the "after" variable.
      64              :          */
      65            0 :         byte_ptr= (unsigned char *)&before;
      66            0 :         for (ii= 0; ii < sizeof(before); ++ii)
      67            0 :                 if (byte_ptr[ii] != 0) {
      68            0 :                         printf("problem with before\n");
      69            0 :                         break;
      70              :                 }
      71            0 :         if (ii == sizeof(before)) printf("before OK\n");
      72            0 :         byte_ptr= (unsigned char *)&after;
      73            0 :         for (ii= 0; ii < sizeof(after); ++ii)
      74            0 :                 if (byte_ptr[ii] != 0) {
      75            0 :                         printf("problem with after\n");
      76            0 :                         break;
      77              :                 }
      78            0 :         if (ii == sizeof(after)) printf("after OK\n");
      79              : 
      80            0 :         printf("printf - main done\n");
      81            0 :         return (0);
      82              : } /* main */
        

Generated by: LCOV version 2.0-1