diff options
author | jimingham <jingham@apple.com> | 2024-02-28 16:14:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 16:14:19 -0800 |
commit | 97281708ac176e0464b770686ee314af4da0a3d5 (patch) | |
tree | cd3b3219bd55008795476828ab857f59e3a43c74 /lldb/source/Commands/CommandObjectTarget.cpp | |
parent | 6bc7c9df7f45642071f2b59a222ba009dc81eb99 (diff) | |
download | llvm-97281708ac176e0464b770686ee314af4da0a3d5.zip llvm-97281708ac176e0464b770686ee314af4da0a3d5.tar.gz llvm-97281708ac176e0464b770686ee314af4da0a3d5.tar.bz2 |
Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (#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.
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 4526557..b2346c2 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3376,15 +3376,19 @@ protected: case 'r': { size_t ref_count = 0; + char in_shared_cache = 'Y'; + ModuleSP module_sp(module->shared_from_this()); + if (!ModuleList::ModuleIsInCache(module)) + in_shared_cache = 'N'; if (module_sp) { // Take one away to make sure we don't count our local "module_sp" ref_count = module_sp.use_count() - 1; } if (width) - strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); + strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count); else - strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); + strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count); } break; case 's': |