Skip to content

Commit 1f168a7

Browse files
committed
add index and count to the moduleSymbols request
1 parent 6581b34 commit 1f168a7

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

lldb/tools/lldb-dap/Handler/ModuleSymbolsRequestHandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ ModuleSymbolsRequestHandler::Run(const ModuleSymbolsArguments &args) const {
5151
if (!module.IsValid())
5252
return llvm::make_error<DAPError>("Module not found");
5353

54-
size_t num_symbols = module.GetNumSymbols();
55-
for (size_t i = 0; i < num_symbols; ++i) {
54+
const size_t num_symbols = module.GetNumSymbols();
55+
const size_t start_index = args.startIndex.value_or(0);
56+
const size_t end_index = std::min(start_index + args.count.value_or(num_symbols), num_symbols);
57+
for (size_t i = start_index; i < end_index; ++i) {
5658
lldb::SBSymbol symbol = module.GetSymbolAtIndex(i);
5759
if (!symbol.IsValid())
5860
continue;

lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,10 @@ json::Value toJSON(const WriteMemoryResponseBody &WMR) {
601601
bool fromJSON(const llvm::json::Value &Params, ModuleSymbolsArguments &Args,
602602
llvm::json::Path P) {
603603
json::ObjectMapper O(Params, P);
604-
return O && O.mapOptional("moduleId", Args.moduleId) &&
605-
O.mapOptional("moduleName", Args.moduleName);
604+
return O && O.map("moduleId", Args.moduleId) &&
605+
O.map("moduleName", Args.moduleName) &&
606+
O.mapOptional("startIndex", Args.startIndex) &&
607+
O.mapOptional("count", Args.count);
606608
}
607609

608610
llvm::json::Value toJSON(const ModuleSymbolsResponseBody &DGMSR) {

lldb/tools/lldb-dap/Protocol/ProtocolRequests.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,12 @@ struct ModuleSymbolsArguments {
987987

988988
/// The module path.
989989
std::string moduleName;
990+
991+
/// The index of the first symbol to return; if omitted, start at the beginning.
992+
std::optional<uint32_t> startIndex;
993+
994+
/// The number of symbols to return; if omitted, all symbols are returned.
995+
std::optional<uint32_t> count;
990996
};
991997
bool fromJSON(const llvm::json::Value &, ModuleSymbolsArguments &,
992998
llvm::json::Path);

lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class SymbolsProvider extends DisposableContext {
4444
});
4545
});
4646

47-
this.tracker.onDidExitSession((session) => {
47+
this.tracker.onDidExitSession((_session) => {
4848
vscode.commands.executeCommand("setContext", "lldb-dap.supportsModuleSymbolsRequest", false);
4949
});
5050
}

0 commit comments

Comments
 (0)