tools/fidlcat/main.cc
// Add the startup actions to the loop: connect, attach to pid, set breakpoints.
Add the startup actions to the loop: connect, attach to pid, set breakpoints.
Add the startup actions to the loop : connect attach to pid set breakpoints .
void EnqueueStartup(InterceptionWorkflow* workflow, const CommandLineOptions& options,
                    const std::vector<std::string>& params) {
  std::vector<zx_koid_t> process_koids;
  if (!options.remote_pid.empty()) {
    for (const std::string& pid_str : options.remote_pid) {
      zx_koid_t process_koid = strtoull(pid_str.c_str(), nullptr, fidl_codec::kDecimalBase);
      if (process_koid == 0) {
        fprintf(stderr, "Invalid pid %s\n", pid_str.c_str());
        exit(1);
      }
      process_koids.push_back(process_koid);
    }
  }
  std::string host;
  uint16_t port;
  zxdb::Err parse_err = zxdb::ParseHostPort(*(options.connect), &host, &port);
  if (!parse_err.ok()) {
    fprintf(stderr, "Could not parse host/port pair: %s", parse_err.msg().c_str());
    exit(1);
  }
  auto attach = [workflow, process_koids, remote_name = options.remote_name,
                 extra_name = options.extra_name, params](const zxdb::Err& err) {
    if (!err.ok()) {
      fprintf(stderr, "Unable to connect: %s", err.msg().c_str());
      exit(2);
    }
    FX_LOGS(INFO) << "Connected!";
    if (!process_koids.empty()) {
      workflow->Attach(process_koids);
    }
    if (remote_name.empty() && extra_name.empty()) {
      if (std::find(params.begin(), params.end(), "run") != params.end()) {
        zxdb::Target* target = workflow->GetNewTarget();
        workflow->Launch(target, params);
      }
    } else {
      zxdb::Target* target = workflow->GetNewTarget();
      if (std::find(params.begin(), params.end(), "run") != params.end()) {
        workflow->Launch(target, params);
      }
      workflow->Filter(remote_name, true);
      workflow->Filter(extra_name, false);
    }
  };
  auto connect = [workflow, attach = std::move(attach), host, port]() {
    FX_LOGS(INFO) << "Connecting to port " << port << " on " << host << "...";
    workflow->Connect(host, port, attach);
  };
  debug_ipc::MessageLoop::Current()->PostTask(FROM_HERE, connect);
}
void EnqueueStartup ( InterceptionWorkflow * workflow , const CommandLineOptions & options , const std :: vector < std :: string > & params ) { std :: vector < zx_koid_t > process_koids ; if ( ! options . remote_pid . empty ( ) ) { for ( const std :: string & pid_str : options . remote_pid ) { zx_koid_t process_koid = strtoull ( pid_str . c_str ( ) , nullptr , fidl_codec :: kDecimalBase ) ; if ( process_koid == 0 ) { fprintf ( stderr , " \n " , pid_str . c_str ( ) ) ; exit ( 1 ) ; } process_koids . push_back ( process_koid ) ; } } std :: string host ; uint16_t port ; zxdb :: Err parse_err = zxdb :: ParseHostPort ( * ( options . connect ) , & host , & port ) ; if ( ! parse_err . ok ( ) ) { fprintf ( stderr , " " , parse_err . msg ( ) . c_str ( ) ) ; exit ( 1 ) ; } auto attach = [ workflow , process_koids , remote_name = options . remote_name , extra_name = options . extra_name , params ] ( const zxdb :: Err & err ) { if ( ! err . ok ( ) ) { fprintf ( stderr , " " , err . msg ( ) . c_str ( ) ) ; exit ( 2 ) ; } FX_LOGS ( INFO ) << " " ; if ( ! process_koids . empty ( ) ) { workflow -> Attach ( process_koids ) ; } if ( remote_name . empty ( ) && extra_name . empty ( ) ) { if ( std :: find ( params . begin ( ) , params . end ( ) , " " ) != params . end ( ) ) { zxdb :: Target * target = workflow -> GetNewTarget ( ) ; workflow -> Launch ( target , params ) ; } } else { zxdb :: Target * target = workflow -> GetNewTarget ( ) ; if ( std :: find ( params . begin ( ) , params . end ( ) , " " ) != params . end ( ) ) { workflow -> Launch ( target , params ) ; } workflow -> Filter ( remote_name , true ) ; workflow -> Filter ( extra_name , false ) ; } } ; auto connect = [ workflow , attach = std :: move ( attach ) , host , port ] ( ) { FX_LOGS ( INFO ) << " " << port << " " << host << " " ; workflow -> Connect ( host , port , attach ) ; } ; debug_ipc :: MessageLoop :: Current ( ) -> PostTask ( FROM_HERE , connect ) ; }
Add the startup actions to the loop: connect, attach to pid, set breakpoints.
Add the startup actions to the loop : connect attach to pid set breakpoints .
// There is no process 0, and if there were, we probably wouldn't be able to // talk with it. /*main_filter=*/ /*main_filter=*/