LCOV - code coverage report
Current view: top level - proto - PrintSharedMemory.cc (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 42 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #include "artdaq-core/Core/SharedMemoryEventReceiver.hh"
       2              : #include "artdaq-core/Utilities/configureMessageFacility.hh"
       3              : #include "artdaq/DAQdata/Globals.hh"
       4              : 
       5              : #include <boost/program_options.hpp>
       6              : namespace bpo = boost::program_options;
       7              : 
       8              : #include <sstream>
       9              : 
      10            0 : int main(int argc, char* argv[])
      11              : try
      12              : {
      13            0 :         artdaq::configureMessageFacility("PrintSharedMemory");
      14              : 
      15            0 :         std::ostringstream descstr;
      16              :         descstr << *argv
      17            0 :                 << " [-M <shared memory>] <-e>";
      18            0 :         bpo::options_description desc(descstr.str());
      19            0 :         desc.add_options()("key,M", bpo::value<std::string>(), "Shared Memory to attach to")("events,e", "Print event information")("help,h", "produce help message");
      20            0 :         bpo::variables_map vm;
      21              :         try
      22              :         {
      23            0 :                 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
      24            0 :                 bpo::notify(vm);
      25              :         }
      26            0 :         catch (bpo::error const& e)
      27              :         {
      28              :                 std::cerr << "Exception from command line processing in " << *argv
      29            0 :                           << ": " << e.what() << "\n";
      30            0 :                 return -1;
      31            0 :         }
      32            0 :         if (vm.count("help") != 0u)
      33              :         {
      34            0 :                 std::cout << desc << std::endl;
      35            0 :                 return 1;
      36              :         }
      37              : 
      38            0 :         fhicl::ParameterSet pset;
      39            0 :         if (vm.count("key") != 0u)
      40              :         {
      41            0 :                 pset.put("shared_memory_key", vm["key"].as<std::string>());
      42            0 :                 auto bkey = vm["key"].as<std::string>();
      43            0 :                 if (bkey[2] == 'e' && bkey[3] == 'e')
      44              :                 {
      45            0 :                         bkey[2] = 'b';
      46            0 :                         bkey[3] = 'b';
      47            0 :                         pset.put("broadcast_shared_memory_key", bkey);
      48            0 :                         pset.put("read_event_info", true);
      49              :                 }
      50              :                 else
      51              :                 {
      52            0 :                         pset.put("read_event_info", vm.count("events") > 0);
      53              :                 }
      54            0 :         }
      55              :         else
      56              :         {
      57            0 :                 std::cerr << "You must specify a shared_memory_key in FHiCL or provide one on the command line!" << std::endl;
      58            0 :                 return -2;
      59              :         }
      60              : 
      61            0 :         TLOG() << "Going to read shared memory " << std::showbase << std::hex << pset.get<uint32_t>("shared_memory_key") << " Event Mode: " << std::boolalpha << pset.get<bool>("read_event_info");
      62            0 :         if (pset.get<bool>("read_event_info", false))
      63              :         {
      64            0 :                 artdaq::SharedMemoryEventReceiver t(pset.get<uint32_t>("shared_memory_key"), pset.get<uint32_t>("broadcast_shared_memory_key", pset.get<uint32_t>("shared_memory_key")));
      65            0 :                 std::cout << t.toString() << std::endl;
      66            0 :         }
      67              :         else
      68              :         {
      69            0 :                 artdaq::SharedMemoryManager t(pset.get<uint32_t>("shared_memory_key"), 0, 0, 0);
      70            0 :                 std::cout << t.toString() << std::endl;
      71            0 :         }
      72              : 
      73            0 :         return 0;
      74            0 : }
      75            0 : catch (...)
      76              : {
      77            0 :         return -1;
      78            0 : }
        

Generated by: LCOV version 2.0-1