Skip to content

Commit c16a459

Browse files
jiminghamJDevlieghere
authored andcommitted
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. (cherry picked from commit 9728170)
1 parent 6e0b031 commit c16a459

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
@@ -3171,15 +3171,19 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
31713171

31723172
case 'r': {
31733173
size_t ref_count = 0;
3174+
char in_shared_cache = 'Y';
3175+
31743176
ModuleSP module_sp(module->shared_from_this());
3177+
if (!ModuleList::ModuleIsInCache(module))
3178+
in_shared_cache = 'N';
31753179
if (module_sp) {
31763180
// Take one away to make sure we don't count our local "module_sp"
31773181
ref_count = module_sp.use_count() - 1;
31783182
}
31793183
if (width)
3180-
strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count);
3184+
strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count);
31813185
else
3182-
strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count);
3186+
strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count);
31833187
} break;
31843188

31853189
case 's':

lldb/source/Commands/Options.td

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

0 commit comments

Comments
 (0)