[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 20 12:29:48 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 31e55d461693df035049e09cbeeb8886ca2cb6d3...7e221825b8537f69e19cf366c446d9a09a4768fe lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py 2024-08-20 19:21:12.000000 +0000
+++ test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py 2024-08-20 19:29:09.956487 +0000
@@ -7,16 +7,16 @@
import os
import lldb
class TestDAP_InstructionBreakpointTestCase(lldbdap_testcase.DAPTestCaseBase):
+ NO_DEBUG_INFO_TESTCASE = True
- NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
lldbdap_testcase.DAPTestCaseBase.setUp(self)
- self.main_basename = 'main-copy.cpp'
+ self.main_basename = "main-copy.cpp"
self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename))
def test_instruction_breakpoint(self):
self.build()
self.instruction_breakpoint_test()
@@ -24,53 +24,77 @@
def instruction_breakpoint_test(self):
"""Sample test to ensure SBFrame::Disassemble produces SOME output"""
# Create a target by the debugger.
target = self.createTestTarget()
- #build target and create DAP
- #self.build_and_create_debug_adaptor()
+ # build target and create DAP
+ # self.build_and_create_debug_adaptor()
- main_line = line_number('main.cpp', 'breakpoint 1')
+ main_line = line_number("main.cpp", "breakpoint 1")
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
# Set source breakpoint 1
response = self.dap_server.request_setBreakpoints(self.main_path, [main_line])
- breakpoints = response['body']['breakpoints']
+ breakpoints = response["body"]["breakpoints"]
self.assertEquals(len(breakpoints), 1)
breakpoint = breakpoints[0]
- self.assertEqual(breakpoint['line'], main_line, "incorrect breakpoint source line")
- self.assertTrue(breakpoint['verified'], "breakpoint is not verified")
- self.assertEqual(self.main_basename, breakpoint['source']['name'], "incorrect source name")
- self.assertEqual(self.main_path, breakpoint['source']['path'], "incorrect source file path")
- other_breakpoint_id = breakpoint['id']
+ self.assertEqual(
+ breakpoint["line"], main_line, "incorrect breakpoint source line"
+ )
+ self.assertTrue(breakpoint["verified"], "breakpoint is not verified")
+ self.assertEqual(
+ self.main_basename, breakpoint["source"]["name"], "incorrect source name"
+ )
+ self.assertEqual(
+ self.main_path, breakpoint["source"]["path"], "incorrect source file path"
+ )
+ other_breakpoint_id = breakpoint["id"]
# Continue and then verifiy the breakpoint
self.dap_server.request_continue()
self.verify_breakpoint_hit([other_breakpoint_id])
# now we check the stack trace making sure that we got mapped source paths
- frames = self.dap_server.request_stackTrace()['body']['stackFrames']
+ frames = self.dap_server.request_stackTrace()["body"]["stackFrames"]
intstructionPointerReference = []
setIntstructionBreakpoints = []
- intstructionPointerReference.append(frames[0]['instructionPointerReference'])
- self.assertEqual(frames[0]['source']['name'], self.main_basename, "incorrect source name")
- self.assertEqual(frames[0]['source']['path'], self.main_path, "incorrect source file path")
+ intstructionPointerReference.append(frames[0]["instructionPointerReference"])
+ self.assertEqual(
+ frames[0]["source"]["name"], self.main_basename, "incorrect source name"
+ )
+ self.assertEqual(
+ frames[0]["source"]["path"], self.main_path, "incorrect source file path"
+ )
# Check disassembly view
instruction = self.disassemble(frameIndex=0)
- self.assertEqual(instruction["address"], intstructionPointerReference[0], "current breakpoint reference is not in the disaasembly view")
+ self.assertEqual(
+ instruction["address"],
+ intstructionPointerReference[0],
+ "current breakpoint reference is not in the disaasembly view",
+ )
# Get next instruction address to set instruction breakpoint
disassembled_instruction_list = self.dap_server.disassembled_instructions
instruction_addr_list = list(disassembled_instruction_list.keys())
index = instruction_addr_list.index(intstructionPointerReference[0])
if len(instruction_addr_list) >= (index + 1):
next_inst_addr = int(instruction_addr_list[index + 1], 16)
if next_inst_addr is not 0:
setIntstructionBreakpoints.append(hex(next_inst_addr))
- instruction_breakpoint_response = self.dap_server.request_setInstructionBreakpoints(setIntstructionBreakpoints)
- inst_breakpoints = instruction_breakpoint_response['body']['breakpoints']
- self.assertEqual(inst_breakpoints[0]['instructionReference'], hex(next_inst_addr), "Instruction breakpoint has not been resolved or failed to relocate the instruction breakpoint")
+ instruction_breakpoint_response = (
+ self.dap_server.request_setInstructionBreakpoints(
+ setIntstructionBreakpoints
+ )
+ )
+ inst_breakpoints = instruction_breakpoint_response["body"][
+ "breakpoints"
+ ]
+ self.assertEqual(
+ inst_breakpoints[0]["instructionReference"],
+ hex(next_inst_addr),
+ "Instruction breakpoint has not been resolved or failed to relocate the instruction breakpoint",
+ )
self.dap_server.request_continue()
- self.verify_breakpoint_hit([inst_breakpoints[0]['id']])
+ self.verify_breakpoint_hit([inst_breakpoints[0]["id"]])
``````````
</details>
https://github.com/llvm/llvm-project/pull/105278
More information about the lldb-commits
mailing list