async run(host: NuclideUri, device: Device, proc: Process): Promise<void> {
   const debuggerService = await getDebuggerService();
   const {processInfo} = await this._javaDebugger.createAndroidDebugInfo({
     targetUri: host,
     packageName: '',
     device,
     pid: proc.pid,
   });
   debuggerService.startDebugging(processInfo);
 }
Beispiel #2
0
export async function debug(
  debugMode: DebugMode,
  activeProjectRoot: ?string,
  target: string,
  useTerminal: boolean,
  scriptArguments: string,
): Promise<void> {
  let processInfo = null;
  invariant(activeProjectRoot != null, 'Active project is null');

  // See if this is a custom debug mode type.
  try {
    // $FlowFB
    const helper = require('./fb-hhvm');
    processInfo = await helper.getCustomLaunchInfo(
      debugMode,
      activeProjectRoot,
      target,
      scriptArguments,
    );
  } catch (e) {}

  if (processInfo == null) {
    if (debugMode === 'script') {
      processInfo = await getLaunchProcessInfo(
        activeProjectRoot,
        target,
        scriptArguments,
        null /* script wrapper */,
        useTerminal,
        '' /* cwdPath */,
      );
    } else {
      await startAttachProcessInfo(
        activeProjectRoot,
        null /* attachPort */,
        true /* serverAttach */,
      );
      return;
    }
  }

  invariant(processInfo != null);
  const debuggerService = await getDebuggerService();
  await debuggerService.startDebugging(processInfo);
}
  _handleDebugButtonClick = async (): Promise<void> => {
    const {targetUri, config} = this.props;
    const {
      atomInputValues,
      booleanValues,
      enumValues,
      processTableValues,
    } = this.state;
    const {launch, vsAdapterType, threads} = config;

    const stringValues = new Map();
    const stringArrayValues = new Map();
    const objectValues = new Map();
    const numberValues = new Map();
    const jsonValues = new Map();
    this._getConfigurationProperties()
      .filter(
        property => property.visible && atomInputValues.has(property.name),
      )
      .forEach(property => {
        const {name, type} = property;
        const itemType = idx(property, _ => _.itemType);
        const value = atomInputValues.get(name) || '';
        if (type === 'string') {
          stringValues.set(name, value);
        } else if (type === 'array' && itemType === 'string') {
          stringArrayValues.set(name, shellParse(value));
        } else if (type === 'object') {
          const objectValue = {};
          shellParse(value).forEach(variable => {
            const [lhs, rhs] = variable.split('=');
            objectValue[lhs] = rhs;
          });
          objectValues.set(name, objectValue);
        } else if (type === 'number') {
          numberValues.set(name, Number(value));
        } else if (type === 'json') {
          jsonValues.set(name, JSON.parse(value));
        }
      });

    const values = {};
    [
      booleanValues,
      enumValues,
      stringValues,
      stringArrayValues,
      objectValues,
      numberValues,
      processTableValues,
      jsonValues,
    ].forEach(map => {
      map.forEach((value, key) => {
        values[key] = value;
      });
    });

    this._getConfigurationProperties()
      .filter(
        property => !property.visible && !atomInputValues.has(property.name),
      )
      .forEach(property => {
        const {name} = property;
        values[name] = idx(property, _ => _.defaultValue);
      });

    const debuggerService = await getDebuggerService();
    debuggerService.startVspDebugging({
      targetUri,
      debugMode: launch ? 'launch' : 'attach',
      adapterType: vsAdapterType,
      adapterExecutable: null,
      config: values,
      capabilities: {threads},
      properties: {
        customControlButtons: [],
        threadsComponentTitle: 'Threads',
      },
      customDisposable: new UniversalDisposable(),
    });

    serializeDebuggerConfig(...this._getSerializationArgs(this.props), {
      atomInputValues: Array.from(atomInputValues),
      booleanValues: Array.from(booleanValues),
      enumValues: Array.from(enumValues),
    });
  };