[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)
@@ -1827,6 +1827,33 @@ class CommandObjectMultiwordProcessTrace : public CommandObjectMultiword { ~CommandObjectMultiwordProcessTrace() override = default; }; +// CommandObjectProcessDumpModificationId +class CommandObjectProcessDumpModificationId : public CommandObjectParsed { +public: + CommandObjectProcessDumpModificationId(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "process dump-modification-id", real-mikhail wrote: Yeah, I was reluctant to add new dump command too, but didn't think about extending other command. Fixed it (and other comment about command description too). https://github.com/llvm/llvm-project/pull/129092 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)
https://github.com/real-mikhail updated https://github.com/llvm/llvm-project/pull/129092 >From 1d2da22bceb83cbda54567e5f819e5eef4e6 Mon Sep 17 00:00:00 2001 From: Mikhail Zakharov Date: Thu, 27 Feb 2025 18:43:33 +0100 Subject: [PATCH 01/11] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated This change prevents invalidating and updating values in `ValueObject::UpdateValueIfNeeded` when only "internal" debugger memory is updated. Writing to "internal" debugger memory happens when, for instance, user expressions are evaluated by pretty printers. For some collections getting collection size is an expensive operation (it requires traversal of the collection) and broken value caching (being invalidated after executing expressions) make things worse. At the same time evaluating user expression with side effects (visible to target, not only to debugger) will still bump memory ID because: 1. If expression is evaluated via interpreter: it will cause write to "non-internal" memory 2. If expression is JIT-compiled: then to call the function LLDB will write to "non-internal" stack memory --- lldb/include/lldb/Target/Memory.h | 4 +- lldb/source/Target/Memory.cpp | 8 ++ lldb/source/Target/Process.cpp| 7 +- .../Shell/Expr/TestExprWithSideEffect.cpp | 82 +++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 lldb/test/Shell/Expr/TestExprWithSideEffect.cpp diff --git a/lldb/include/lldb/Target/Memory.h b/lldb/include/lldb/Target/Memory.h index 2d1489a2c96ea..864ef6ca00802 100644 --- a/lldb/include/lldb/Target/Memory.h +++ b/lldb/include/lldb/Target/Memory.h @@ -125,6 +125,8 @@ class AllocatedMemoryCache { bool DeallocateMemory(lldb::addr_t ptr); + bool IsInCache(lldb::addr_t addr) const; + protected: typedef std::shared_ptr AllocatedBlockSP; @@ -133,7 +135,7 @@ class AllocatedMemoryCache { // Classes that inherit from MemoryCache can see and modify these Process &m_process; - std::recursive_mutex m_mutex; + mutable std::recursive_mutex m_mutex; typedef std::multimap PermissionsToBlockMap; PermissionsToBlockMap m_memory_map; diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp index 5cdd84f6640f0..9bfb8c349aa2c 100644 --- a/lldb/source/Target/Memory.cpp +++ b/lldb/source/Target/Memory.cpp @@ -433,3 +433,11 @@ bool AllocatedMemoryCache::DeallocateMemory(lldb::addr_t addr) { (uint64_t)addr, success); return success; } + +bool AllocatedMemoryCache::IsInCache(lldb::addr_t addr) const { + std::lock_guard guard(m_mutex); + + return llvm::any_of(m_memory_map, [addr](const auto &block) { +return block.second->Contains(addr); + }); +} diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 6db582096155f..1150fabf2d0ed 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2267,6 +2267,7 @@ size_t Process::WriteMemoryPrivate(addr_t addr, const void *buf, size_t size, return bytes_written; } +#define USE_ALLOCATE_MEMORY_CACHE 1 size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size, Status &error) { if (ABISP abi_sp = GetABI()) @@ -2279,7 +2280,12 @@ size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size, if (buf == nullptr || size == 0) return 0; +#if defined(USE_ALLOCATE_MEMORY_CACHE) + if (!m_allocated_memory_cache.IsInCache(addr)) +m_mod_id.BumpMemoryID(); +#else m_mod_id.BumpMemoryID(); +#endif // We need to write any data that would go where any current software traps // (enabled software breakpoints) any software traps (breakpoints) that we @@ -2408,7 +2414,6 @@ Status Process::WriteObjectFile(std::vector entries) { return error; } -#define USE_ALLOCATE_MEMORY_CACHE 1 addr_t Process::AllocateMemory(size_t size, uint32_t permissions, Status &error) { if (GetPrivateState() != eStateStopped) { diff --git a/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp b/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp new file mode 100644 index 0..d072fe3121031 --- /dev/null +++ b/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp @@ -0,0 +1,82 @@ +// Tests evaluating expressions with side effects. +// Applied side effect should be visible to the debugger. + +// RUN: %build %s -o %t +// RUN: %lldb %t -o run \ +// RUN: -o "frame variable x" \ +// RUN: -o "expr x.inc()" \ +// RUN: -o "frame variable x" \ +// RUN: -o "continue" \ +// RUN: -o "frame variable x" \ +// RUN: -o "expr x.i = 10" \ +// RUN: -o "frame variable x" \ +// RUN: -o "continue" \ +// RUN: -o "frame variable x" \ +// RUN: -o "expr int $y = 11" \ +// RUN: -o "expr $y" \ +// RUN: -o "expr $y = 100" \ +// RUN: -o "expr $y" \ +// RUN: -o "continue" \ +// RUN: -o "expr $y" \ +// RUN: -o exit | FileCheck %s -dump-input=fail + +class X
[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)
https://github.com/real-mikhail edited https://github.com/llvm/llvm-project/pull/129092 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [dsymutil] Avoid copying binary swiftmodules built from textual (PR #134719)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-win-x-armv7l` running on `as-builder-1` while building `lldb,llvm` at step 9 "test-check-llvm". Full details are available at: https://lab.llvm.org/buildbot/#/builders/38/builds/2874 Here is the relevant piece of the build log for the reference ``` Step 9 (test-check-llvm) failure: Test just built components: check-llvm completed (failure) TEST 'LLVM :: tools/dsymutil/swiftmodule.test' FAILED Exit Code: 1 Command Output (stdout): -- # RUN: at line 1 c:\buildbot\as-builder-1\x-armv7l\build\bin\dsymutil.exe -verbose -oso-prepend-path=C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil -y -o C:\buildbot\as-builder-1\x-armv7l\build\test\tools\dsymutil\Output\swiftmodule.test.tmp.dSYM C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test | c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test # executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\dsymutil.exe' -verbose '-oso-prepend-path=C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil' -y -o 'C:\buildbot\as-builder-1\x-armv7l\build\test\tools\dsymutil\Output\swiftmodule.test.tmp.dSYM' 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test' # .---command stderr # | note: trying to open 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/Binary.swiftmodule' # | note: loaded object. # | warning: Unable to open C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/Binary.swiftmodule The file was not recognized as a valid object file # | note: trying to open 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/FromInterface.swiftmodule' # | note: loaded object. # | warning: Unable to open C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/FromInterface.swiftmodule The file was not recognized as a valid object file # | error: unable to get target for 'arm64-apple-darwin', see --version and --triple. # | note: while processing dwarf streamer init # | error: C:\buildbot\as-builder-1\x-armv7l\build\test\tools\dsymutil\Output\swiftmodule.test.tmp.dSYM\Contents\Resources\DWARF\swiftmodule.test: The file was not recognized as a valid object file # `- # error: command failed with exit status: 1 # executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe' 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test' # .---command stderr # | C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test:15:10: error: CHECK: expected string not found in input # | # CHECK: Skipping compiled textual Swift interface: {{.*}}/Inputs/FromInterface.swiftmodule # | ^ # | :1:1: note: scanning from here # | --- # | ^ # | :9:50: note: possible intended match here # | - filename: 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/FromInterface.swiftmodule' # | ^ # | # | Input file: # | Check file: C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil\swiftmodule.test # | # | -dump-input=help explains the following input dump. # | # | Input was: # | << # | 1: --- # | check:15'0 X~~~ error: no match found # | 2: triple: 'arm64-apple-darwin' # | check:15'0 ~ # | 3: binary-path: '' # | check:15'0 # | 4: objects: # | check:15'0 ~ # | 5: - filename: 'C:\buildbot\as-builder-1\x-armv7l\llvm-project\llvm\test\tools\dsymutil/Inputs/Binary.swiftmodule' # | check:15'0 ~ # | 6: timestamp: 0 ... ``` https://github.com/llvm/llvm-project/pull/134719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f4fba20 - [lldb] Remove vestigial remnants of reproducers (#135361)
Author: Pavel Labath Date: 2025-04-13T08:55:24+02:00 New Revision: f4fba20726aced418dc7ae24e47ee78f109a64cb URL: https://github.com/llvm/llvm-project/commit/f4fba20726aced418dc7ae24e47ee78f109a64cb DIFF: https://github.com/llvm/llvm-project/commit/f4fba20726aced418dc7ae24e47ee78f109a64cb.diff LOG: [lldb] Remove vestigial remnants of reproducers (#135361) Not touching the SB API. Added: Modified: lldb/include/lldb/API/SBReproducer.h lldb/include/lldb/Core/Debugger.h lldb/source/API/SBReproducer.cpp lldb/source/Core/Debugger.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/unittests/Core/DiagnosticEventTest.cpp lldb/unittests/Interpreter/TestCommandPaths.cpp lldb/unittests/Platform/PlatformSiginfoTest.cpp lldb/unittests/Process/ProcessEventDataTest.cpp lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp lldb/unittests/Target/ExecutionContextTest.cpp lldb/unittests/Target/MemoryTest.cpp lldb/unittests/Target/StackFrameRecognizerTest.cpp lldb/unittests/Thread/ThreadTest.cpp Removed: lldb/scripts/reproducer-replay.py diff --git a/lldb/include/lldb/API/SBReproducer.h b/lldb/include/lldb/API/SBReproducer.h index c48b4747afe57..e11accf052f46 100644 --- a/lldb/include/lldb/API/SBReproducer.h +++ b/lldb/include/lldb/API/SBReproducer.h @@ -11,12 +11,6 @@ #include "lldb/API/SBDefines.h" -namespace lldb_private { -namespace repro { -struct ReplayOptions; -} -} // namespace lldb_private - namespace lldb { #ifndef SWIG diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index f36202edbbde0..00b86f6c133b6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -67,10 +67,6 @@ class Stream; class SymbolContext; class Target; -namespace repro { -class DataRecorder; -} - /// \class Debugger Debugger.h "lldb/Core/Debugger.h" /// A class to manage flag bits. /// @@ -143,8 +139,6 @@ class Debugger : public std::enable_shared_from_this, return m_error_stream_sp->GetUnlockedFileSP(); } - repro::DataRecorder *GetInputRecorder(); - Status SetInputString(const char *data); void SetInputFile(lldb::FileSP file); @@ -720,9 +714,6 @@ class Debugger : public std::enable_shared_from_this, lldb::LockableStreamFileSP m_error_stream_sp; LockableStreamFile::Mutex m_output_mutex; - /// Used for shadowing the input file when capturing a reproducer. - repro::DataRecorder *m_input_recorder; - lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a // broadcaster manager of // last resort. diff --git a/lldb/scripts/reproducer-replay.py b/lldb/scripts/reproducer-replay.py deleted file mode 100755 index f44e3cf493538..0 --- a/lldb/scripts/reproducer-replay.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python3 - -from multiprocessing import Pool -import multiprocessing -import argparse -import tempfile -import logging -import os -import subprocess - - -def run_reproducer(path): -proc = subprocess.Popen( -[LLDB, "--replay", path], stdout=subprocess.PIPE, stderr=subprocess.PIPE -) -reason = None -try: -outs, errs = proc.communicate(timeout=TIMEOUT) -success = proc.returncode == 0 -result = "PASSED" if success else "FAILED" -if not success: -outs = outs.decode() -errs = errs.decode() -# Do some pattern matching to find out the cause of the failure. -if "Encountered unexpected packet during replay" in errs: -reason = "Unexpected packet" -elif "Assertion failed" in errs: -reason = "Assertion failed" -elif "UNREACHABLE" in errs: -reason = "Unreachable executed" -elif "Segmentation fault" in errs: -reason = "Segmentation fault" -elif "Illegal instruction" in errs: -reason = "Illegal instruction" -else: -reason = f"Exit code {proc.returncode}" -except subprocess.TimeoutExpired: -proc.kill() -success = False -outs, errs = proc.communicate() -result = "TIMEOUT" - -if not FAILURE_ONLY or not success: -reason_str = f" ({reason})" if reason else "" -print(f"{result}: {path}{reason_str}") -if VERBOSE: -if outs: -print(outs) -if errs: -print(errs) - - -def find_reproducers(path): -for root, dirs, files in os.walk(path): -for dir in dirs: -_, extension = os.path.splitext(dir) -if dir.startswith("Test") and extension == ".py": -yield os.path.join(root, dir) - - -if __name__ == "__main
[Lldb-commits] [lldb] [lldb] Remove vestigial remnants of reproducers (PR #135361)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/135361 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits