serhiy.redko updated this revision to Diff 390182.
serhiy.redko edited the summary of this revision.
serhiy.redko added a comment.
As requested DAP now reports an error in case debug configuration contains
unused target related keys
("program", "coreFile" etc) along with "launchCommands" or "attachCommands"
that must create target.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94997/new/
https://reviews.llvm.org/D94997
Files:
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json
Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -215,7 +215,7 @@
},
"launchCommands": {
"type": "array",
-"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail.",
+"description": "Custom commands that are executed instead of launching a process. The commands must create a target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. The following settings will be ignored if provided: \"program\", \"cwd\", \"args\", \"env\", \"disableASLR\", \"disableSTDIO\", \"shellExpandArguments\", \"detachOnError\", \"runInTerminal\", \"targetTriple\", \"platformName\"",
"default": []
},
"stopCommands": {
@@ -276,7 +276,7 @@
},
"attachCommands": {
"type": "array",
-"description": "Custom commands that are executed instead of attaching to a process ID or to a process by name. These commands may optionally create a new target and must perform an attach. A valid process must exist after these commands complete or the \"attach\" will fail.",
+"description": "Custom commands that are executed instead of attaching to a process ID or to a process by name. These commands must create a target and must perform an attach. A valid process must exist after these commands complete or the \"attach\" will fail. The following settings will be ignored if provided: \"program\", \"pid\", \"waitFor\", \"coreFile\", \"targetTriple\", \"platformName\"",
"default": []
},
"initCommands": {
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -618,28 +618,67 @@
SetSourceMapFromArguments(*arguments);
- lldb::SBError status;
- g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
- if (status.Fail()) {
-response["success"] = llvm::json::Value(false);
-EmplaceSafeString(response, "message", status.GetCString());
-g_vsc.SendJSON(llvm::json::Value(std::move(response)));
-return;
- }
+ if (!attachCommands.empty()) {
+// We have "attachCommands" that are a set of commands that are expected
+// to execute the commands after which a process should be created. If there
+// is no valid process after running these commands, we have failed.
- // Run any pre run LLDB commands the user specified in the launch.json
- g_vsc.RunPreRunCommands();
+std::vector incompatible_fields;
+for (llvm::StringRef arg : {"program", "pid", "waitFor", "coreFile",
+"targetTriple", "platformName"}) {
+ if (arguments->get(arg) != nullptr) {
+incompatible_fields.push_back(arg);
+ }
+}
- if (pid == LLDB_INVALID_PROCESS_ID && wait_for) {
-char attach_msg[256];
-auto attach_msg_len = snprintf(attach_msg, sizeof(attach_msg),
- "Waiting to attach to \"%s\"...",
- g_vsc.target.GetExecutable().GetFilename());
-g_vsc.SendOutput(OutputType::Console,
- llvm::StringRef(attach_msg, attach_msg_len));
+if (!incompatible_fields.empty()) {
+ std::string str;
+ llvm::raw_string_ostream strm(str);
+ strm << "Incorrect debug configuration: " <<
+"'attachCommands' is not compatible with ";
+ for (llvm::StringRef field : incompatible_fields) {
+strm << " '" << field << "' ";
+ }
+ response["success"] = llvm::json::Value(false);
+ EmplaceSafeString(response, "message", strm.str());
+ g_vsc.SendJSON(llvm::json::Value(std::move(response)));
+ return;
+}
+
+// Run any pre run LLDB command