Skip to content

[LLDB] Update DIL assignment to respect ValueObject::CanSetValue - #217960

Open
cmtice wants to merge 1 commit into
llvm:mainfrom
cmtice:dil-restrict-assign
Open

[LLDB] Update DIL assignment to respect ValueObject::CanSetValue#217960
cmtice wants to merge 1 commit into
llvm:mainfrom
cmtice:dil-restrict-assign

Conversation

@cmtice

@cmtice cmtice commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

This will prevent DIL from allowing users to try to assign new values in cases where that could lead to incorrect behavior.

This will prevent DIL from allowing users to try to assign new
values in cases where that could lead to incorrect behavior.
@github-actions

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 34212 tests passed
  • 512 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

lldb-api

lldb-api.commands/frame/var-dil/expr/Assignment/TestFrameVarDILAssign.py
Script:
--
/usr/bin/python3 /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include --env LLVM_TOOLS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --libcxx-include-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/c++/v1 --libcxx-include-target-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/x86_64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib/x86_64-unknown-linux-gnu --triple x86_64-unknown-linux-gnu --build-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build --lldb-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build/module-cache-lldb/lldb-api --clang-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build/module-cache-clang/lldb-api --executable /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/lldb --lldb-python-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/local/lib/python3.12/dist-packages --compiler /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --dsymutil /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --lldb-obj-root /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb --lldb-libs-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --cmake-build-type Release /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/commands/frame/var-dil/expr/Assignment -p TestFrameVarDILAssign.py --timeout 1200
--
Exit Code: 1

Command Output (stdout):
--
Skipping the following test categories: msvcstl, dsym, pdb, gmodules, debugserver, objc

--
Command Output (stderr):
--
FAIL: LLDB (/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-x86_64) :: test_assignment (TestFrameVarDILAssign.TestFrameVarDILAssignment.test_assignment)
Log Files:
 - /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build/commands/frame/var-dil/expr/Assignment/TestFrameVarDILAssign/Failure_test_assignment.log
======================================================================
FAIL: test_assignment (TestFrameVarDILAssign.TestFrameVarDILAssignment.test_assignment)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/commands/frame/var-dil/expr/Assignment/TestFrameVarDILAssign.py", line 26, in test_assignment
    self.expect(
  File "/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2973, in expect
    self.fail(log_msg)
AssertionError: Ran command:
"frame variable '1 = 1'"

Got output:
error: value is not in a writable location

Expecting sub string: "Not allowed to change the value of a constant" (was not found)
Config=x86_64-/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang
----------------------------------------------------------------------
Ran 1 test in 0.376s

FAILED (failures=1)

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 33488 tests passed
  • 907 tests skipped
  • 2 tests failed

Failed Tests

(click on a test name to see its output)

lldb-api

lldb-api.commands/frame/var-dil/expr/Assignment/TestFrameVarDILAssign.py
Script:
--
C:/Python312/python.exe C:/_work/llvm-project/llvm-project/lldb\test\API\dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=C:/_work/llvm-project/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=C:/_work/llvm-project/llvm-project/build/include --env LLVM_TOOLS_DIR=C:/_work/llvm-project/llvm-project/build/./bin --triple x86_64-pc-windows-msvc --build-dir C:/_work/llvm-project/llvm-project/build/lldb-test-build --lldb-module-cache-dir C:/_work/llvm-project/llvm-project/build/lldb-test-build/module-cache-lldb\lldb-api --clang-module-cache-dir C:/_work/llvm-project/llvm-project/build/lldb-test-build/module-cache-clang\lldb-api --executable C:/_work/llvm-project/llvm-project/build/./bin/lldb.exe --lldb-python-dir C:\_work\llvm-project\llvm-project\build\Lib\site-packages --compiler C:/_work/llvm-project/llvm-project/build/./bin/clang.exe --dsymutil C:/_work/llvm-project/llvm-project/build/./bin/dsymutil.exe --make C:/ProgramData/chocolatey/bin/make.exe --llvm-tools-dir C:/_work/llvm-project/llvm-project/build/./bin --lldb-obj-root C:/_work/llvm-project/llvm-project/build/tools/lldb --lldb-libs-dir C:/_work/llvm-project/llvm-project/build/./lib --cmake-build-type Release --env LLDB_LAUNCH_FLAG_USE_PIPES=1 C:\_work\llvm-project\llvm-project\lldb\test\API\commands\frame\var-dil\expr\Assignment -p TestFrameVarDILAssign.py --timeout 1200
--
Exit Code: 1

Command Output (stdout):
--
Skipping the following test categories: libc++, libstdcxx, dwo, dsym, gmodules, debugserver, objc, fork, pexpect


--
Command Output (stderr):
--
FAIL: LLDB (C:\_work\llvm-project\llvm-project\build\bin\clang.exe-x86_64) :: test_assignment (TestFrameVarDILAssign.TestFrameVarDILAssignment.test_assignment)

Log Files:

 - C:\_work\llvm-project\llvm-project\build\lldb-test-build\commands\frame\var-dil\expr\Assignment\TestFrameVarDILAssign\Failure_test_assignment.log

======================================================================

FAIL: test_assignment (TestFrameVarDILAssign.TestFrameVarDILAssignment.test_assignment)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "C:\_work\llvm-project\llvm-project\lldb\test\API\commands\frame\var-dil\expr\Assignment\TestFrameVarDILAssign.py", line 26, in test_assignment

    self.expect(

  File "C:\_work\llvm-project\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 2973, in expect

    self.fail(log_msg)

AssertionError: Ran command:

"frame variable '1 = 1'"



Got output:

error: value is not in a writable location



Expecting sub string: "Not allowed to change the value of a constant" (was not found)

Config=x86_64-C:\_work\llvm-project\llvm-project\build\bin\clang.exe

----------------------------------------------------------------------

Ran 1 test in 1.100s



FAILED (failures=1)


--

lldb-unit

lldb-unit.Target/_/TargetTests_exe/TestTypeSystemMap/GetScratchTypeSystemsIsOrderedByLanguage
Script:
--
C:\_work\llvm-project\llvm-project\build\tools\lldb\unittests\Target\.\TargetTests.exe --gtest_filter=TestTypeSystemMap.GetScratchTypeSystemsIsOrderedByLanguage
--
C:\_work\llvm-project\llvm-project\lldb\unittests\Target\ScratchTypeSystemTest.cpp:117
Expected: (g_fortran90_type_system.get()) < (g_fortran77_type_system.get()), actual: 000001A98A00B4F0 vs 000001A98A00B370


If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-lldb

Author: cmtice

Changes

This will prevent DIL from allowing users to try to assign new values in cases where that could lead to incorrect behavior.


Full diff: https://github.com/llvm/llvm-project/pull/217960.diff

1 Files Affected:

  • (modified) lldb/source/ValueObject/DILEval.cpp (+4)
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index d448444b43eba..9be288173e8f3 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -971,6 +971,10 @@ llvm::Expected<lldb::ValueObjectSP>
 Interpreter::EvaluateAssignment(lldb::ValueObjectSP lhs,
                                 lldb::ValueObjectSP rhs, uint32_t location) {
 
+  // Verify that lhs can accept an assignment.
+  if (llvm::Error err = lhs->CanSetValue())
+    return err;
+
   auto all_ok =
       VerifyAssignmentTypes(lhs->GetCompilerType(), rhs->GetCompilerType());
   if (!all_ok)

@kuilpd

kuilpd commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Need to change the error messages in tests when assigning to constants.

I didn't quite understand from the discussions, will the check for optimizations eventually happen in this function as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants