cdt-gdb-adapter
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -34,1 +34,18 @@ /********************************************************************* | ||
export declare const gdbPath: string | undefined; | ||
export interface LineTags { | ||
[key: string]: number; | ||
} | ||
/** | ||
* Find locations of tags in `sourceFile`. | ||
* | ||
* Instead of referring to source line numbers of test programs directly, | ||
* tests should place tags (usually some comments) in the source files. This | ||
* function finds the line number correspnding to each tag in `tags`. | ||
* | ||
* This function throws if a tag is found more than once or is not found. | ||
* | ||
* @param tags An object where keys are the tags to find, and values are 0. | ||
* This function will modify the object in place to full the values | ||
* with line number. | ||
*/ | ||
export declare function resolveLineTagLocations(sourceFile: string, tags: LineTags): void; |
@@ -22,2 +22,3 @@ "use strict"; | ||
const cp = require("child_process"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
@@ -126,2 +127,35 @@ const debugClient_1 = require("./debugClient"); | ||
} | ||
/** | ||
* Find locations of tags in `sourceFile`. | ||
* | ||
* Instead of referring to source line numbers of test programs directly, | ||
* tests should place tags (usually some comments) in the source files. This | ||
* function finds the line number correspnding to each tag in `tags`. | ||
* | ||
* This function throws if a tag is found more than once or is not found. | ||
* | ||
* @param tags An object where keys are the tags to find, and values are 0. | ||
* This function will modify the object in place to full the values | ||
* with line number. | ||
*/ | ||
function resolveLineTagLocations(sourceFile, tags) { | ||
const lines = fs.readFileSync(sourceFile, { encoding: 'utf-8' }).split('\n'); | ||
for (let i = 0; i < lines.length; i++) { | ||
for (const tag of Object.keys(tags)) { | ||
if (lines[i].includes(tag)) { | ||
if (tags[tag] !== 0) { | ||
throw new Error(`Tag ${tag} has been found twice.`); | ||
} | ||
tags[tag] = i + 1; | ||
} | ||
} | ||
} | ||
for (const tag of Object.keys(tags)) { | ||
const line = tags[tag]; | ||
if (line === 0) { | ||
throw new Error(`Tag ${tag} was not found.`); | ||
} | ||
} | ||
} | ||
exports.resolveLineTagLocations = resolveLineTagLocations; | ||
//# sourceMappingURL=utils.js.map |
@@ -30,3 +30,9 @@ "use strict"; | ||
const numVars = 8; // number of variables in the main() scope of vars.c | ||
before(utils_1.standardBefore); | ||
const lineTags = { | ||
'STOP HERE': 0, | ||
}; | ||
before(function () { | ||
utils_1.standardBefore(); | ||
utils_1.resolveLineTagLocations(varsSrc, lineTags); | ||
}); | ||
beforeEach(function () { | ||
@@ -42,3 +48,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
path: varsSrc, | ||
line: 19, | ||
line: lineTags['STOP HERE'], | ||
}); | ||
@@ -45,0 +51,0 @@ scope = yield utils_1.getScopes(dc); |
@@ -29,3 +29,9 @@ "use strict"; | ||
const varsCppSrc = path.join(utils_1.testProgramsDir, 'vars_cpp.cpp'); | ||
before(utils_1.standardBefore); | ||
const lineTags = { | ||
'STOP HERE': 0, | ||
}; | ||
before(function () { | ||
utils_1.standardBefore(); | ||
utils_1.resolveLineTagLocations(varsCppSrc, lineTags); | ||
}); | ||
beforeEach(function () { | ||
@@ -41,3 +47,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
path: varsCppSrc, | ||
line: 37, | ||
line: lineTags['STOP HERE'], | ||
}); | ||
@@ -44,0 +50,0 @@ scope = yield utils_1.getScopes(dc); |
{ | ||
"name": "cdt-gdb-adapter", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "gdb adapter implementing the debug adapter protocol", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
236661
3133
9