[Lldb-commits] [lldb] 0c2b7fa - Leave DW_OP_addr addresses as load addresses in DWARFExpression

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 2 14:45:10 PST 2022


Author: Jason Molenda
Date: 2022-12-02T14:45:02-08:00
New Revision: 0c2b7fa8691e9d1f6c7dd656e44321ef8c84ae87

URL: https://github.com/llvm/llvm-project/commit/0c2b7fa8691e9d1f6c7dd656e44321ef8c84ae87
DIFF: https://github.com/llvm/llvm-project/commit/0c2b7fa8691e9d1f6c7dd656e44321ef8c84ae87.diff

LOG: Leave DW_OP_addr addresses as load addresses in DWARFExpression

DWARFExpression::Evaluate will convert DW_OP_addr addresses in
a DWARF expression into load addresses on the expression stack
when there is a StackFrame in the ExecutionContext, this from
a change in 2018 in https://reviews.llvm.org/D46362.  At the
time this was handling a case that came up in swift programs,
and is no longer necessary.  I generalized this conversion to
a load address when a Target is available in
https://reviews.llvm.org/D137682 to make a test case possible;
this change broke a use case that Ted reported.

This change removes my test case, and removes this conversion
of a DW_OP_addr into a load address in some instances.

Differential Revision: https://reviews.llvm.org/D139226

Added: 
    

Modified: 
    lldb/source/Expression/DWARFExpression.cpp

Removed: 
    lldb/test/API/lang/c/high-mem-global/Makefile
    lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py
    lldb/test/API/lang/c/high-mem-global/main.c


################################################################################
diff  --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 9e7df2d3b82ef..e92216bb5e4d5 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -925,10 +925,6 @@ bool DWARFExpression::Evaluate(
         stack.back().SetValueType(Value::ValueType::LoadAddress);
       } else {
         stack.back().SetValueType(Value::ValueType::FileAddress);
-        // Convert the file address to a load address, so subsequent
-        // DWARF operators can operate on it.
-        if (target)
-          stack.back().ConvertToLoadAddress(module_sp.get(), target);
       }
       break;
 

diff  --git a/lldb/test/API/lang/c/high-mem-global/Makefile b/lldb/test/API/lang/c/high-mem-global/Makefile
deleted file mode 100644
index 10495940055b6..0000000000000
--- a/lldb/test/API/lang/c/high-mem-global/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules

diff  --git a/lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py b/lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py
deleted file mode 100644
index b0df19ac690c7..0000000000000
--- a/lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""Look that lldb can display a global loaded in high memory at an addressable address."""
-
-
-import lldb
-from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
-from lldbsuite.test.decorators import *
-
-class TestHighMemGlobal(TestBase):
-
-    NO_DEBUG_INFO_TESTCASE = True
-
-    @skipUnlessDarwin  # hardcoding of __DATA segment name
-    def test_command_line(self):
-        """Test that we can display a global variable loaded in high memory."""
-        self.build()
-
-        exe = self.getBuildArtifact("a.out")
-        err = lldb.SBError()
-
-        target = self.dbg.CreateTarget(exe, '', '', False, err)
-        self.assertTrue(target.IsValid())
-        module = target.GetModuleAtIndex(0)
-        self.assertTrue(module.IsValid())
-        data_segment = module.FindSection("__DATA")
-        self.assertTrue(data_segment.IsValid())
-        err.Clear()
-
-        self.expect("expr -- global.c", substrs=[' = 1'])
-        self.expect("expr -- global.d", substrs=[' = 2'])
-        self.expect("expr -- global.e", substrs=[' = 3'])
-
-        err = target.SetSectionLoadAddress(data_segment, 0xffffffff00000000)
-        self.assertTrue(err.Success())
-        self.expect("expr -- global.c", substrs=[' = 1'])
-        self.expect("expr -- global.d", substrs=[' = 2'])
-        self.expect("expr -- global.e", substrs=[' = 3'])
-
-        err = target.SetSectionLoadAddress(data_segment, 0x0000088100004000)
-        self.assertTrue(err.Success())
-        self.expect("expr -- global.c", substrs=[' = 1'])
-        self.expect("expr -- global.d", substrs=[' = 2'])
-        self.expect("expr -- global.e", substrs=[' = 3'])
-
-        # This is an address in IRMemoryMap::FindSpace where it has an 
-        # lldb-side buffer of memory that's used in IR interpreters when
-        # memory cannot be allocated in the inferior / functions cannot
-        # be jitted.
-        err = target.SetSectionLoadAddress(data_segment, 0xdead0fff00000000)
-        self.assertTrue(err.Success())
-
-        # The global variable `global` is now overlayed by this 
-        # IRMemoryMap special buffer, and now we cannot see the variable.
-        # Testing that we get the incorrect values at this address ensures 
-        # that IRMemoryMap::FindSpace and this test stay in sync.
-        self.runCmd("expr -- int $global_c = global.c")
-        self.runCmd("expr -- int $global_d = global.d")
-        self.runCmd("expr -- int $global_e = global.e")
-        self.expect("expr -- $global_c != 1 || $global_d != 2 || $global_e != 3", substrs=[' = true'])

diff  --git a/lldb/test/API/lang/c/high-mem-global/main.c b/lldb/test/API/lang/c/high-mem-global/main.c
deleted file mode 100644
index ae75f64107332..0000000000000
--- a/lldb/test/API/lang/c/high-mem-global/main.c
+++ /dev/null
@@ -1,9 +0,0 @@
-
-struct mystruct {
-  int c, d, e;
-} global = {1, 2, 3};
-
-int main ()
-{
-  return global.c; // break here
-}


        


More information about the lldb-commits mailing list