1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
"""
Test lldb-dap coreFile attaching
"""
import dap_server
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
import lldbdap_testcase
import os
class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase):
@skipIfLLVMTargetMissing("X86")
def test_core_file(self):
current_dir = os.path.dirname(__file__)
exe_file = os.path.join(current_dir, "linux-x86_64.out")
core_file = os.path.join(current_dir, "linux-x86_64.core")
self.create_debug_adapter()
self.attach(program=exe_file, coreFile=core_file)
self.dap_server.request_configurationDone()
expected_frames = [
{
"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",
},
{
"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",
},
{
"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",
},
]
self.assertEqual(self.get_stackFrames(), expected_frames)
# Resuming should have no effect and keep the process stopped
resp = self.dap_server.request_continue()
self.assertFalse(resp["success"])
self.assertEqual(self.get_stackFrames(), expected_frames)
self.dap_server.request_next(threadId=32259)
self.assertEqual(self.get_stackFrames(), expected_frames)
def test_wrong_core_file(self):
exe_file = self.getSourcePath("linux-x86_64.out")
wrong_core_file = self.getSourcePath("main.c")
self.create_debug_adapter()
resp = self.attach(
program=exe_file, coreFile=wrong_core_file, expectFailure=True
)
self.assertIsNotNone(resp)
self.assertFalse(resp["success"], "Expected failure in response {resp!r}")
error_msg = resp["body"]["error"]["format"]
# attach may fail for mutilple reasons.
self.assertEqual(error_msg, "Failed to create the process")
@skipIfLLVMTargetMissing("X86")
def test_core_file_source_mapping_array(self):
"""Test that sourceMap property is correctly applied when loading a core"""
current_dir = os.path.dirname(__file__)
exe_file = os.path.join(current_dir, "linux-x86_64.out")
core_file = os.path.join(current_dir, "linux-x86_64.core")
self.create_debug_adapter()
source_map = [["/home/labath/test", current_dir]]
self.attach(program=exe_file, coreFile=core_file, sourceMap=source_map)
self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"])
@skipIfLLVMTargetMissing("X86")
def test_core_file_source_mapping_object(self):
"""Test that sourceMap property is correctly applied when loading a core"""
current_dir = os.path.dirname(__file__)
exe_file = os.path.join(current_dir, "linux-x86_64.out")
core_file = os.path.join(current_dir, "linux-x86_64.core")
self.create_debug_adapter()
source_map = {"/home/labath/test": current_dir}
self.attach(program=exe_file, coreFile=core_file, sourceMap=source_map)
self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"])
|