Skip to content

Commit 9728170

Browse files
authored
Change image list -r so that it actually shows the ref count and whether the image is in the shared cache. (llvm#83341)
The help for the `-r` option to `image list` says: -r[<width>] ( --ref-count=[<width>] ) Display the reference count if the module is still in the shared module cache. but that's not what it actually does. It unconditionally shows the use_count for all Module shared pointers, regardless of whether they are still in the shared module cache or whether they are just in the ModuleCollection and other entities are keeping them alive. That seems like a more useful behavior, but then it is also useful to know what's in the shared cache, so I changed this to: -r[<width>] ( --ref-count=[<width>] ) Display whether the module is still in the the shared module cache (Y/N), and its shared pointer use_count. So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and `{N 5}` if not. I didn't add tests for this because I'm not sure how much we want to fix shared cache behavior in the testsuite.
1 parent 6bc7c9d commit 9728170

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
33763376

33773377
case 'r': {
33783378
size_t ref_count = 0;
3379+
char in_shared_cache = 'Y';
3380+
33793381
ModuleSP module_sp(module->shared_from_this());
3382+
if (!ModuleList::ModuleIsInCache(module))
3383+
in_shared_cache = 'N';
33803384
if (module_sp) {
33813385
// Take one away to make sure we don't count our local "module_sp"
33823386
ref_count = module_sp.use_count() - 1;
33833387
}
33843388
if (width)
3385-
strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count);
3389+
strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count);
33863390
else
3387-
strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count);
3391+
strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count);
33883392
} break;
33893393

33903394
case 's':

lldb/source/Commands/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ let Command = "target modules list" in {
936936
OptionalArg<"Width">, Desc<"Display the modification time with optional "
937937
"width of the module.">;
938938
def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>,
939-
OptionalArg<"Width">, Desc<"Display the reference count if the module is "
940-
"still in the shared module cache.">;
939+
OptionalArg<"Width">, Desc<"Display whether the module is still in the "
940+
"the shared module cache (Y/N), and its shared pointer use_count.">;
941941
def target_modules_list_pointer : Option<"pointer", "p">, Group<1>,
942942
OptionalArg<"None">, Desc<"Display the module pointer.">;
943943
def target_modules_list_global : Option<"global", "g">, Group<1>,

0 commit comments

Comments
 (0)