Skip to content

[lldb-dap][test] Fix DAP disassemble test #142129

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

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

da-viper
Copy link
Contributor

compare the instructions before and after setting breakpoint to make sure they are the same.
Do not use the source location as it is not guaranteed to exist.

compare the instructions before and after setting breakpoint
to make sure they are the same. Do not use the source location as
it is not guaranteed to exist.
@da-viper da-viper requested review from ashgti and eronnen May 30, 2025 11:53
@da-viper da-viper requested a review from JDevlieghere as a code owner May 30, 2025 11:53
@llvmbot llvmbot added the lldb label May 30, 2025
@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

compare the instructions before and after setting breakpoint to make sure they are the same.
Do not use the source location as it is not guaranteed to exist.


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

1 Files Affected:

  • (modified) lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py (+22-14)
diff --git a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
index a8b51864d118b..da7a337de5ea6 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -2,13 +2,9 @@
 Test lldb-dap disassemble request
 """
 
-
-import dap_server
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
 import lldbdap_testcase
-import os
 
 
 class TestDAP_disassemble(lldbdap_testcase.DAPTestCaseBase):
@@ -23,15 +19,23 @@ def test_disassemble(self):
         self.set_source_breakpoints(source, [line_number(source, "// breakpoint 1")])
         self.continue_to_next_stop()
 
-        _, pc_assembly = self.disassemble(frameIndex=0)
-        self.assertIn("location", pc_assembly, "Source location missing.")
-        self.assertIn("instruction", pc_assembly, "Assembly instruction missing.")
+        insts_with_bp, pc_with_bp_assembly = self.disassemble(frameIndex=0)
+        no_bp = self.set_source_breakpoints(source, [])
+        self.assertEqual(len(no_bp), 0, "expect no breakpoints.")
+        self.assertIn(
+            "instruction", pc_with_bp_assembly, "Assembly instruction missing."
+        )
 
-        # The calling frame (qsort) is coming from a system library, as a result
-        # we should not have a source location.
-        _, qsort_assembly = self.disassemble(frameIndex=1)
-        self.assertNotIn("location", qsort_assembly, "Source location not expected.")
-        self.assertIn("instruction", pc_assembly, "Assembly instruction missing.")
+        # the disassembly instructions should be the same even if there is a breakpoint;
+        insts_no_bp, pc_no_bp_assembly = self.disassemble(frameIndex=0)
+        self.assertDictEqual(
+            insts_with_bp,
+            insts_no_bp,
+            "Expects instructions are the same after removing breakpoints.",
+        )
+        self.assertIn("instruction", pc_no_bp_assembly, "Assembly instruction missing.")
+
+        self.continue_to_exit()
 
     @skipIfWindows
     def test_disassemble_backwards(self):
@@ -74,3 +78,7 @@ def test_disassemble_backwards(self):
             backwards_instructions,
             f"requested instruction should be preceeded by {backwards_instructions} instructions. Actual index: {frame_instruction_index}",
         )
+
+        # clear breakpoints
+        self.set_source_breakpoints(source, [])
+        self.continue_to_exit()

Copy link
Contributor

@ashgti ashgti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also move

to line 11?

That should help us land on a location with a line associated with it.

@da-viper da-viper requested review from eronnen and ashgti June 2, 2025 09:14
@da-viper da-viper merged commit a48e1ab into llvm:main Jun 4, 2025
10 checks passed
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.

5 participants