Author: woruyu Date: 2025-08-01T13:43:13+01:00 New Revision: 0b9470b329103bcdfe3578d99664974d2a53bf8d
URL: https://github.com/llvm/llvm-project/commit/0b9470b329103bcdfe3578d99664974d2a53bf8d DIFF: https://github.com/llvm/llvm-project/commit/0b9470b329103bcdfe3578d99664974d2a53bf8d.diff LOG: [lldb-dap] support moduleId in the stackTrace response (#149774) This PR resolves https://github.com/llvm/llvm-project/issues/149316 --------- Co-authored-by: Ebuka Ezike <yerimy...@gmail.com> Added: Modified: lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py lldb/tools/lldb-dap/JSONUtils.cpp Removed: ################################################################################ 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 db43dbaf515cf..1143cd93a70b3 100644 --- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py +++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py @@ -26,6 +26,7 @@ def test_core_file(self): "column": 0, "id": 524288, "line": 4, + "moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "bar", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40011C", @@ -34,6 +35,7 @@ def test_core_file(self): "column": 0, "id": 524289, "line": 10, + "moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "foo", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x400142", @@ -42,6 +44,7 @@ def test_core_file(self): "column": 0, "id": 524290, "line": 16, + "moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "_start", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40015F", diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py index abd469274ffd4..fd2037b5762d1 100644 --- a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py +++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py @@ -242,3 +242,36 @@ def test_StackFrameFormat(self): frame = self.get_stackFrames(format={"parameters": False, "module": True})[0] self.assertEqual(frame["name"], "a.out recurse") + + @skipIfWindows + def test_stack_frame_module_id(self): + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = "main.c" + lines = [line_number(source, "recurse end")] + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertEqual( + len(breakpoint_ids), len(lines), "expect correct number of breakpoints" + ) + + self.continue_to_breakpoints(breakpoint_ids) + + modules = self.dap_server.get_modules() + name_to_id = { + name: info["id"] for name, info in modules.items() if "id" in info + } + + stack_frames = self.get_stackFrames() + for frame in stack_frames: + module_id = frame.get("moduleId") + source_name = frame.get("source", {}).get("name") + if module_id is None or source_name is None: + continue + + if source_name in name_to_id: + expected_id = name_to_id[source_name] + self.assertEqual( + module_id, + expected_id, + f"Expected moduleId '{expected_id}' for {source_name}, got: {module_id}", + ) diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index f42c50236f19e..4f26599a49bac 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -550,6 +550,13 @@ llvm::json::Value CreateStackFrame(DAP &dap, lldb::SBFrame &frame, if (frame.IsArtificial() || frame.IsHidden()) object.try_emplace("presentationHint", "subtle"); + lldb::SBModule module = frame.GetModule(); + if (module.IsValid()) { + std::string uuid = module.GetUUIDString(); + if (!uuid.empty()) + object.try_emplace("moduleId", uuid); + } + return llvm::json::Value(std::move(object)); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits