xdl
Version:
The Expo Development Library
112 lines (109 loc) • 4.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DebugserverClient = void 0;
function _debug() {
const data = _interopRequireDefault(require("debug"));
_debug = function () {
return data;
};
return data;
}
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _gdb() {
const data = require("../protocol/gdb");
_gdb = function () {
return data;
};
return data;
}
function _client() {
const data = require("./client");
_client = function () {
return data;
};
return data;
}
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2021 Expo, Inc.
* Copyright (c) 2018 Drifty Co.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const debug = (0, _debug().default)('expo:xdl:ios:lib:client:debugserver');
class DebugserverClient extends _client().ServiceClient {
constructor(socket) {
super(socket, new (_gdb().GDBProtocolClient)(socket));
this.socket = socket;
}
async setMaxPacketSize(size) {
return this.sendCommand('QSetMaxPacketSize:', [size.toString()]);
}
async setWorkingDir(workingDir) {
return this.sendCommand('QSetWorkingDir:', [workingDir]);
}
async checkLaunchSuccess() {
return this.sendCommand('qLaunchSuccess', []);
}
async attachByName(name) {
const hexName = Buffer.from(name).toString('hex');
return this.sendCommand(`vAttachName;${hexName}`, []);
}
async continue() {
return this.sendCommand('c', []);
}
halt() {
// ^C
debug('Sending ^C to debugserver');
return this.protocolClient.socket.write('\u0003');
}
async kill() {
const msg = {
cmd: 'k',
args: []
};
return this.protocolClient.sendMessage(msg, (resp, resolve, reject) => {
this.protocolClient.socket.write('+');
const parts = resp.split(';');
for (const part of parts) {
if (part.includes('description')) {
// description:{hex encoded message like: "Terminated with signal 9"}
resolve(Buffer.from(part.split(':')[1], 'hex').toString('ascii'));
}
}
});
}
// TODO support app args
// https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#Packets
// A arglen,argnum,arg,
async launchApp(appPath, executableName) {
const fullPath = path().join(appPath, executableName);
const hexAppPath = Buffer.from(fullPath).toString('hex');
const appCommand = `A${hexAppPath.length},0,${hexAppPath}`;
return this.sendCommand(appCommand, []);
}
async sendCommand(cmd, args) {
const msg = {
cmd,
args
};
debug(`Sending command: ${cmd}, args: ${args}`);
const resp = await this.protocolClient.sendMessage(msg);
// we need to ACK as well
this.protocolClient.socket.write('+');
return resp;
}
}
exports.DebugserverClient = DebugserverClient;
//# sourceMappingURL=debugserver.js.map
;