Skip to content

Commit a6469cd

Browse files
committed
[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
1 parent a7e7f54 commit a6469cd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,6 @@ static size_t LookupTypeInModule(Target *target,
16051605
TypeList type_list;
16061606
if (module && name_cstr && name_cstr[0]) {
16071607
const uint32_t max_num_matches = UINT32_MAX;
1608-
size_t num_matches = 0;
16091608
bool name_is_fully_qualified = false;
16101609

16111610
ConstString name(name_cstr);
@@ -1616,8 +1615,10 @@ static size_t LookupTypeInModule(Target *target,
16161615
if (type_list.Empty())
16171616
return 0;
16181617

1618+
const uint64_t num_matches = type_list.GetSize();
1619+
16191620
strm.Indent();
1620-
strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
1621+
strm.Printf("%" PRIu64 " match%s found in ", num_matches,
16211622
num_matches > 1 ? "es" : "");
16221623
DumpFullpath(strm, &module->GetFileSpec(), 0);
16231624
strm.PutCString(":\n");

lldb/test/API/commands/target/basic/TestTargetCommand.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,11 @@ def test_target_modules_search_paths_query(self):
468468
# Invalid arguments.
469469
self.expect("target modules search-paths query faz baz", error=True,
470470
substrs=["query requires one argument"])
471+
472+
@no_debug_info_test
473+
def test_target_modules_type(self):
474+
self.buildB()
475+
self.runCmd("file " + self.getBuildArtifact("b.out"),
476+
CURRENT_EXECUTABLE_SET)
477+
self.expect("target modules lookup --type int",
478+
substrs=["1 match found", 'name = "int"'])

0 commit comments

Comments
 (0)