Skip to content

Commit

Permalink
[lldb] Correctly display the number of types found
Browse files Browse the repository at this point in the history
Correctly display the number of types found for `target modules lookup
--type` and add a test.

Fixes #53219
  • Loading branch information
JDevlieghere committed Jan 15, 2022
1 parent a7e7f54 commit a6469cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lldb/source/Commands/CommandObjectTarget.cpp
Expand Up @@ -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);
Expand All @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions lldb/test/API/commands/target/basic/TestTargetCommand.py
Expand Up @@ -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"'])

0 comments on commit a6469cd

Please sign in to comment.