53                                      {
   54   bool print_addresses = false;
   55   bool print_functions = false;
   56   bool pretty = false;
   57   std::vector<std::string> addresses;
   58   std::string filename = "a.out";
   59   for(int i = 1; i < argc; ++i) {
   60      std::string arg = 
argv[i];
 
   61      if(arg == "-h" || arg == "--help") {
   62        std::cerr << 
"Usage: " << 
argv[0] << 
" [-h] [-a] [-C] [-e wasm] [-f] [-s] [-i] [-p] address..." << std::endl;
 
   63          return 0;
   64      } else if(arg == "-a" || arg == "--addresses") {
   65         print_addresses = true;
   66      } 
else if(arg == 
"-C" || 
starts_with(arg, 
"--demangle=")) {
 
   67         
   68      } else if(arg == "-e") {
   69         if(++i < argc) {
   71         } else {
   72            std::cerr << "Missing argument to -e" << std::endl;
   73            return 2;
   74         }
   76         filename = arg.substr(6);
   77      } else if(arg == "-f" || arg == "--functions") {
   78         print_functions = true;
   79      } else if(arg == "-s" || arg == "--basenames") {
   80         
   81      } else if(arg == "-i" || arg == "--inlines") {
   82         
   83      } else if(arg == "-p" || arg == "--pretty-print") {
   84         pretty = true;
   85      } else if(arg[0] != '-') {
   86         addresses.push_back(arg);
   87      } else {
   88         std::cerr << "unexpected argument: " << arg << std::endl;
   89         return 2;
   90      }
   91   }
   92 
   93   std::vector<std::string> function_names;
   94 
   98   module mod;
  100   parser.parse_module(code, mod, info);
  101   {
  102      for(std::size_t i = 0; i < info.function_offsets.size(); ++i) {
  104            function_names.push_back(std::string(
reinterpret_cast<const char*
>(
name->raw()), 
name->size()));
 
  105         } else {
  106            function_names.push_back("fn" + std::to_string( i + mod.get_imported_functions_size()));
  107         }
  108      }
  109   }
  110 
  111   std::string_view sep = pretty ? " " : "\n";
  112 
  113   auto print_one_address = [&](const std::string& addr) {
  114      unsigned x = std::stoul(addr, nullptr, 16);
  115      if(print_addresses) {
  116         std::cout << std::showbase << std::hex << x << sep;
  117      }
  118      if(print_functions) {
  119         std::cout << std::hex << function_names[info.get_function(x)] << sep;
  120      }
  121      std::cout << "??:0\n";
  122   };
  123 
  124   if(!addresses.empty()) {
  125      for(const auto& addr : addresses) {
  126         print_one_address(addr);
  127      }
  128   } else {
  129      std::string addr;
  130      while(std::cin >> addr) {
  131         print_one_address(addr);
  132      }
  133   }
  134}
sysio::vm::guarded_vector< uint8_t > * find_export_name(sysio::vm::module &mod, uint32_t idx)
bool starts_with(std::string_view arg, std::string_view prefix)
std::vector< uint8_t > read_wasm(const std::string &fname)
Immutable except for fc::from_variant.