Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdt-gdb-adapter

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdt-gdb-adapter - npm Package Compare versions

Comparing version 0.0.14-next.4783033.0 to 0.0.14-next.277a31a.0

dist/integration-tests/diassemble.spec.d.ts

14

dist/GDBBackend.d.ts

@@ -42,12 +42,12 @@ /// <reference types="node" />

sendCommand<T>(command: string): Promise<T>;
sendEnablePrettyPrint(): Promise<{}>;
sendEnablePrettyPrint(): Promise<unknown>;
standardEscape(arg: string): string;
sendFileExecAndSymbols(program: string): Promise<{}>;
sendFileSymbolFile(symbols: string): Promise<{}>;
sendAddSymbolFile(symbols: string, offset: string): Promise<{}>;
sendLoad(imageFileName: string, imageOffset: string | undefined): Promise<{}>;
sendGDBSet(params: string): Promise<{}>;
sendFileExecAndSymbols(program: string): Promise<unknown>;
sendFileSymbolFile(symbols: string): Promise<unknown>;
sendAddSymbolFile(symbols: string, offset: string): Promise<unknown>;
sendLoad(imageFileName: string, imageOffset: string | undefined): Promise<unknown>;
sendGDBSet(params: string): Promise<unknown>;
sendGDBShow(params: string): Promise<MIGDBShowResponse>;
sendGDBExit(): Promise<{}>;
sendGDBExit(): Promise<unknown>;
protected nextToken(): number;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

@@ -51,2 +51,10 @@ import { Handles, Logger, LoggingDebugSession, Response, Thread } from 'vscode-debugadapter';

}
export interface CDTDisassembleArguments extends DebugProtocol.DisassembleArguments {
/**
* Memory reference to the end location containing the instructions to disassemble. When this
* optional setting is provided, the minimum number of lines needed to get to the endMemoryReference
* is used.
*/
endMemoryReference: string;
}
export declare class GDBDebugSession extends LoggingDebugSession {

@@ -61,2 +69,5 @@ protected gdb: GDBBackend;

protected variableHandles: Handles<VariableReference>;
protected logPointMessages: {
[key: string]: string;
};
protected threads: Thread[];

@@ -93,2 +104,3 @@ protected waitPaused?: (value?: void | PromiseLike<void>) => void;

protected memoryRequest(response: MemoryResponse, args: any): Promise<void>;
protected disassembleRequest(response: DebugProtocol.DisassembleResponse, args: CDTDisassembleArguments): Promise<void>;
protected disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments): Promise<void>;

@@ -95,0 +107,0 @@ protected sendStoppedEvent(reason: string, threadId: number, allThreadsStopped?: boolean): void;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,2 +29,4 @@ });

const stoppedEvent_1 = require("./stoppedEvent");
// Allow a single number for ignore count or the form '> [number]'
const ignoreCountRegex = /\s|\>/g;
const arrayRegex = /.*\[[\d]+\].*/;

@@ -41,2 +44,3 @@ const arrayChildRegex = /[\d]+/;

this.variableHandles = new vscode_debugadapter_1.Handles();
this.logPointMessages = {};
this.threads = [];

@@ -66,3 +70,6 @@ this.logger = vscode_debugadapter_1.logger;

response.body.supportsConditionalBreakpoints = true;
response.body.supportsHitConditionalBreakpoints = true;
response.body.supportsLogPoints = true;
// response.body.supportsSetExpression = true;
response.body.supportsDisassembleRequest = true;
this.sendResponse(response);

@@ -166,2 +173,4 @@ }

}
// Reset logPoint messages
this.logPointMessages = {};
try {

@@ -176,2 +185,9 @@ // Need to get the list of current breakpoints in the file and then make sure

const actual = new Array();
const createActual = (breakpoint) => {
return {
id: parseInt(breakpoint.number, 10),
line: breakpoint.line ? parseInt(breakpoint.line, 10) : 0,
verified: true,
};
};
const result = yield mi.sendBreakList(this.gdb);

@@ -182,3 +198,4 @@ result.BreakpointTable.body.forEach((gdbbp) => {

const line = parseInt(gdbbp.line, 10);
if (!breakpoints.find((vsbp) => vsbp.line === line)) {
const breakpoint = breakpoints.find((vsbp) => vsbp.line === line);
if (!breakpoint) {
deletes.push(gdbbp.number);

@@ -196,7 +213,6 @@ }

}
actual.push({
verified: true,
line: gdbbp.line ? parseInt(gdbbp.line, 10) : 0,
id: parseInt(gdbbp.number, 10),
});
actual.push(createActual(gdbbp));
if (breakpoint && breakpoint.logMessage) {
this.logPointMessages[gdbbp.number] = breakpoint.logMessage;
}
return false;

@@ -207,11 +223,27 @@ });

for (const vsbp of inserts) {
let temporary = false;
let ignoreCount;
if (vsbp.hitCondition !== undefined) {
ignoreCount = parseInt(vsbp.hitCondition.replace(ignoreCountRegex, ''), 10);
if (isNaN(ignoreCount)) {
this.sendEvent(new vscode_debugadapter_1.OutputEvent(`Unable to decode expression: ${vsbp.hitCondition}`));
continue;
}
// Allow hit condition continuously above the count
temporary = !vsbp.hitCondition.startsWith('>');
if (temporary) {
// The expression is not 'greater than', decrease ignoreCount to match
ignoreCount--;
}
}
const gdbbp = yield mi.sendBreakInsert(this.gdb, {
location: `${file}:${vsbp.line}`,
condition: vsbp.condition,
temporary,
ignoreCount,
});
actual.push({
id: parseInt(gdbbp.bkpt.number, 10),
line: gdbbp.bkpt.line ? parseInt(gdbbp.bkpt.line, 10) : 0,
verified: true,
});
actual.push(createActual(gdbbp.bkpt));
if (vsbp.logMessage) {
this.logPointMessages[gdbbp.bkpt.number] = vsbp.logMessage;
}
}

@@ -292,3 +324,6 @@ response.body = {

});
return new vscode_debugadapter_1.StackFrame(frameHandle, frame.func || frame.fullname || '', source, line);
const name = frame.func || frame.fullname || '';
const sf = new vscode_debugadapter_1.StackFrame(frameHandle, name, source, line);
sf.instructionPointerReference = frame.addr;
return sf;
});

@@ -560,2 +595,98 @@ response.body = {

}
disassembleRequest(response, args) {
return __awaiter(this, void 0, void 0, function* () {
try {
const meanSizeOfInstruction = 4;
let startOffset = 0;
let lastStartOffset = -1;
const instructions = [];
let oneIterationOnly = false;
outer_loop: while (instructions.length < args.instructionCount && !oneIterationOnly) {
if (startOffset === lastStartOffset) {
// We have stopped getting new instructions, give up
break outer_loop;
}
lastStartOffset = startOffset;
const fetchSize = (args.instructionCount - instructions.length) * meanSizeOfInstruction;
// args.memoryReference is an arbitrary expression, so let GDB do the
// math on resolving value rather than doing the addition in the adapter
try {
const stepStartAddress = `(${args.memoryReference})+${startOffset}`;
let stepEndAddress = `(${args.memoryReference})+${startOffset}+${fetchSize}`;
if (args.endMemoryReference && instructions.length === 0) {
// On the first call, if we have an end memory address use it instead of
// the approx size
stepEndAddress = args.endMemoryReference;
oneIterationOnly = true;
}
const result = yield data_1.sendDataDisassemble(this.gdb, stepStartAddress, stepEndAddress);
for (const asmInsn of result.asm_insns) {
const line = asmInsn.line ? parseInt(asmInsn.line, 10) : undefined;
const source = {
name: asmInsn.file,
path: asmInsn.fullname,
};
for (const asmLine of asmInsn.line_asm_insn) {
let funcAndOffset;
if (asmLine.func_name && asmLine.offset) {
funcAndOffset = `${asmLine.func_name}+${asmLine.offset}`;
}
else if (asmLine.func_name) {
funcAndOffset = asmLine.func_name;
}
else {
funcAndOffset = undefined;
}
const disInsn = {
address: asmLine.address,
instructionBytes: asmLine.opcodes,
instruction: asmLine.inst,
symbol: funcAndOffset,
location: source,
line,
};
instructions.push(disInsn);
if (instructions.length === args.instructionCount) {
break outer_loop;
}
const bytes = asmLine.opcodes.replace(/\s/g, '');
startOffset += bytes.length;
}
}
}
catch (err) {
// Failed to read instruction -- what best to do here?
// in other words, whose responsibility (adapter or client)
// to reissue reads in smaller chunks to find good memory
while (instructions.length < args.instructionCount) {
const badDisInsn = {
// TODO this should start at byte after last retrieved address
address: `0x${startOffset.toString(16)}`,
instruction: err.message,
};
instructions.push(badDisInsn);
startOffset += 2;
}
break outer_loop;
}
}
if (!args.endMemoryReference) {
while (instructions.length < args.instructionCount) {
const badDisInsn = {
// TODO this should start at byte after last retrieved address
address: `0x${startOffset.toString(16)}`,
instruction: 'failed to retrieve instruction',
};
instructions.push(badDisInsn);
startOffset += 2;
}
}
response.body = { instructions };
this.sendResponse(response);
}
catch (err) {
this.sendErrorResponse(response, 1, err.message);
}
});
}
disconnectRequest(response, args) {

@@ -590,3 +721,9 @@ return __awaiter(this, void 0, void 0, function* () {

case 'breakpoint-hit':
this.sendStoppedEvent('breakpoint', getThreadId(result), getAllThreadsStopped(result));
if (this.logPointMessages[result.bkptno]) {
this.sendEvent(new vscode_debugadapter_1.OutputEvent(this.logPointMessages[result.bkptno]));
mi.sendExecContinue(this.gdb);
}
else {
this.sendStoppedEvent('breakpoint', getThreadId(result), getAllThreadsStopped(result));
}
break;

@@ -593,0 +730,0 @@ case 'end-stepping-range':

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -23,5 +24,5 @@ });

const utils_1 = require("./utils");
describe('breakpoints', () => __awaiter(this, void 0, void 0, function* () {
describe('breakpoints', () => __awaiter(void 0, void 0, void 0, function* () {
let dc;
beforeEach(() => __awaiter(this, void 0, void 0, function* () {
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
dc = yield utils_1.standardBeforeEach();

@@ -35,6 +36,6 @@ yield dc.launchRequest({

}));
afterEach(() => __awaiter(this, void 0, void 0, function* () {
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
yield dc.stop();
}));
it('hits a standard breakpoint', () => __awaiter(this, void 0, void 0, function* () {
it('hits a standard breakpoint', () => __awaiter(void 0, void 0, void 0, function* () {
yield dc.setBreakpointsRequest({

@@ -58,3 +59,3 @@ source: {

}));
it('hits a conditional breakpoint', () => __awaiter(this, void 0, void 0, function* () {
it('hits a conditional breakpoint', () => __awaiter(void 0, void 0, void 0, function* () {
yield dc.setBreakpointsRequest({

@@ -79,3 +80,43 @@ source: {

}));
it('hits a hit conditional breakpoint with >', () => __awaiter(void 0, void 0, void 0, function* () {
yield dc.setBreakpointsRequest({
source: {
name: 'count.c',
path: path.join(utils_1.testProgramsDir, 'count.c'),
},
breakpoints: [
{
column: 1,
line: 4,
hitCondition: '> 5',
},
],
});
yield dc.configurationDoneRequest();
const scope = yield utils_1.getScopes(dc);
const vr = scope.scopes.body.scopes[0].variablesReference;
const vars = yield dc.variablesRequest({ variablesReference: vr });
utils_1.verifyVariable(vars.body.variables[0], 'count', 'int', '5');
}));
it('hits a hit conditional breakpoint without >', () => __awaiter(void 0, void 0, void 0, function* () {
yield dc.setBreakpointsRequest({
source: {
name: 'count.c',
path: path.join(utils_1.testProgramsDir, 'count.c'),
},
breakpoints: [
{
column: 1,
line: 4,
hitCondition: '5',
},
],
});
yield dc.configurationDoneRequest();
const scope = yield utils_1.getScopes(dc);
const vr = scope.scopes.body.scopes[0].variablesReference;
const vars = yield dc.variablesRequest({ variablesReference: vr });
utils_1.verifyVariable(vars.body.variables[0], 'count', 'int', '4');
}));
}));
//# sourceMappingURL=breakpoints.spec.js.map

@@ -22,2 +22,35 @@ import { DebugClient } from 'vscode-debugadapter-testsupport';

/**
* Send a nextRequest and wait for target to stop
*/
next(args: DebugProtocol.NextArguments, expected: {
path?: string | RegExp;
line?: number;
column?: number;
}): Promise<DebugProtocol.StackTraceResponse>;
/**
* Send a stepInRequest and wait for target to stop
*/
stepIn(args: DebugProtocol.StepInArguments, expected: {
path?: string | RegExp;
line?: number;
column?: number;
}): Promise<DebugProtocol.StackTraceResponse>;
/**
* Send a stepOutRequest and wait for target to stop
*/
stepOut(args: DebugProtocol.StepOutArguments, expected: {
path?: string | RegExp;
line?: number;
column?: number;
}): Promise<DebugProtocol.StackTraceResponse>;
/**
* Send a stepBackRequest and wait for target to stop
*/
stepBack(args: DebugProtocol.StepBackArguments, expected: {
path?: string | RegExp;
line?: number;
column?: number;
}): Promise<DebugProtocol.StackTraceResponse>;
waitForOutputEvent(category: string, timeout?: number): Promise<DebugProtocol.OutputEvent>;
/**
* Send a response following a Debug Adapter Reverse Request.

@@ -24,0 +57,0 @@ * @param request original request to respond to.

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -68,2 +69,70 @@ });

/**
* Send a nextRequest and wait for target to stop
*/
next(args, expected) {
return __awaiter(this, void 0, void 0, function* () {
const waitForStopped = this.assertStoppedLocation('step', expected);
const next = this.nextRequest(args);
yield Promise.all([waitForStopped, next]);
return waitForStopped;
});
}
/**
* Send a stepInRequest and wait for target to stop
*/
stepIn(args, expected) {
return __awaiter(this, void 0, void 0, function* () {
const waitForStopped = this.assertStoppedLocation('step', expected);
const next = this.stepInRequest(args);
yield Promise.all([waitForStopped, next]);
return waitForStopped;
});
}
/**
* Send a stepOutRequest and wait for target to stop
*/
stepOut(args, expected) {
return __awaiter(this, void 0, void 0, function* () {
const waitForStopped = this.assertStoppedLocation('step', expected);
const next = this.stepOutRequest(args);
yield Promise.all([waitForStopped, next]);
return waitForStopped;
});
}
/**
* Send a stepBackRequest and wait for target to stop
*/
stepBack(args, expected) {
return __awaiter(this, void 0, void 0, function* () {
const waitForStopped = this.assertStoppedLocation('step', expected);
const next = this.stepBackRequest(args);
yield Promise.all([waitForStopped, next]);
return waitForStopped;
});
}
/*
* Returns a promise that will resolve if an output event with a specific category was received.
* The promise will be rejected if a timeout occurs.
*/
waitForOutputEvent(category, timeout = this.defaultTimeout) {
return __awaiter(this, void 0, void 0, function* () {
const isOutputEvent = (event) => {
return !!event.body && !!event.body.output;
};
const timer = setTimeout(() => {
throw new Error(`no output event with category '${category}' received after ${timeout} ms`);
}, timeout);
while (true) {
const event = yield new Promise((resolve) => this.once('output', (e) => resolve(e)));
if (!isOutputEvent(event)) {
continue;
}
if (event.body.category === category) {
clearTimeout(timer);
return event;
}
}
});
}
/**
* Send a response following a Debug Adapter Reverse Request.

@@ -70,0 +139,0 @@ * @param request original request to respond to.

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -76,3 +77,4 @@ });

&& (msg.includes('The system cannot find the path specified')
|| msg.includes('No such file or directory')));
|| msg.includes('No such file or directory')
|| msg.includes('not found')));
});

@@ -79,0 +81,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -14,11 +15,11 @@ });

const path = require("path");
describe('stop', () => __awaiter(this, void 0, void 0, function* () {
describe('stop', () => __awaiter(void 0, void 0, void 0, function* () {
let dc;
beforeEach(() => __awaiter(this, void 0, void 0, function* () {
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
dc = yield utils_1.standardBeforeEach();
}));
afterEach(() => __awaiter(this, void 0, void 0, function* () {
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
yield dc.stop();
}));
it('handles segv', () => __awaiter(this, void 0, void 0, function* () {
it('handles segv', () => __awaiter(void 0, void 0, void 0, function* () {
yield dc.launchRequest({

@@ -25,0 +26,0 @@ verbose: true,

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -47,2 +48,3 @@ });

openGdbConsole: utils_1.openGdbConsole,
logFile: '/tmp/log',
}, {

@@ -68,3 +70,3 @@ path: varsSrc,

// read the variables
const vr = scope.scopes.body.scopes[0].variablesReference;
let vr = scope.scopes.body.scopes[0].variablesReference;
let vars = yield dc.variablesRequest({ variablesReference: vr });

@@ -83,3 +85,6 @@ chai_1.expect(vars.body.variables.length, 'There is a different number of variables than expected').to.equal(numVars);

// step the program and see that the values were passed to the program and evaluated.
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 1 });
scope = yield utils_1.getScopes(dc);
chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);
vr = scope.scopes.body.scopes[0].variablesReference;
vars = yield dc.variablesRequest({ variablesReference: vr });

@@ -93,4 +98,4 @@ chai_1.expect(vars.body.variables.length, 'There is a different number of variables than expected').to.equal(numVars);

// step past the initialization for the structure
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 1 });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 2 });
scope = yield utils_1.getScopes(dc);

@@ -118,3 +123,3 @@ chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);

// step the program and see that the values were passed to the program and evaluated.
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 3 });
scope = yield utils_1.getScopes(dc);

@@ -131,4 +136,4 @@ chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);

// step past the initialization for the structure
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 1 });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 2 });
scope = yield utils_1.getScopes(dc);

@@ -160,4 +165,4 @@ chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);

// step the program and see that the values were passed to the program and evaluated.
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 3 });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: lineTags['STOP HERE'] + 4 });
scope = yield utils_1.getScopes(dc);

@@ -202,3 +207,3 @@ chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);

// step the program and see that the values were passed to the program and evaluated.
yield dc.nextRequest({ threadId: scope.threadId });
yield dc.next({ threadId: scope.threadId }, { path: varsSrc, line: 25 });
scope = yield utils_1.getScopes(dc);

@@ -205,0 +210,0 @@ chai_1.expect(scope.scopes.body.scopes.length, 'Unexpected number of scopes returned').to.equal(1);

@@ -12,6 +12,7 @@ "use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,0 +19,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -14,4 +15,6 @@ });

// Todo: lots of options
const temp = request.temporary ? '-t ' : '';
const ignore = request.ignoreCount ? `-i ${request.ignoreCount} ` : '';
const escapedLocation = gdb.standardEscape(request.location);
const result = yield gdb.sendCommand(`-break-insert ${escapedLocation}`);
const result = yield gdb.sendCommand(`-break-insert ${temp}${ignore}${escapedLocation}`);
if (request.condition) {

@@ -18,0 +21,0 @@ yield gdb.sendCommand(`-break-condition ${result.bkpt.number} ${request.condition}`);

@@ -20,2 +20,18 @@ /*********************************************************************

}
interface MIDataDisassembleAsmInsn {
address: string;
func_name: string;
offset: string;
opcodes: string;
inst: string;
}
interface MIDataDisassembleSrcAndAsmLine {
line: string;
file: string;
fullname: string;
line_asm_insn: MIDataDisassembleAsmInsn[];
}
interface MIDataDisassembleResponse {
asm_insns: MIDataDisassembleSrcAndAsmLine[];
}
export interface MIGDBDataEvaluateExpressionResponse extends MIResponse {

@@ -26,2 +42,3 @@ value?: string;

export declare function sendDataEvaluateExpression(gdb: GDBBackend, expr: string): Promise<MIGDBDataEvaluateExpressionResponse>;
export declare function sendDataDisassemble(gdb: GDBBackend, startAddress: string, endAddress: string): Promise<MIDataDisassembleResponse>;
export {};

@@ -11,2 +11,11 @@ "use strict";

*********************************************************************/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,2 +30,36 @@ function sendDataReadMemoryBytes(gdb, address, size, offset = 0) {

exports.sendDataEvaluateExpression = sendDataEvaluateExpression;
// https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Data-Manipulation.html#The-_002ddata_002ddisassemble-Command
function sendDataDisassemble(gdb, startAddress, endAddress) {
return __awaiter(this, void 0, void 0, function* () {
// -- 5 == mixed source and disassembly with raw opcodes
// TODO needs to be -- 3 for GDB < 7.11 -- are we supporting such old versions?
const result = yield gdb.sendCommand(`-data-disassemble -s "${startAddress}" -e "${endAddress}" -- 5`);
// cleanup the result data
if (result.asm_insns.length > 0) {
if (!result.asm_insns[0].hasOwnProperty('line_asm_insn')) {
// In this case there is no source info available for any instruction,
// so GDB treats as if we had done -- 2 instead of -- 5
// This bit of code remaps the data to look like it should
const e = {
line_asm_insn: result.asm_insns,
};
result.asm_insns = [e];
}
for (const asmInsn of result.asm_insns) {
if (!asmInsn.hasOwnProperty('line_asm_insn')) {
asmInsn.line_asm_insn = [];
}
for (const line of asmInsn.line_asm_insn) {
const untypeLine = line;
if (untypeLine.hasOwnProperty('func-name')) {
line.func_name = untypeLine['func-name'];
delete untypeLine['func-name'];
}
}
}
}
return Promise.resolve(result);
});
}
exports.sendDataDisassemble = sendDataDisassemble;
//# sourceMappingURL=data.js.map

@@ -15,6 +15,6 @@ /*********************************************************************

}): Promise<MIResponse>;
export declare function sendExecRun(gdb: GDBBackend): Promise<{}>;
export declare function sendExecContinue(gdb: GDBBackend, threadId?: number): Promise<{}>;
export declare function sendExecNext(gdb: GDBBackend, threadId?: number): Promise<{}>;
export declare function sendExecStep(gdb: GDBBackend, threadId?: number): Promise<{}>;
export declare function sendExecFinish(gdb: GDBBackend, threadId?: number): Promise<{}>;
export declare function sendExecRun(gdb: GDBBackend): Promise<unknown>;
export declare function sendExecContinue(gdb: GDBBackend, threadId?: number): Promise<unknown>;
export declare function sendExecNext(gdb: GDBBackend, threadId?: number): Promise<unknown>;
export declare function sendExecStep(gdb: GDBBackend, threadId?: number): Promise<unknown>;
export declare function sendExecFinish(gdb: GDBBackend, threadId?: number): Promise<unknown>;

@@ -203,3 +203,7 @@ "use strict";

case '^':
logger_1.logger.verbose(`GDB result: ${token} ${this.restOfLine()}`);
const rest = this.restOfLine();
for (let i = 0; i < rest.length; i += 1000) {
const msg = i === 0 ? 'result' : '-cont-';
logger_1.logger.verbose(`GDB ${msg}: ${token} ${rest.substr(i, 1000)}`);
}
const command = this.commandQueue[token];

@@ -206,0 +210,0 @@ if (command) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

{
"name": "cdt-gdb-adapter",
"version": "0.0.14-next.4783033.0",
"version": "0.0.14-next.277a31a.0",
"description": "gdb adapter implementing the debug adapter protocol",

@@ -8,4 +8,10 @@ "main": "dist/index.js",

"scripts": {
"install": "node install.js",
"nativebuild": "node-gyp rebuild",
"prepublish": "yarn build",
"build": "tsc",
"watch": "tsc -w",
"clean": "git clean -dfx",
"docker:build": "docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest yarn",
"docker:test": "docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest yarn test",
"test": "yarn test:integration && yarn test:pty && yarn test:integration-run-in-terminal && yarn test:integration-remote-target && yarn test:integration-remote-target-run-in-terminal",

@@ -30,3 +36,4 @@ "test:integration": "cross-env JUNIT_REPORT_PATH=test-reports/integration.xml JUNIT_REPORT_STACK=1 JUNIT_REPORT_PACKAGES=1 mocha --reporter mocha-jenkins-reporter dist/integration-tests/*.spec.js",

"node-addon-api": "^1.6.2",
"vscode-debugadapter": "^1.32.1"
"vscode-debugadapter": "^1.37.1",
"vscode-debugprotocol": "^1.37.0"
},

@@ -47,3 +54,3 @@ "devDependencies": {

"typescript": "^3.1.5",
"vscode-debugadapter-testsupport": "^1.32.0",
"vscode-debugadapter-testsupport": "^1.37.1",
"webpack": "^4.23.1",

@@ -53,3 +60,2 @@ "webpack-cli": "^3.1.2"

"files": [
"binding.gyp",
"dist/**/*.js",

@@ -56,0 +62,0 @@ "dist/**/*.js.map",

@@ -12,4 +12,3 @@ # CDT GDB Debug Adapter

```sh
yarn install
yarn build
yarn
```

@@ -16,0 +15,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc