diff options
| author | Ebuka Ezike <yerimyah1@gmail.com> | 2025-10-29 18:53:00 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-29 18:53:00 +0000 |
| commit | b17f1fd6766a5b36b06df734ee577f7dae9cb964 (patch) | |
| tree | 77a390f471aa1c5021fb96c541ef5eb4298ba7ee | |
| parent | db6ba82acc767651ee59d249d717706be7239953 (diff) | |
| download | llvm-b17f1fd6766a5b36b06df734ee577f7dae9cb964.zip llvm-b17f1fd6766a5b36b06df734ee577f7dae9cb964.tar.gz llvm-b17f1fd6766a5b36b06df734ee577f7dae9cb964.tar.bz2 | |
[lldb-dap] Report any errors during attach request (#165270)
Attaching using `core`, `gdbremote` or `attachInfo` may have an error.
fail early if it does.
| -rw-r--r-- | lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py | 15 | ||||
| -rw-r--r-- | lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py index 1143cd9..d56a8a4 100644 --- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py +++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py @@ -61,6 +61,21 @@ class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase): self.dap_server.request_next(threadId=32259) self.assertEqual(self.get_stackFrames(), expected_frames) + def test_wrong_core_file(self): + exe_file = self.getSourcePath("linux-x86_64.out") + wrong_core_file = self.getSourcePath("main.c") + + self.create_debug_adapter() + resp = self.attach( + program=exe_file, coreFile=wrong_core_file, expectFailure=True + ) + self.assertIsNotNone(resp) + self.assertFalse(resp["success"], "Expected failure in response {resp!r}") + error_msg = resp["body"]["error"]["format"] + + # attach may fail for mutilple reasons. + self.assertEqual(error_msg, "Failed to create the process") + @skipIfLLVMTargetMissing("X86") def test_core_file_source_mapping_array(self): """Test that sourceMap property is correctly applied when loading a core""" diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp index 371349a..490513f 100644 --- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp @@ -124,6 +124,8 @@ Error AttachRequestHandler::Run(const AttachRequestArguments &args) const { attach_info.SetWaitForLaunch(args.waitFor, /*async=*/false); dap.target.Attach(attach_info, error); } + if (error.Fail()) + return ToError(error); } // Make sure the process is attached and stopped. |
