This reverts commit daa4061d61.
Original PR https://github.com/llvm/llvm-project/pull/129092.
I have restricted the test to X86 Windows because it turns out the only
reason that `expr x.get()` would change m_memory_id is that on x86 we
have to write the return address to the stack in ABIWindows_X86_64::PrepareTrivialCall:
```
// Save return address onto the stack
if (!process_sp->WritePointerToMemory(sp, return_addr, error))
return false;
```
This is not required on AArch64 so m_memory_id was not changed:
```
(lldb) expr x.get()
(int) $0 = 0
(lldb) process status -d
Process 15316 stopped
* thread #1, stop reason = Exception 0x80000003 encountered at address 0x7ff764a31034
frame #0: 0x00007ff764a31038 TestProcessModificationIdOnExpr.cpp.tmp`main at TestProcessModificationIdOnExpr.cpp:35
32 __builtin_debugtrap();
33 __builtin_debugtrap();
34 return 0;
-> 35 }
36
37 // CHECK-LABEL: process status -d
38 // CHECK: m_stop_id: 2
ProcessModID:
m_stop_id: 3
m_last_natural_stop_id: 0
m_resume_id: 0
m_memory_id: 0
```
Really we should find a better way to force a memory write here, but
I can't think of one right now.
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
// Tests that ProcessModID.m_memory_id is not bumped when evaluating expressions without side effects.
|
|
|
|
// REQUIRES: target-windows && target-x86
|
|
// Due to different implementations exact numbers (m_stop_id) are different on different OSs. So we lock this test to specific platform (Windows). It is limited to x86 because on x86, running get()
|
|
// requires that we write the return address to the stack, this does not happen on AArch64.
|
|
|
|
// RUN: %build %s -o %t
|
|
// RUN: %lldb %t \
|
|
// RUN: -o "settings set target.process.track-memory-cache-changes false" \
|
|
// RUN: -o "run" \
|
|
// RUN: -o "process status -d" \
|
|
// RUN: -o "expr x.i != 42" \
|
|
// RUN: -o "process status -d" \
|
|
// RUN: -o "expr x.get()" \
|
|
// RUN: -o "process status -d" \
|
|
// RUN: -o "expr x.i = 10" \
|
|
// RUN: -o "process status -d" \
|
|
// RUN: -o "continue" \
|
|
// RUN: -o "process status -d" \
|
|
// RUN: -o "exit" | FileCheck %s -dump-input=fail
|
|
|
|
class X {
|
|
int i = 0;
|
|
|
|
public:
|
|
int get() { return i; }
|
|
};
|
|
|
|
int main() {
|
|
X x;
|
|
x.get();
|
|
|
|
__builtin_debugtrap();
|
|
__builtin_debugtrap();
|
|
return 0;
|
|
}
|
|
|
|
// CHECK-LABEL: process status -d
|
|
// CHECK: m_stop_id: 2
|
|
// CHECK: m_memory_id: 0
|
|
|
|
// CHECK-LABEL: expr x.i != 42
|
|
// IDs are not changed when executing simple expressions
|
|
|
|
// CHECK-LABEL: process status -d
|
|
// CHECK: m_stop_id: 2
|
|
// CHECK: m_memory_id: 0
|
|
|
|
// CHECK-LABEL: expr x.get()
|
|
// Expression causes ID to be bumped because LLDB has to execute function and in doing
|
|
// so must write the return address to the stack.
|
|
|
|
// CHECK-LABEL: process status -d
|
|
// CHECK: m_stop_id: 3
|
|
// CHECK: m_memory_id: 1
|
|
|
|
// CHECK-LABEL: expr x.i = 10
|
|
// Expression causes MemoryID to be bumped because LLDB writes to non-cache memory
|
|
|
|
// CHECK-LABEL: process status -d
|
|
// CHECK: m_stop_id: 3
|
|
// CHECK: m_memory_id: 2
|
|
|
|
// CHECK-LABEL: continue
|
|
// Continue causes StopID to be bumped because process is resumed
|
|
|
|
// CHECK-LABEL: process status -d
|
|
// CHECK: m_stop_id: 4
|
|
// CHECK: m_memory_id: 2
|