1""" 2Test lldb-dap coreFile attaching 3""" 4 5 6import dap_server 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10import lldbdap_testcase 11import os 12 13 14class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase): 15 @skipIfLLVMTargetMissing("X86") 16 def test_core_file(self): 17 current_dir = os.path.dirname(__file__) 18 exe_file = os.path.join(current_dir, "linux-x86_64.out") 19 core_file = os.path.join(current_dir, "linux-x86_64.core") 20 21 self.create_debug_adaptor() 22 self.attach(exe_file, coreFile=core_file) 23 24 expected_frames = [ 25 { 26 "column": 0, 27 "id": 524288, 28 "line": 4, 29 "name": "bar", 30 "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, 31 "instructionPointerReference": "0x40011C", 32 }, 33 { 34 "column": 0, 35 "id": 524289, 36 "line": 10, 37 "name": "foo", 38 "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, 39 "instructionPointerReference": "0x400142", 40 }, 41 { 42 "column": 0, 43 "id": 524290, 44 "line": 16, 45 "name": "_start", 46 "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, 47 "instructionPointerReference": "0x40015F", 48 }, 49 ] 50 51 self.assertEqual(self.get_stackFrames(), expected_frames) 52 53 # Resuming should have no effect and keep the process stopped 54 self.continue_to_next_stop() 55 self.assertEqual(self.get_stackFrames(), expected_frames) 56 57 self.dap_server.request_next(threadId=32259) 58 self.assertEqual(self.get_stackFrames(), expected_frames) 59 60 @skipIfLLVMTargetMissing("X86") 61 def test_core_file_source_mapping_array(self): 62 """Test that sourceMap property is correctly applied when loading a core""" 63 current_dir = os.path.dirname(__file__) 64 exe_file = os.path.join(current_dir, "linux-x86_64.out") 65 core_file = os.path.join(current_dir, "linux-x86_64.core") 66 67 self.create_debug_adaptor() 68 69 source_map = [["/home/labath/test", current_dir]] 70 self.attach(exe_file, coreFile=core_file, sourceMap=source_map) 71 72 self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"]) 73 74 @skipIfLLVMTargetMissing("X86") 75 def test_core_file_source_mapping_object(self): 76 """Test that sourceMap property is correctly applied when loading a core""" 77 current_dir = os.path.dirname(__file__) 78 exe_file = os.path.join(current_dir, "linux-x86_64.out") 79 core_file = os.path.join(current_dir, "linux-x86_64.core") 80 81 self.create_debug_adaptor() 82 83 source_map = {"/home/labath/test": current_dir} 84 self.attach(exe_file, coreFile=core_file, sourceMap=source_map) 85 86 self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"]) 87