Add a debug flag to allow remote debugging (#524)
With this flag on, it is possible to remote-debug the language server in a java debugger.
This commit is contained in:
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@@ -15,7 +15,11 @@
|
|||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceRoot}/extensions/ql-vscode/out/**/*.js",
|
"${workspaceRoot}/extensions/ql-vscode/out/**/*.js",
|
||||||
],
|
],
|
||||||
"preLaunchTask": "Build"
|
"preLaunchTask": "Build",
|
||||||
|
"env": {
|
||||||
|
// uncomment to allow debugging the language server Java process from a remote java debugger
|
||||||
|
// "DEBUG_LANGUAGE_SERVER": "true"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Launch Unit Tests (vscode-codeql)",
|
"name": "Launch Unit Tests (vscode-codeql)",
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ import { ideServerLogger } from './logging';
|
|||||||
/** Starts a new CodeQL language server process, sending progress messages to the status bar. */
|
/** Starts a new CodeQL language server process, sending progress messages to the status bar. */
|
||||||
export async function spawnIdeServer(config: QueryServerConfig): Promise<StreamInfo> {
|
export async function spawnIdeServer(config: QueryServerConfig): Promise<StreamInfo> {
|
||||||
return window.withProgress({ title: 'CodeQL language server', location: ProgressLocation.Window }, async (progressReporter, _) => {
|
return window.withProgress({ title: 'CodeQL language server', location: ProgressLocation.Window }, async (progressReporter, _) => {
|
||||||
|
const args = ['--check-errors', 'ON_CHANGE'];
|
||||||
|
if (shouldDebug()) {
|
||||||
|
args.push('-J=-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=n,quiet=y');
|
||||||
|
}
|
||||||
const child = cli.spawnServer(
|
const child = cli.spawnServer(
|
||||||
config.codeQlPath,
|
config.codeQlPath,
|
||||||
'CodeQL language server',
|
'CodeQL language server',
|
||||||
['execute', 'language-server'],
|
['execute', 'language-server'],
|
||||||
['--check-errors', 'ON_CHANGE'],
|
args,
|
||||||
ideServerLogger,
|
ideServerLogger,
|
||||||
data => ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
data => ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||||
data => ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
data => ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||||
@@ -24,3 +28,9 @@ export async function spawnIdeServer(config: QueryServerConfig): Promise<StreamI
|
|||||||
return { writer: child.stdin!, reader: child.stdout! };
|
return { writer: child.stdin!, reader: child.stdout! };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldDebug() {
|
||||||
|
return 'DEBUG_LANGUAGE_SERVER' in process.env
|
||||||
|
&& process.env.DEBUG_LANGUAGE_SERVER !== '0'
|
||||||
|
&& process.env.DEBUG_LANGUAGE_SERVER?.toLocaleLowerCase() !== 'false';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user