[Lldb-commits] [lldb] a6469cd - [lldb] Correctly display the number of types found
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Sat Jan 15 10:31:54 PST 2022
Author: Jonas Devlieghere
Date: 2022-01-15T10:31:49-08:00
New Revision: a6469cdbc426437dcb8442ae398f0a863336de37
URL: https://github.com/llvm/llvm-project/commit/a6469cdbc426437dcb8442ae398f0a863336de37
DIFF: https://github.com/llvm/llvm-project/commit/a6469cdbc426437dcb8442ae398f0a863336de37.diff
LOG: [lldb] Correctly display the number of types found
Correctly display the number of types found for `target modules lookup
--type` and add a test.
Fixes #53219
Added:
Modified:
lldb/source/Commands/CommandObjectTarget.cpp
lldb/test/API/commands/target/basic/TestTargetCommand.py
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 2a42eb22938d7..bd19ac513d017 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1605,7 +1605,6 @@ static size_t LookupTypeInModule(Target *target,
TypeList type_list;
if (module && name_cstr && name_cstr[0]) {
const uint32_t max_num_matches = UINT32_MAX;
- size_t num_matches = 0;
bool name_is_fully_qualified = false;
ConstString name(name_cstr);
@@ -1616,8 +1615,10 @@ static size_t LookupTypeInModule(Target *target,
if (type_list.Empty())
return 0;
+ const uint64_t num_matches = type_list.GetSize();
+
strm.Indent();
- strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
+ strm.Printf("%" PRIu64 " match%s found in ", num_matches,
num_matches > 1 ? "es" : "");
DumpFullpath(strm, &module->GetFileSpec(), 0);
strm.PutCString(":\n");
diff --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 30cb9d7d6c84f..9904eb02394a9 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -468,3 +468,11 @@ def test_target_modules_search_paths_query(self):
# Invalid arguments.
self.expect("target modules search-paths query faz baz", error=True,
substrs=["query requires one argument"])
+
+ @no_debug_info_test
+ def test_target_modules_type(self):
+ self.buildB()
+ self.runCmd("file " + self.getBuildArtifact("b.out"),
+ CURRENT_EXECUTABLE_SET)
+ self.expect("target modules lookup --type int",
+ substrs=["1 match found", 'name = "int"'])
More information about the lldb-commits
mailing list