Skip to content

[lldb-dap] support moduleId in the stackTrace response #149774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

woruyu
Copy link
Contributor

@woruyu woruyu commented Jul 21, 2025

Summary

This PR resolves #149316

@llvmbot
Copy link
Member

llvmbot commented Jul 21, 2025

@llvm/pr-subscribers-lldb

Author: woruyu (woruyu)

Changes

Summary

This PR resolves #149316


Full diff: https://github.com/llvm/llvm-project/pull/149774.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+9)
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index 41ca29a405ac9..7abd9618cc71f 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -550,6 +550,15 @@ 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);
+    else
+      object.try_emplace("moduleId", module.GetFileSpec().GetFilename());
+  }
+
   return llvm::json::Value(std::move(object));
 }
 

@woruyu
Copy link
Contributor Author

woruyu commented Jul 21, 2025

@da-viper , I added moduleId to the stackTrace response where I think it fits, but I’m not very familiar with lldb-dap. Would appreciate feedback on whether this is the right place, and where a test should go—DAPTests.cpp, ProtocolTypesTest.cpp, or elsewhere? Also, is there a simple way to test this locally without a full frontend?

@woruyu woruyu force-pushed the fix/support-moduleid-for-stackTrace branch from 2d48be5 to 3c47de2 Compare July 21, 2025 09:09
Copy link

github-actions bot commented Jul 21, 2025

✅ With the latest revision this PR passed the Python code formatter.

@da-viper da-viper requested a review from ashgti July 21, 2025 10:07
@da-viper
Copy link
Contributor

where a test should go—DAPTests.cpp, ProtocolTypesTest.cpp, or elsewhere

It should go into TestDAP_stackTrace

def verify_stackFrame(self, frame_idx, stackFrame):
frame_name = self.get_dict_value(stackFrame, self.name_key_path)
frame_source = self.get_dict_value(stackFrame, self.source_key_path)

Also, is there a simple way to test this locally without a full frontend?

Not that I am aware of, you can look at LLDB_DAP logs (you need to set a log path) when running the DAP adapter or looking at the logs in a failed test.

@da-viper
Copy link
Contributor

You can either use the self.dap_server.get_modules and compare the uuid received with the one returned from the stacktrace request.
OR
send an evaluate request of image list --uuid --basename and regex parse the modules to get the uuid.

@woruyu woruyu requested a review from da-viper July 23, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lldb-dap] support moduleId in the stackTrace response
3 participants