From 6aa963f780d63d4c8fa80de97dd79c932bc35f4e Mon Sep 17 00:00:00 2001 From: Mikhail Zakharov Date: Thu, 1 May 2025 20:10:41 +0200 Subject: [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (#129092) This change adds a setting `target.process.track-memory-cache-changes`. Disabling this setting prevents invalidating and updating values in `ValueObject::UpdateValueIfNeeded` when only "internal" debugger memory is updated. Writing to "internal" debugger memory happens when, for instance, expressions are evaluated by visualizers (pretty printers). One of the examples when cache invalidation has a particularly heavy impact is visualizations of some collections: in some collections getting collection size is an expensive operation (it requires traversal of the collection). At the same time evaluating user expression with side effects (visible to target, not only to debugger) will still bump memory ID because: - If expression is evaluated via interpreter: it will cause write to "non-internal" memory - If expression is JIT-compiled: then to call the function LLDB will write to "non-internal" stack memory The downside of disabled `target.process.track-memory-cache-changes` setting is that convenience variables won't reevaluate synthetic children automatically. --------- Co-authored-by: Mikhail Zakharov --- lldb/source/Commands/CommandObjectProcess.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lldb/source/Commands/CommandObjectProcess.cpp') diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index ed80c85..d0f5eaf 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1388,6 +1388,9 @@ public: case 'v': m_verbose = true; break; + case 'd': + m_dump = true; + break; default: llvm_unreachable("Unimplemented option"); } @@ -1397,6 +1400,7 @@ public: void OptionParsingStarting(ExecutionContext *execution_context) override { m_verbose = false; + m_dump = false; } llvm::ArrayRef GetDefinitions() override { @@ -1405,6 +1409,7 @@ public: // Instance variables to hold the values for command options. bool m_verbose = false; + bool m_dump = false; }; protected: @@ -1459,6 +1464,14 @@ protected: crash_info_sp->GetDescription(strm); } } + + if (m_options.m_dump) { + StateType state = process->GetState(); + if (state == eStateStopped) { + ProcessModID process_mod_id = process->GetModID(); + process_mod_id.Dump(result.GetOutputStream()); + } + } } private: -- cgit v1.1