LCOV - code coverage report
Current view: top level - app/firedancer-dev/commands - reasm.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 45 0.0 %
Date: 2026-02-13 06:06:24 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /* The reasm command joins the replay tile and prints the reasm tree.
       2             :    This is a standalone development application that can be run to
       3             :    inspect the replay tile memory. */
       4             : 
       5             : #include "../../shared/fd_config.h" /* config_t */
       6             : #include "../../shared_dev/commands/dev.h"
       7             : #include "../../../discof/replay/fd_replay_tile.c"
       8             : 
       9             : #include <stdio.h>
      10             : #include <unistd.h>
      11             : 
      12             : fd_topo_run_tile_t
      13             : fdctl_tile_run( fd_topo_tile_t const * tile );
      14             : 
      15             : static void
      16             : replay_ctx_wksp( args_t *             args,
      17             :                  config_t *           config,
      18             :                  fd_replay_tile_t **  replay_ctx,
      19           0 :                  fd_topo_wksp_t **    replay_wksp ) {
      20           0 :   (void)args;
      21             : 
      22           0 :   fd_topo_t * topo = &config->topo;
      23             : 
      24           0 :   ulong tile_id = fd_topo_find_tile( topo, "replay", 0UL );
      25           0 :   if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "replay tile not found" ));
      26             : 
      27           0 :   fd_topo_tile_t * tile = &topo->tiles[ tile_id ];
      28             : 
      29             :   /* Get the workspace that contains the tile's scratch memory */
      30           0 :   ulong scratch_wksp_id = topo->objs[ tile->tile_obj_id ].wksp_id;
      31           0 :   if( FD_UNLIKELY( scratch_wksp_id>=topo->wksp_cnt ) ) FD_LOG_ERR(( "invalid workspace id %lu for tile scratch", scratch_wksp_id ));
      32             : 
      33           0 :   fd_topo_wksp_t * _replay_wksp = &topo->workspaces[ scratch_wksp_id ];
      34           0 :   fd_topo_join_workspace( topo, _replay_wksp, FD_SHMEM_JOIN_MODE_READ_ONLY, FD_TOPO_CORE_DUMP_LEVEL_DISABLED );
      35             : 
      36             :   /* Access the replay tile scratch memory where replay_tile_ctx is stored */
      37           0 :   void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
      38           0 :   if( FD_UNLIKELY( !scratch ) ) FD_LOG_ERR(( "Failed to access replay tile scratch memory" ));
      39             : 
      40           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
      41           0 :   fd_replay_tile_t * _replay_ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_replay_tile_t), sizeof(fd_replay_tile_t) );
      42             : 
      43           0 :   *replay_ctx  = _replay_ctx;
      44           0 :   *replay_wksp = _replay_wksp;
      45           0 : }
      46             : 
      47             : static void
      48             : reasm_cmd_fn( args_t *   args,
      49           0 :               config_t * config ) {
      50           0 :   (void)args;
      51           0 :   fd_replay_tile_t * replay_ctx;
      52           0 :   fd_topo_wksp_t *   replay_wksp;
      53           0 :   replay_ctx_wksp( args, config, &replay_ctx, &replay_wksp );
      54             : 
      55           0 :   ulong reasm_gaddr  = fd_wksp_gaddr_fast( replay_ctx->wksp, replay_ctx->reasm );
      56           0 :   fd_reasm_t * reasm = (fd_reasm_t *)fd_wksp_laddr( replay_wksp->wksp, reasm_gaddr );
      57             : 
      58           0 :   for( ;; ) {
      59           0 :     ulong root_slot = replay_ctx->consensus_root_slot;
      60           0 :     if( root_slot == ULONG_MAX ) {
      61           0 :       printf( "root_slot: ULONG_MAX (not set)\n" );
      62           0 :     } else {
      63           0 :       printf( "root_slot: %lu\n", root_slot );
      64           0 :     }
      65             : 
      66           0 :     fd_reasm_print( reasm );
      67             : 
      68           0 :     fflush( stdout );
      69           0 :     sleep( 1 );
      70           0 :   }
      71           0 : }
      72             : 
      73             : static const char * HELP =
      74             :   "\n\n"
      75             :   "usage: reasm [-h]\n"
      76             :   "\n"
      77             :   "optional arguments:\n"
      78             :   "  -h, --help            show this help message and exit\n";
      79             : 
      80             : void
      81           0 : reasm_cmd_help( char const * arg ) {
      82           0 :   (void)arg;
      83           0 :   FD_LOG_NOTICE(( "%s", HELP ));
      84           0 : }
      85             : 
      86             : void
      87             : reasm_cmd_args( int *    pargc,
      88             :                 char *** pargv,
      89           0 :                 args_t * args ) {
      90           0 :   (void)pargc;
      91           0 :   (void)pargv;
      92           0 :   (void)args;
      93             :   /* no args yet */
      94           0 : }
      95             : 
      96             : action_t fd_action_reasm = {
      97             :   .name = "reasm",
      98             :   .args = reasm_cmd_args,
      99             :   .fn   = reasm_cmd_fn,
     100             :   .perm = dev_cmd_perm,
     101             : };
     102             : 

Generated by: LCOV version 1.14