Skip to content

Commit 2b93e81

Browse files
Provide a user setting to set default vmArgs (#891)
1 parent 5f1a6ed commit 2b93e81

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
120120
- `java.debug.settings.stepping.skipConstructors`: Skip constructor methods when stepping.
121121
- `java.debug.settings.jdwp.limitOfVariablesPerJdwpRequest`: The maximum number of variables or fields that can be requested in one JDWP request. The higher the value, the less frequently debuggee will be requested when expanding the variable view. Also a large number can cause JDWP request timeout. Defaults to 100.
122122
- `java.debug.settings.jdwp.requestTimeout`: The timeout (ms) of JDWP request when the debugger communicates with the target JVM. Defaults to 3000.
123+
- `java.debug.settings.vmArgs`: The default VM arguments to launch the Java program. Eg. Use '-Xmx1G -ea' to increase the heap size to 1GB and enable assertions. If you want to customize the VM arguments for a specific debug session, please modify the 'vmArgs' config in launch.json.
123124

124125
Pro Tip: The documentation [Configuration.md](https://github.com/microsoft/vscode-java-debug/blob/master/Configuration.md) provides lots of samples to demonstrate how to use these debug configurations, recommend to take a look.
125126

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,11 @@
730730
"description": "%java.debugger.configuration.jdwp.requestTimeout.description%",
731731
"default": 3000,
732732
"minimum": 100
733+
},
734+
"java.debug.settings.vmArgs": {
735+
"type": "string",
736+
"description": "%java.debugger.configuration.vmArgs.description%",
737+
"default": ""
733738
}
734739
}
735740
}

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@
5757
"java.debugger.configuration.console": "The specified console to launch Java program. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json.",
5858
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "Skip the specified classes when breaking on exception. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo",
5959
"java.debugger.configuration.jdwp.limitOfVariablesPerJdwpRequest.description": "The maximum number of variables or fields that can be requested in one JDWP request. The higher the value, the less frequently debuggee will be requested when expanding the variable view. Also a large number can cause JDWP request timeout.",
60-
"java.debugger.configuration.jdwp.requestTimeout.description": "The timeout (ms) of JDWP request when the debugger communicates with the target JVM."
60+
"java.debugger.configuration.jdwp.requestTimeout.description": "The timeout (ms) of JDWP request when the debugger communicates with the target JVM.",
61+
"java.debugger.configuration.vmArgs.description": "The default VM arguments to launch the Java program. Eg. Use '-Xmx1G -ea' to increase the heap size to 1GB and enable assertions. If you want to customize the VM arguments for a specific debug session, please modify the 'vmArgs' config in launch.json."
6162
}

package.nls.zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"java.debugger.configuration.console": "指定的控制台用于启动Java程序。如果要为特定的调试会话自定义控制台,请修改launch.json中的“console”配置。",
5656
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "当发生异常时,跳过指定的类。你可以使用内置变量,如'$JDK'和'$Libraries'来跳过一组类,或者添加一个特定的类名表达式,如java.*,*.Foo。",
5757
"java.debugger.configuration.jdwp.limitOfVariablesPerJdwpRequest.description": "一次JDWP请求中可以请求的变量或字段的最大数量。该值越高,在展开变量视图时,请求debuggee的频率就越低。同时数量过大也会导致JDWP请求超时。",
58-
"java.debugger.configuration.jdwp.requestTimeout.description": "调试器与目标JVM通信时JDWP请求的超时时间(ms)。"
58+
"java.debugger.configuration.jdwp.requestTimeout.description": "调试器与目标JVM通信时JDWP请求的超时时间(ms)。",
59+
"java.debugger.configuration.vmArgs.description": "启动Java程序的默认VM参数。例如,使用'-Xmx1G -ea'将堆大小增加到1GB并启用断言。如果要为特定的调试会话定制VM参数,请修改launch.json中的'vmArgs'配置。"
5960
}

src/configurationProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as fs from "fs";
44
import * as _ from "lodash";
55
import * as os from "os";
66
import * as path from "path";
7+
import { debug } from "util";
78
import * as vscode from "vscode";
89

910
import { instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
@@ -173,6 +174,11 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
173174
}
174175

175176
if (config.request === "launch") {
177+
// If the user doesn't specify 'vmArgs' in launch.json, use the global setting to get the default vmArgs.
178+
if (config.vmArgs === undefined) {
179+
const debugSettings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug.settings");
180+
config.vmArgs = debugSettings.vmArgs;
181+
}
176182
// If the user doesn't specify 'console' in launch.json, use the global setting to get the launch console.
177183
if (!config.console) {
178184
const debugSettings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug.settings");

0 commit comments

Comments
 (0)