Skip to content

Commit 693e29c

Browse files
committed
adding simple test for the moduleSymbols request
1 parent 1f168a7 commit 693e29c

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,19 @@ def request_modules(self, startModule: int, moduleCount: int):
11991199
}
12001200
)
12011201

1202+
def request_moduleSymbols(self, moduleId: str = "", moduleName: str = "", startIndex: int = 0, count: int = 0):
1203+
command_dict = {
1204+
"command": "moduleSymbols",
1205+
"type": "request",
1206+
"arguments": {
1207+
"moduleId": moduleId,
1208+
"moduleName": moduleName,
1209+
"startIndex": startIndex,
1210+
"count": count,
1211+
},
1212+
}
1213+
return self.send_recv(command_dict)
1214+
12021215
def request_stackTrace(
12031216
self, threadId=None, startFrame=None, levels=None, format=None, dump=False
12041217
):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
C_SOURCES := main.c
2+
3+
include Makefile.rules
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Test lldb-dap moduleSymbols request
3+
"""
4+
5+
import lldbdap_testcase
6+
7+
8+
class TestDAP_moduleSymbols(lldbdap_testcase.DAPTestCaseBase):
9+
def test_moduleSymbols(self):
10+
"""
11+
Test that the stack frame without a module still has assembly source.
12+
"""
13+
program = self.getBuildArtifact("a.out")
14+
self.build_and_launch(program)
15+
16+
symbol_names = []
17+
i = 0
18+
while True:
19+
next_symbol = self.dap_server.request_moduleSymbols(moduleName="a.out", startIndex=i, count=1)
20+
self.assertIn("symbols", next_symbol["body"])
21+
result_symbols = next_symbol["body"]["symbols"]
22+
self.assertLessEqual(len(result_symbols), 1)
23+
if len(result_symbols) == 0:
24+
break
25+
26+
self.assertIn("name", result_symbols[0])
27+
symbol_names.append(result_symbols[0]["name"])
28+
i += 1
29+
if i >= 1000:
30+
break
31+
32+
self.assertGreater(len(symbol_names), 0)
33+
self.assertIn("main", symbol_names)
34+
self.assertIn("func1", symbol_names)
35+
self.assertIn("func2", symbol_names)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
int func1() {
2+
return 42;
3+
}
4+
5+
int func2() {
6+
return 84;
7+
}
8+
9+
int main() {
10+
func1();
11+
func2();
12+
return 0;
13+
}

0 commit comments

Comments
 (0)