LCOV - code coverage report
Current view: top level - tango - fd_tango_ctl.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 389 539 72.2 %
Date: 2024-11-13 11:58:15 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "fd_tango.h"
       2             : #include "mcache/fd_mcache_private.h"
       3             : #include "dcache/fd_dcache_private.h"
       4             : 
       5             : #if FD_HAS_HOSTED
       6             : 
       7             : #include <stdio.h>
       8             : 
       9             : FD_IMPORT_CSTR( fd_tango_ctl_help, "src/tango/fd_tango_ctl_help" );
      10             : 
      11             : int
      12             : main( int     argc,
      13         180 :       char ** argv ) {
      14         180 :   fd_boot( &argc, &argv );
      15         777 : # define SHIFT(n) argv+=(n),argc-=(n)
      16             : 
      17         180 :   if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "no arguments" ));
      18         180 :   char const * bin = argv[0];
      19         180 :   SHIFT(1);
      20             : 
      21             :   /* FIXME: CACHE ATTACHMENTS? */
      22             : 
      23         180 :   ulong tag = 1UL;
      24             : 
      25         180 :   int cnt = 0;
      26         480 :   while( argc ) {
      27         300 :     char const * cmd = argv[0];
      28         300 :     SHIFT(1);
      29             : 
      30         300 :     if( !strcmp( cmd, "help" ) ) {
      31             : 
      32           3 :       fputs( fd_tango_ctl_help, stdout );
      33             : 
      34           3 :       FD_LOG_NOTICE(( "%i: %s: success", cnt, cmd ));
      35             : 
      36         297 :     } else if( !strcmp( cmd, "tag" ) ) {
      37             : 
      38           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
      39             : 
      40           3 :       tag = fd_cstr_to_ulong( argv[0] );
      41             : 
      42           3 :       FD_LOG_NOTICE(( "%i: %s %lu: success", cnt, cmd, tag ));
      43           3 :       SHIFT(1);
      44             : 
      45         294 :     } else if( !strcmp( cmd, "new-mcache" ) ) {
      46             : 
      47           6 :       if( FD_UNLIKELY( argc<4 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
      48             : 
      49           6 :       char const * _wksp  =                   argv[0];
      50           6 :       ulong        depth  = fd_cstr_to_ulong( argv[1] );
      51           6 :       ulong        app_sz = fd_cstr_to_ulong( argv[2] );
      52           6 :       ulong        seq0   = fd_cstr_to_ulong( argv[3] );
      53             : 
      54           6 :       ulong align     = fd_mcache_align();
      55           6 :       ulong footprint = fd_mcache_footprint( depth, app_sz );
      56           6 :       if( FD_UNLIKELY( !footprint ) )
      57           0 :         FD_LOG_ERR(( "%i: %s: depth (%lu) must a power-of-2 and at least %lu and depth and app_sz (%lu) must result in a "
      58           6 :                      "footprint smaller than 2^64.\n\tDo %s help for help", cnt, cmd, depth, FD_MCACHE_BLOCK, app_sz, bin ));
      59             : 
      60           6 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
      61           6 :       if( FD_UNLIKELY( !wksp ) ) {
      62           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
      63           0 :       }
      64             : 
      65           6 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
      66           6 :       if( FD_UNLIKELY( !gaddr ) ) {
      67           0 :         fd_wksp_detach( wksp );
      68           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
      69           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
      70           0 :       }
      71             : 
      72           6 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
      73           6 :       if( FD_UNLIKELY( !shmem ) ) {
      74           0 :         fd_wksp_free( wksp, gaddr );
      75           0 :         fd_wksp_detach( wksp );
      76           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
      77           0 :       }
      78             : 
      79           6 :       void * shmcache = fd_mcache_new( shmem, depth, app_sz, seq0 );
      80           6 :       if( FD_UNLIKELY( !shmcache ) ) {
      81           0 :         fd_wksp_free( wksp, gaddr );
      82           0 :         fd_wksp_detach( wksp );
      83           0 :         FD_LOG_ERR(( "%i: %s: fd_mcache_new( %s:%lu, %lu, %lu, %lu ) failed\n\tDo %s help for help",
      84           0 :                      cnt, cmd, _wksp, gaddr, depth, app_sz, seq0, bin ));
      85           0 :       }
      86             : 
      87           6 :       char buf[ FD_WKSP_CSTR_MAX ];
      88           6 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
      89             : 
      90           6 :       fd_wksp_detach( wksp );
      91             : 
      92           6 :       FD_LOG_NOTICE(( "%i: %s %s %lu %lu %lu: success", cnt, cmd, _wksp, depth, app_sz, seq0 ));
      93           6 :       SHIFT( 4 );
      94             : 
      95         288 :     } else if( !strcmp( cmd, "delete-mcache" ) ) {
      96             : 
      97           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
      98             : 
      99           3 :       char const * _shmcache = argv[0];
     100             : 
     101           3 :       void * shmcache = fd_wksp_map( _shmcache );
     102           3 :       if( FD_UNLIKELY( !shmcache ) )
     103           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
     104           3 :       if( FD_UNLIKELY( !fd_mcache_delete( shmcache ) ) )
     105           0 :         FD_LOG_ERR(( "%i: %s: fd_mcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
     106           3 :       fd_wksp_unmap( shmcache );
     107             : 
     108           3 :       fd_wksp_cstr_free( _shmcache );
     109             : 
     110           3 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shmcache ));
     111           3 :       SHIFT( 1 );
     112             : 
     113         285 :     } else if( !strcmp( cmd, "query-mcache" ) ) {
     114             : 
     115           6 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     116             : 
     117           6 :       char const * _shmcache =                 argv[0];
     118           6 :       int          verbose   = fd_cstr_to_int( argv[1] );
     119             : 
     120           6 :       void * shmcache = fd_wksp_map( _shmcache );
     121           6 :       if( FD_UNLIKELY( !shmcache ) )
     122           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
     123             : 
     124           6 :       fd_frag_meta_t const * mcache = fd_mcache_join( shmcache );
     125           6 :       if( FD_UNLIKELY( !mcache ) )
     126           0 :         FD_LOG_ERR(( "%i: %s: fd_mcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shmcache, bin ));
     127             : 
     128           6 :       fd_mcache_private_hdr_t const * hdr = fd_mcache_private_hdr_const( mcache );
     129           6 :       if( !verbose ) printf( "%lu\n", *hdr->seq );
     130           3 :       else {
     131           3 :         printf( "mcache %s\n", _shmcache );
     132           3 :         printf( "\tdepth   %lu\n", hdr->depth  );
     133           3 :         printf( "\tapp-sz  %lu\n", hdr->app_sz );
     134           3 :         printf( "\tseq0    %lu\n", hdr->seq0   );
     135             : 
     136           3 :         ulong seq_cnt;
     137          48 :         for( seq_cnt=FD_MCACHE_SEQ_CNT; seq_cnt; seq_cnt-- ) if( hdr->seq[seq_cnt-1UL] ) break;
     138           3 :         printf( "\tseq[ 0] %lu\n", *hdr->seq );
     139           3 :         for( ulong idx=1UL; idx<seq_cnt; idx++ ) printf( "\tseq[%2lu] %lu\n", idx, hdr->seq[idx] );
     140           3 :         if( seq_cnt<FD_MCACHE_SEQ_CNT ) printf( "\t        ... snip (all remaining are zero) ...\n" );
     141             : 
     142           3 :         if( hdr->app_sz ) {
     143           3 :           uchar const * a = fd_mcache_app_laddr_const( mcache );
     144           3 :           ulong app_sz;
     145       12291 :           for( app_sz=hdr->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
     146           3 :           ulong         off = 0UL;
     147           3 :           printf( "\tapp     %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     148           3 :                   (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     149           3 :                   (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     150           3 :           for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
     151           0 :             printf( "\t        %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     152           3 :                     (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     153           3 :                     (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     154           3 :           if( off<hdr->app_sz ) printf( "\t        ... snip (all remaining are zero) ...\n" );
     155           3 :         }
     156           3 :       }
     157             : 
     158           6 :       fd_wksp_unmap( fd_mcache_leave( mcache ) );
     159             : 
     160           6 :       FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shmcache, verbose ));
     161           6 :       SHIFT( 2 );
     162             : 
     163         279 :     } else if( !strcmp( cmd, "new-dcache" ) ) {
     164             : 
     165           9 :       if( FD_UNLIKELY( argc<6 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     166             : 
     167           9 :       char const * _wksp   =                   argv[0];
     168           9 :       ulong        mtu     = fd_cstr_to_ulong( argv[1] );
     169           9 :       ulong        depth   = fd_cstr_to_ulong( argv[2] );
     170           9 :       ulong        burst   = fd_cstr_to_ulong( argv[3] );
     171           9 :       int          compact = fd_cstr_to_int  ( argv[4] );
     172           9 :       ulong        app_sz  = fd_cstr_to_ulong( argv[5] );
     173             : 
     174           9 :       ulong data_sz = fd_dcache_req_data_sz( mtu, depth, burst, compact );
     175           9 :       if( FD_UNLIKELY( !data_sz ) ) {
     176           0 :         FD_LOG_ERR(( "%i: %s: mtu (%lu), depth (%lu), burst (%lu) all must be positive and mtu, depth, burst and compact (%i) "
     177           0 :                      "must result in a data_sz smaller than 2^64.\n\tDo %s help for help",
     178           0 :                      cnt, cmd, mtu, depth, burst, compact, bin ));
     179           0 :       }
     180             : 
     181           9 :       ulong align     = fd_dcache_align();
     182           9 :       ulong footprint = fd_dcache_footprint( data_sz, app_sz );
     183           9 :       if( FD_UNLIKELY( !footprint ) ) {
     184           0 :         FD_LOG_ERR(( "%i: %s: mtu (%lu), depth (%lu), burst (%lu), compact (%i) and app_sz (%lu) must result in a footprint "
     185           0 :                      "smaller than 2^64.\n\tDo %s help for help", cnt, cmd, mtu, depth, burst, compact, app_sz, bin ));
     186           0 :       }
     187             : 
     188           9 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
     189           9 :       if( FD_UNLIKELY( !wksp ) ) {
     190           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
     191           0 :       }
     192             : 
     193           9 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
     194           9 :       if( FD_UNLIKELY( !gaddr ) ) {
     195           0 :         fd_wksp_detach( wksp );
     196           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
     197           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
     198           0 :       }
     199             : 
     200           9 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
     201           9 :       if( FD_UNLIKELY( !shmem ) ) {
     202           0 :         fd_wksp_free( wksp, gaddr );
     203           0 :         fd_wksp_detach( wksp );
     204           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
     205           0 :       }
     206             : 
     207           9 :       void * shdcache = fd_dcache_new( shmem, data_sz, app_sz );
     208           9 :       if( FD_UNLIKELY( !shdcache ) ) {
     209           0 :         fd_wksp_free( wksp, gaddr );
     210           0 :         fd_wksp_detach( wksp );
     211           0 :         FD_LOG_ERR(( "%i: %s: fd_dcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
     212           0 :                      cnt, cmd, _wksp, gaddr, data_sz, app_sz, bin ));
     213           0 :       }
     214             : 
     215           9 :       char buf[ FD_WKSP_CSTR_MAX ];
     216           9 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
     217             : 
     218           9 :       fd_wksp_detach( wksp );
     219             : 
     220           9 :       FD_LOG_NOTICE(( "%i: %s %s %lu %lu %lu %i %lu: success", cnt, cmd, _wksp, mtu, depth, burst, compact, app_sz ));
     221           9 :       SHIFT( 6 );
     222             : 
     223         270 :     } else if( !strcmp( cmd, "new-dcache-raw" ) ) {
     224             : 
     225           3 :       if( FD_UNLIKELY( argc<3 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     226             : 
     227           3 :       char const * _wksp   =                   argv[0];
     228           3 :       ulong        data_sz = fd_cstr_to_ulong( argv[1] );
     229           3 :       ulong        app_sz  = fd_cstr_to_ulong( argv[2] );
     230             : 
     231           3 :       ulong align     = fd_dcache_align();
     232           3 :       ulong footprint = fd_dcache_footprint( data_sz, app_sz );
     233           3 :       if( FD_UNLIKELY( !footprint ) ) {
     234           0 :         FD_LOG_ERR(( "%i: %s: data_sz (%lu) and app_sz (%lu) must result a footprint smaller than 2^64.\n\tDo %s help for help",
     235           0 :                      cnt, cmd, data_sz, app_sz, bin ));
     236           0 :       }
     237             : 
     238           3 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
     239           3 :       if( FD_UNLIKELY( !wksp ) ) {
     240           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
     241           0 :       }
     242             : 
     243           3 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
     244           3 :       if( FD_UNLIKELY( !gaddr ) ) {
     245           0 :         fd_wksp_detach( wksp );
     246           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
     247           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
     248           0 :       }
     249             : 
     250           3 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
     251           3 :       if( FD_UNLIKELY( !shmem ) ) {
     252           0 :         fd_wksp_free( wksp, gaddr );
     253           0 :         fd_wksp_detach( wksp );
     254           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
     255           0 :       }
     256             : 
     257           3 :       void * shdcache = fd_dcache_new( shmem, data_sz, app_sz );
     258           3 :       if( FD_UNLIKELY( !shdcache ) ) {
     259           0 :         fd_wksp_free( wksp, gaddr );
     260           0 :         fd_wksp_detach( wksp );
     261           0 :         FD_LOG_ERR(( "%i: %s: fd_dcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
     262           0 :                      cnt, cmd, _wksp, gaddr, data_sz, app_sz, bin ));
     263           0 :       }
     264             : 
     265           3 :       char buf[ FD_WKSP_CSTR_MAX ];
     266           3 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
     267             : 
     268           3 :       fd_wksp_detach( wksp );
     269             : 
     270           3 :       FD_LOG_NOTICE(( "%i: %s %s %lu %lu: success", cnt, cmd, _wksp, data_sz, app_sz ));
     271           3 :       SHIFT( 3 );
     272             : 
     273         267 :     } else if( !strcmp( cmd, "delete-dcache" ) ) {
     274             : 
     275           9 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     276             : 
     277           9 :       char const * _shdcache = argv[0];
     278             : 
     279           9 :       void * shdcache = fd_wksp_map( _shdcache );
     280           9 :       if( FD_UNLIKELY( !shdcache ) )
     281           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
     282           9 :       if( FD_UNLIKELY( !fd_dcache_delete( shdcache ) ) )
     283           0 :         FD_LOG_ERR(( "%i: %s: fd_dcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
     284           9 :       fd_wksp_unmap( shdcache );
     285             : 
     286           9 :       fd_wksp_cstr_free( _shdcache );
     287             : 
     288           9 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shdcache ));
     289           9 :       SHIFT( 1 );
     290             : 
     291         258 :     } else if( !strcmp( cmd, "query-dcache" ) ) {
     292             : 
     293          18 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     294             : 
     295          18 :       char const * _shdcache =                 argv[0];
     296          18 :       int          verbose   = fd_cstr_to_int( argv[1] );
     297             : 
     298          18 :       void * shdcache = fd_wksp_map( _shdcache );
     299          18 :       if( FD_UNLIKELY( !shdcache ) )
     300           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
     301             : 
     302          18 :       uchar const * dcache = fd_dcache_join( shdcache );
     303          18 :       if( FD_UNLIKELY( !dcache ) )
     304           0 :         FD_LOG_ERR(( "%i: %s: fd_dcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shdcache, bin ));
     305             : 
     306          18 :       if( !verbose ) printf( "0\n" );
     307           9 :       else {
     308           9 :         fd_dcache_private_hdr_t const * hdr = fd_dcache_private_hdr_const( dcache );
     309           9 :         printf( "dcache %s\n", _shdcache );
     310           9 :         printf( "\tdata-sz %lu\n", hdr->data_sz );
     311           9 :         printf( "\tapp-sz  %lu\n", hdr->app_sz  );
     312             : 
     313           9 :         if( hdr->app_sz ) {
     314           9 :           uchar const * a = fd_dcache_app_laddr_const( dcache );
     315           9 :           ulong app_sz;
     316       36873 :           for( app_sz=hdr->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
     317           9 :           ulong         off = 0UL;
     318           9 :           printf( "\tapp     %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     319           9 :                   (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     320           9 :                   (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     321           9 :           for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
     322           0 :             printf( "\t        %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     323           9 :                     (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     324           9 :                     (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     325           9 :           if( off<hdr->app_sz ) printf( "\t        ... snip (all remaining are zero) ...\n" );
     326           9 :         }
     327           9 :       }
     328             : 
     329          18 :       fd_wksp_unmap( fd_dcache_leave( dcache ) );
     330             : 
     331          18 :       FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shdcache, verbose ));
     332          18 :       SHIFT( 2 );
     333             : 
     334         240 :     } else if( !strcmp( cmd, "new-fseq" ) ) {
     335             : 
     336          51 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     337             : 
     338          51 :       char const * _wksp =                   argv[0];
     339          51 :       ulong        seq0  = fd_cstr_to_ulong( argv[1] );
     340             : 
     341          51 :       ulong align     = fd_fseq_align();
     342          51 :       ulong footprint = fd_fseq_footprint();
     343             : 
     344          51 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
     345          51 :       if( FD_UNLIKELY( !wksp ) ) {
     346           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
     347           0 :       }
     348             : 
     349          51 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
     350          51 :       if( FD_UNLIKELY( !gaddr ) ) {
     351           0 :         fd_wksp_detach( wksp );
     352           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
     353           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
     354           0 :       }
     355             : 
     356          51 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
     357          51 :       if( FD_UNLIKELY( !shmem ) ) {
     358           0 :         fd_wksp_free( wksp, gaddr );
     359           0 :         fd_wksp_detach( wksp );
     360           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
     361           0 :       }
     362             : 
     363          51 :       void * shfseq = fd_fseq_new( shmem, seq0 );
     364          51 :       if( FD_UNLIKELY( !shfseq ) ) {
     365           0 :         fd_wksp_free( wksp, gaddr );
     366           0 :         fd_wksp_detach( wksp );
     367           0 :         FD_LOG_ERR(( "%i: %s: fd_fseq_new( %s:%lu, %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, seq0, bin ));
     368           0 :       }
     369             : 
     370          51 :       char buf[ FD_WKSP_CSTR_MAX ];
     371          51 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
     372             : 
     373          51 :       fd_wksp_detach( wksp );
     374             : 
     375          51 :       FD_LOG_NOTICE(( "%i: %s %s %lu: success", cnt, cmd, _wksp, seq0 ));
     376          51 :       SHIFT( 2 );
     377             : 
     378         189 :     } else if( !strcmp( cmd, "delete-fseq" ) ) {
     379             : 
     380           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     381             : 
     382           3 :       char const * _shfseq = argv[0];
     383             : 
     384           3 :       void * shfseq = fd_wksp_map( _shfseq );
     385           3 :       if( FD_UNLIKELY( !shfseq ) )
     386           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     387           3 :       if( FD_UNLIKELY( !fd_fseq_delete( shfseq ) ) )
     388           0 :         FD_LOG_ERR(( "%i: %s: fd_fseq_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     389           3 :       fd_wksp_unmap( shfseq );
     390             : 
     391           3 :       fd_wksp_cstr_free( _shfseq );
     392             : 
     393           3 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shfseq ));
     394           3 :       SHIFT( 1 );
     395             : 
     396         186 :     } else if( !strcmp( cmd, "query-fseq" ) ) {
     397             : 
     398           6 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     399             : 
     400           6 :       char const * _shfseq =                 argv[0];
     401           6 :       int          verbose = fd_cstr_to_int( argv[1] );
     402             : 
     403           6 :       void * shfseq = fd_wksp_map( _shfseq );
     404           6 :       if( FD_UNLIKELY( !shfseq ) )
     405           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     406             : 
     407           6 :       ulong const * fseq = fd_fseq_join( shfseq );
     408           6 :       if( FD_UNLIKELY( !fseq ) )
     409           0 :         FD_LOG_ERR(( "%i: %s: fd_fseq_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     410             : 
     411           6 :       if( !verbose ) printf( "%lu\n", fd_fseq_query( fseq ) );
     412           3 :       else {
     413           3 :         printf( "fseq %s\n", _shfseq );
     414           3 :         printf( "\tseq0 %lu\n", fd_fseq_seq0 ( fseq ) );
     415           3 :         printf( "\tseq  %lu\n", fd_fseq_query( fseq ) );
     416           3 :         uchar const * a = (uchar const *)fd_fseq_app_laddr_const( fseq );
     417           3 :         ulong app_sz;
     418         291 :         for( app_sz=FD_FSEQ_APP_FOOTPRINT; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
     419           3 :         ulong off = 0UL;
     420           3 :         printf( "\tapp  %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     421           3 :                 (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     422           3 :                 (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     423           3 :         for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
     424           0 :           printf( "\t     %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     425           3 :                   (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     426           3 :                   (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     427           3 :         if( off<FD_FSEQ_APP_FOOTPRINT ) printf( "\t     ... snip (all remaining are zero) ...\n" );
     428           3 :       }
     429             : 
     430           6 :       fd_wksp_unmap( fd_fseq_leave( fseq ) );
     431             : 
     432           6 :       FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shfseq, verbose ));
     433           6 :       SHIFT( 2 );
     434             : 
     435         180 :     } else if( !strcmp( cmd, "update-fseq" ) ) {
     436             : 
     437           0 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     438             : 
     439           0 :       char const * _shfseq =                   argv[0];
     440           0 :       ulong        seq     = fd_cstr_to_ulong( argv[1] );
     441             : 
     442           0 :       void * shfseq = fd_wksp_map( _shfseq );
     443           0 :       if( FD_UNLIKELY( !shfseq ) )
     444           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     445             : 
     446           0 :       ulong * fseq = fd_fseq_join( shfseq );
     447           0 :       if( FD_UNLIKELY( !fseq ) )
     448           0 :         FD_LOG_ERR(( "%i: %s: fd_fseq_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shfseq, bin ));
     449             : 
     450           0 :       fd_fseq_update( fseq, seq );
     451             : 
     452           0 :       fd_wksp_unmap( fd_fseq_leave( fseq ) );
     453             : 
     454           0 :       FD_LOG_NOTICE(( "%i: %s %s %lu: success", cnt, cmd, _shfseq, seq ));
     455           0 :       SHIFT( 2 );
     456             : 
     457         180 :     } else if( !strcmp( cmd, "new-cnc" ) ) {
     458             : 
     459          54 :       if( FD_UNLIKELY( argc<4 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     460             : 
     461          54 :       char const * _wksp     =                                                 argv[0];
     462          54 :       ulong        type      =                               fd_cstr_to_ulong( argv[1] );
     463          54 :       long         heartbeat = (!strcmp( argv[2], "-"   )) ? fd_log_wallclock() :
     464          54 :                              ( (!strcmp( argv[2], "tic" )) ? fd_tickcount()     :
     465           3 :                                                              fd_cstr_to_long ( argv[2] ) );
     466          54 :       ulong        app_sz    =                               fd_cstr_to_ulong( argv[3] );
     467             : 
     468          54 :       ulong align     = fd_cnc_align();
     469          54 :       ulong footprint = fd_cnc_footprint( app_sz );
     470          54 :       if( FD_UNLIKELY( !footprint ) ) {
     471           0 :         FD_LOG_ERR(( "%i: %s: bad app-sz (%lu)\n\tDo %s help for help", cnt, cmd, app_sz, bin ));
     472           0 :       }
     473             : 
     474          54 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
     475          54 :       if( FD_UNLIKELY( !wksp ) ) {
     476           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
     477           0 :       }
     478             : 
     479          54 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
     480          54 :       if( FD_UNLIKELY( !gaddr ) ) {
     481           0 :         fd_wksp_detach( wksp );
     482           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
     483           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
     484           0 :       }
     485             : 
     486          54 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
     487          54 :       if( FD_UNLIKELY( !shmem ) ) {
     488           0 :         fd_wksp_free( wksp, gaddr );
     489           0 :         fd_wksp_detach( wksp );
     490           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
     491           0 :       }
     492             : 
     493          54 :       void * shcnc = fd_cnc_new( shmem, app_sz, type, heartbeat );
     494          54 :       if( FD_UNLIKELY( !shcnc ) ) {
     495           0 :         fd_wksp_free( wksp, gaddr );
     496           0 :         fd_wksp_detach( wksp );
     497           0 :         FD_LOG_ERR(( "%i: %s: fd_cnc_new( %s:%lu, %lu, %lu, %li ) failed\n\tDo %s help for help",
     498           0 :                      cnt, cmd, _wksp, gaddr, app_sz, type, heartbeat, bin ));
     499           0 :       }
     500             : 
     501          54 :       char buf[ FD_WKSP_CSTR_MAX ];
     502          54 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
     503             : 
     504          54 :       fd_wksp_detach( wksp );
     505             : 
     506          54 :       FD_LOG_NOTICE(( "%i: %s %s %lu %li %lu: success", cnt, cmd, _wksp, type, heartbeat, app_sz ));
     507          54 :       SHIFT( 4 );
     508             : 
     509         126 :     } else if( !strcmp( cmd, "delete-cnc" ) ) {
     510             : 
     511           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     512             : 
     513           3 :       char const * _shcnc = argv[0];
     514             : 
     515           3 :       void * shcnc = fd_wksp_map( _shcnc );
     516           3 :       if( FD_UNLIKELY( !shcnc ) )
     517           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     518           3 :       if( FD_UNLIKELY( !fd_cnc_delete( shcnc ) ) )
     519           0 :         FD_LOG_ERR(( "%i: %s: fd_cnc_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     520           3 :       fd_wksp_unmap( shcnc );
     521             : 
     522           3 :       fd_wksp_cstr_free( _shcnc );
     523             : 
     524           3 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, _shcnc ));
     525           3 :       SHIFT( 1 );
     526             : 
     527         123 :     } else if( !strcmp( cmd, "query-cnc" ) ) {
     528             : 
     529           6 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     530             : 
     531           6 :       char const * _shcnc  =                 argv[0];
     532           6 :       int          verbose = fd_cstr_to_int( argv[1] );
     533             : 
     534           6 :       void * shcnc = fd_wksp_map( _shcnc );
     535           6 :       if( FD_UNLIKELY( !shcnc ) )
     536           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     537             : 
     538           6 :       fd_cnc_t const * cnc = fd_cnc_join( shcnc );
     539           6 :       if( FD_UNLIKELY( !cnc ) )
     540           0 :         FD_LOG_ERR(( "%i: %s: fd_cnc_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     541             : 
     542           6 :       char buf[ FD_CNC_SIGNAL_CSTR_BUF_MAX ];
     543             : 
     544           6 :       if( !verbose ) printf( "%lu\n", cnc->signal );
     545           3 :       else {
     546           3 :         printf( "cnc %s\n", _shcnc );
     547           3 :         printf( "\tapp-sz     %lu\n",      cnc->app_sz                                         );
     548           3 :         printf( "\ttype       %lu\n",      cnc->type                                           );
     549           3 :         printf( "\theartbeat0 %li\n",      cnc->heartbeat0                                     );
     550           3 :         printf( "\theartbeat  %li\n",      cnc->heartbeat                                      );
     551           3 :         printf( "\tlock       %lu\n",      cnc->lock                                           );
     552           3 :         printf( "\tsignal     %s (%lu)\n", fd_cnc_signal_cstr( cnc->signal, buf ), cnc->signal );
     553             : 
     554           3 :         uchar const * a = (uchar const *)fd_cnc_app_laddr_const( cnc );
     555           3 :         ulong app_sz;
     556       12291 :         for( app_sz=cnc->app_sz; app_sz; app_sz-- ) if( a[app_sz-1UL] ) break;
     557           3 :         ulong off = 0UL;
     558           3 :         printf( "\tapp        %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     559           3 :                 (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     560           3 :                 (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     561           3 :         for( off+=16UL, a+=16UL; off<app_sz; off+=16UL, a+=16UL )
     562           0 :           printf( "\t           %04lx: %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x\n", off,
     563           3 :                   (uint)a[ 0], (uint)a[ 1], (uint)a[ 2], (uint)a[ 3], (uint)a[ 4], (uint)a[ 5], (uint)a[ 6], (uint)a[ 7],
     564           3 :                   (uint)a[ 8], (uint)a[ 9], (uint)a[10], (uint)a[11], (uint)a[12], (uint)a[13], (uint)a[14], (uint)a[15] );
     565           3 :         if( off<cnc->app_sz ) printf( "\t           ... snip (all remaining are zero) ...\n" );
     566           3 :       }
     567             : 
     568           6 :       fd_wksp_unmap( fd_cnc_leave( cnc ) );
     569             : 
     570           6 :       FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, _shcnc, verbose ));
     571           6 :       SHIFT( 2 );
     572             : 
     573         117 :     } else if( !strcmp( cmd, "signal-cnc" ) ) {
     574             : 
     575         102 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     576             : 
     577         102 :       char const * _shcnc =                        argv[0];
     578         102 :       ulong        signal = fd_cstr_to_cnc_signal( argv[1] );
     579             : 
     580         102 :       char buf[ FD_CNC_SIGNAL_CSTR_BUF_MAX ];
     581             : 
     582         102 :       if( FD_UNLIKELY( signal<FD_CNC_SIGNAL_HALT ) )
     583           0 :         FD_LOG_ERR(( "%i: %s: invalid signal %s (%lu) to send\n\tDo %s help for help",
     584         102 :                      cnt, cmd, fd_cnc_signal_cstr( signal, buf ), signal, bin ));
     585             : 
     586         102 :       void * shcnc = fd_wksp_map( _shcnc );
     587         102 :       if( FD_UNLIKELY( !shcnc ) )
     588           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     589             : 
     590         102 :       fd_cnc_t * cnc = fd_cnc_join( shcnc );
     591         102 :       if( FD_UNLIKELY( !cnc ) )
     592           0 :         FD_LOG_ERR(( "%i: %s: fd_cnc_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _shcnc, bin ));
     593             : 
     594         102 :       int err = fd_cnc_open( cnc );
     595         102 :       if( FD_UNLIKELY( err ) )
     596           0 :         FD_LOG_ERR(( "%i: %s: fd_cnc_open( \"%s\" ) failed (%i-%s)\n\tDo %s help for help",
     597         102 :                      cnt, cmd, _shcnc, err, fd_cnc_strerror( err ), bin ));
     598             : 
     599         102 :       fd_cnc_signal( cnc, signal );
     600             : 
     601         102 :       ulong response = fd_cnc_wait( cnc, signal, LONG_MAX, NULL );
     602         102 :       printf( "%s\n", fd_cnc_signal_cstr( response, buf ) );
     603             : 
     604         102 :       fd_cnc_close( cnc );
     605             : 
     606         102 :       fd_wksp_unmap( fd_cnc_leave( cnc ) );
     607             : 
     608         102 :       FD_LOG_NOTICE(( "%i: %s %s %s: success", cnt, cmd, _shcnc, fd_cnc_signal_cstr( signal, buf ) ));
     609         102 :       SHIFT( 2 );
     610             : 
     611         102 :     } else if( !strcmp( cmd, "new-tcache" ) ) {
     612             : 
     613           3 :       if( FD_UNLIKELY( argc<3 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     614             : 
     615           3 :       char const * _wksp     =                   argv[0];
     616           3 :       ulong        depth     = fd_cstr_to_ulong( argv[1] );
     617           3 :       ulong        map_cnt   = fd_cstr_to_ulong( argv[2] );
     618             : 
     619           3 :       ulong align     = fd_tcache_align();
     620           3 :       ulong footprint = fd_tcache_footprint( depth, map_cnt );
     621           3 :       if( FD_UNLIKELY( !footprint ) ) {
     622           0 :         FD_LOG_ERR(( "%i: %s: bad depth (%lu) and/or map_cnt (%lu)\n\tDo %s help for help", cnt, cmd, depth, map_cnt, bin ));
     623           0 :       }
     624             : 
     625           3 :       fd_wksp_t * wksp = fd_wksp_attach( _wksp );
     626           3 :       if( FD_UNLIKELY( !wksp ) ) {
     627           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_attach( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, _wksp, bin ));
     628           0 :       }
     629             : 
     630           3 :       ulong gaddr = fd_wksp_alloc( wksp, align, footprint, tag );
     631           3 :       if( FD_UNLIKELY( !gaddr ) ) {
     632           0 :         fd_wksp_detach( wksp );
     633           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_alloc( \"%s\", %lu, %lu, %lu ) failed\n\tDo %s help for help",
     634           0 :                      cnt, cmd, _wksp, align, footprint, tag, bin ));
     635           0 :       }
     636             : 
     637           3 :       void * shmem = fd_wksp_laddr( wksp, gaddr );
     638           3 :       if( FD_UNLIKELY( !shmem ) ) {
     639           0 :         fd_wksp_free( wksp, gaddr );
     640           0 :         fd_wksp_detach( wksp );
     641           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_laddr( \"%s\", %lu ) failed\n\tDo %s help for help", cnt, cmd, _wksp, gaddr, bin ));
     642           0 :       }
     643             : 
     644           3 :       void * _tcache = fd_tcache_new( shmem, depth, map_cnt );
     645           3 :       if( FD_UNLIKELY( !_tcache ) ) {
     646           0 :         fd_wksp_free( wksp, gaddr );
     647           0 :         fd_wksp_detach( wksp );
     648           0 :         FD_LOG_ERR(( "%i: %s: fd_tcache_new( %s:%lu, %lu, %lu ) failed\n\tDo %s help for help",
     649           0 :                      cnt, cmd, _wksp, gaddr, depth, map_cnt, bin ));
     650           0 :       }
     651             : 
     652           3 :       char buf[ FD_WKSP_CSTR_MAX ];
     653           3 :       printf( "%s\n", fd_wksp_cstr( wksp, gaddr, buf ) );
     654             : 
     655           3 :       fd_wksp_detach( wksp );
     656             : 
     657           3 :       FD_LOG_NOTICE(( "%i: %s %s %lu %lu: success", cnt, cmd, _wksp, depth, map_cnt ));
     658           3 :       SHIFT( 3 );
     659             : 
     660          12 :     } else if( !strcmp( cmd, "delete-tcache" ) ) {
     661             : 
     662           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     663             : 
     664           3 :       char const * gaddr = argv[0];
     665             : 
     666           3 :       void * _tcache = fd_wksp_map( gaddr );
     667           3 :       if( FD_UNLIKELY( !_tcache ) )
     668           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     669           3 :       if( FD_UNLIKELY( !fd_tcache_delete( _tcache ) ) )
     670           0 :         FD_LOG_ERR(( "%i: %s: fd_tcache_delete( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     671           3 :       fd_wksp_unmap( _tcache );
     672             : 
     673           3 :       fd_wksp_cstr_free( gaddr );
     674             : 
     675           3 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, gaddr ));
     676           3 :       SHIFT( 1 );
     677             : 
     678           9 :     } else if( !strcmp( cmd, "query-tcache" ) ) {
     679             : 
     680           6 :       if( FD_UNLIKELY( argc<2 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     681             : 
     682           6 :       char const * gaddr  =                  argv[0];
     683           6 :       int          verbose = fd_cstr_to_int( argv[1] );
     684             : 
     685           6 :       void * _tcache = fd_wksp_map( gaddr );
     686           6 :       if( FD_UNLIKELY( !_tcache ) )
     687           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     688             : 
     689           6 :       fd_tcache_t * tcache = fd_tcache_join( _tcache );
     690           6 :       if( FD_UNLIKELY( !tcache ) )
     691           0 :         FD_LOG_ERR(( "%i: %s: fd_tcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     692             : 
     693           6 :       printf( "tcache %s\n", gaddr );
     694           6 :       printf( "\tdepth   %lu\n", tcache->depth   );
     695           6 :       printf( "\tmap_cnt %lu\n", tcache->map_cnt );
     696             : 
     697           6 :       fd_wksp_unmap( fd_tcache_leave( tcache ) );
     698             : 
     699           6 :       FD_LOG_NOTICE(( "%i: %s %s %i: success", cnt, cmd, gaddr, verbose ));
     700           6 :       SHIFT( 2 );
     701             : 
     702           6 :     } else if( !strcmp( cmd, "reset-tcache" ) ) {
     703             : 
     704           3 :       if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "%i: %s: too few arguments\n\tDo %s help for help", cnt, cmd, bin ));
     705             : 
     706           3 :       char const * gaddr = argv[0];
     707             : 
     708           3 :       void * _tcache = fd_wksp_map( gaddr );
     709           3 :       if( FD_UNLIKELY( !_tcache ) )
     710           0 :         FD_LOG_ERR(( "%i: %s: fd_wksp_map( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     711             : 
     712           3 :       fd_tcache_t * tcache = fd_tcache_join( _tcache );
     713           3 :       if( FD_UNLIKELY( !tcache ) )
     714           0 :         FD_LOG_ERR(( "%i: %s: fd_tcache_join( \"%s\" ) failed\n\tDo %s help for help", cnt, cmd, gaddr, bin ));
     715             : 
     716           3 :       fd_tcache_reset( fd_tcache_ring_laddr( tcache ), fd_tcache_depth  ( tcache ),
     717           3 :                        fd_tcache_map_laddr ( tcache ), fd_tcache_map_cnt( tcache ) );
     718             : 
     719           3 :       fd_wksp_unmap( fd_tcache_leave( tcache ) );
     720             : 
     721           3 :       FD_LOG_NOTICE(( "%i: %s %s: success", cnt, cmd, gaddr ));
     722           3 :       SHIFT( 1 );
     723             : 
     724           3 :     } else {
     725             : 
     726           0 :       FD_LOG_ERR(( "%i: %s: unknown command\n\t"
     727           0 :                    "Do %s help for help", cnt, cmd, bin ));
     728             : 
     729           0 :     }
     730         300 :     cnt++;
     731         300 :   }
     732             : 
     733         180 :   if( FD_UNLIKELY( cnt<1 ) ) FD_LOG_NOTICE(( "processed %i commands\n\tDo %s help for help", cnt, bin ));
     734         177 :   else                       FD_LOG_NOTICE(( "processed %i commands", cnt ));
     735             : 
     736         180 : # undef SHIFT
     737         180 :   fd_halt();
     738         180 :   return 0;
     739         180 : }
     740             : 
     741             : #else
     742             : 
     743             : int
     744             : main( int     argc,
     745             :       char ** argv ) {
     746             :   fd_boot( &argc, &argv );
     747             :   if( FD_UNLIKELY( argc<1 ) ) FD_LOG_ERR(( "No arguments" ));
     748             :   if( FD_UNLIKELY( argc>1 ) ) FD_LOG_ERR(( "fd_tango_ctl not supported on this platform" ));
     749             :   FD_LOG_NOTICE(( "processed 0 commands" ));
     750             :   fd_halt();
     751             :   return 0;
     752             : }
     753             : 
     754             : #endif
     755             : 

Generated by: LCOV version 1.14