LCOV - code coverage report
Current view: top level - app/fddev - dev1.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 64 0.0 %
Date: 2026-03-31 06:22:16 Functions: 0 5 0.0 %

          Line data    Source code
       1             : #define _GNU_SOURCE
       2             : #include "../platform/fd_sys_util.h"
       3             : #include "../shared/commands/configure/configure.h"
       4             : #include "../shared/commands/run/run.h"
       5             : #include "../shared_dev/commands/dev.h"
       6             : 
       7             : #include <errno.h>
       8             : #include <unistd.h>
       9             : #include <sched.h>
      10             : #include <sys/wait.h>
      11             : 
      12             : extern fd_topo_run_tile_t * TILES[];
      13             : 
      14             : void
      15             : update_config_for_dev( fd_config_t * config );
      16             : 
      17             : int
      18             : agave_main( void * args );
      19             : 
      20             : extern char fd_log_private_path[ 1024 ]; /* empty string on start */
      21             : 
      22           0 : #define FD_LOG_ERR_NOEXIT(a) do { long _fd_log_msg_now = fd_log_wallclock(); fd_log_private_1( 4, _fd_log_msg_now, __FILE__, __LINE__, __func__, fd_log_private_0 a ); } while(0)
      23             : 
      24             : extern int * fd_log_private_shared_lock;
      25             : 
      26             : static void
      27           0 : parent_signal( int sig ) {
      28             :   /* Same hack as in run.c, see comments there. */
      29           0 :   int lock = 0;
      30           0 :   fd_log_private_shared_lock = &lock;
      31             : 
      32           0 :   if( -1!=fd_log_private_logfile_fd() ) FD_LOG_ERR_NOEXIT(( "Received signal %s\nLog at \"%s\"", fd_io_strsignal( sig ), fd_log_private_path ));
      33           0 :   else                                  FD_LOG_ERR_NOEXIT(( "Received signal %s",                fd_io_strsignal( sig ) ));
      34             : 
      35           0 :   if( FD_LIKELY( sig==SIGINT ) ) fd_sys_util_exit_group( 128+SIGINT );
      36           0 :   else                           fd_sys_util_exit_group( 0          );
      37           0 : }
      38             : 
      39             : static void
      40           0 : install_parent_signals( void ) {
      41           0 :   struct sigaction sa = {
      42           0 :     .sa_handler = parent_signal,
      43           0 :     .sa_flags   = 0,
      44           0 :   };
      45           0 :   if( FD_UNLIKELY( sigaction( SIGTERM, &sa, NULL ) ) )
      46           0 :     FD_LOG_ERR(( "sigaction(SIGTERM) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      47           0 :   if( FD_UNLIKELY( sigaction( SIGINT, &sa, NULL ) ) )
      48           0 :     FD_LOG_ERR(( "sigaction(SIGINT) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      49           0 : }
      50             : 
      51             : void
      52             : dev1_cmd_args( int *    pargc,
      53             :                char *** pargv,
      54           0 :                args_t * args) {
      55           0 :   char * usage = "usage: dev1 <tile>";
      56           0 :   if( FD_UNLIKELY( *pargc < 1 ) ) FD_LOG_ERR(( "%s", usage ));
      57             : 
      58           0 :   fd_cstr_ncpy( args->dev1.tile_name, *pargv[ 0 ], sizeof( args->dev1.tile_name ) );
      59             : 
      60           0 :   (*pargc)--;
      61           0 :   (*pargv)++;
      62             : 
      63           0 :   args->dev1.no_configure = fd_env_strip_cmdline_contains( pargc, pargv, "--no-configure" );
      64           0 : }
      65             : 
      66             : void
      67             : dev1_cmd_perm( args_t *         args,
      68             :                fd_cap_chk_t *   chk,
      69           0 :                config_t const * config ) {
      70           0 :   dev_cmd_perm( args, chk, config );
      71           0 : }
      72             : 
      73             : void
      74             : dev1_cmd_fn( args_t *   args,
      75           0 :              config_t * config ) {
      76           0 :   if( FD_LIKELY( !args->dev1.no_configure ) ) {
      77           0 :     args_t configure_args = {
      78           0 :       .configure.command = CONFIGURE_CMD_INIT,
      79           0 :     };
      80           0 :     for( ulong i=0UL; STAGES[i]; i++ )
      81           0 :       configure_args.configure.stages[ i ] = STAGES[ i ];
      82           0 :     configure_cmd_fn( &configure_args, config );
      83           0 :   }
      84             : 
      85           0 :   update_config_for_dev( config );
      86           0 :   run_firedancer_init( config, 1, 0 );
      87             : 
      88           0 :   install_parent_signals();
      89             : 
      90           0 :   if( FD_UNLIKELY( close( 0 ) ) ) FD_LOG_ERR(( "close(0) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      91           0 :   if( FD_UNLIKELY( close( 1 ) ) ) FD_LOG_ERR(( "close(1) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      92           0 :   if( FD_UNLIKELY( close( config->log.lock_fd ) ) ) FD_LOG_ERR(( "close() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      93             : 
      94           0 :   int result = 0;
      95           0 :   if( !strcmp( args->dev1.tile_name, "agave" ) ) {
      96           0 :     result = agave_main( config );
      97           0 :   } else {
      98           0 :     ulong tile_id = fd_topo_find_tile( &config->topo, args->dev1.tile_name, 0UL );
      99           0 :     if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "tile %s not found in topology", args->dev1.tile_name ));
     100             : 
     101           0 :     fd_topo_tile_t * tile = &config->topo.tiles[ tile_id ];
     102             : 
     103           0 :     fd_topo_run_tile_t * runner = NULL;
     104           0 :     for( ulong i=0UL; TILES[ i ]; i++ ) {
     105           0 :       if( FD_UNLIKELY( !strcmp( TILES[ i ]->name, tile->name ) ) ) {
     106           0 :         runner = TILES[ i ];
     107           0 :         break;
     108           0 :       }
     109           0 :     }
     110           0 :     FD_TEST( runner );
     111             : 
     112           0 :     fd_topo_run_tile( &config->topo, tile, config->development.sandbox, 1, config->development.core_dump_level, config->uid, config->gid, -1, NULL, NULL, runner );
     113           0 :   }
     114             : 
     115           0 :   fd_sys_util_exit_group( result );
     116           0 : }
     117             : 
     118             : action_t fd_action_dev1 = {
     119             :   .name             = "dev1",
     120             :   .args             = dev1_cmd_args,
     121             :   .fn               = dev1_cmd_fn,
     122             :   .perm             = dev_cmd_perm,
     123             :   .is_local_cluster = 1,
     124             :   .description      = "Start up a single tile"
     125             : };

Generated by: LCOV version 1.14