|
| 1 | +// Tests that ProcessModID.m_memory_id is not bumped when evaluating expressions without side effects. |
| 2 | + |
| 3 | +// REQUIRES: target-windows && target-x86 |
| 4 | +// 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() |
| 5 | +// requires that we write the return address to the stack, this does not happen on AArch64. |
| 6 | + |
| 7 | +// RUN: %build %s -o %t |
| 8 | +// RUN: %lldb %t \ |
| 9 | +// RUN: -o "settings set target.process.track-memory-cache-changes false" \ |
| 10 | +// RUN: -o "run" \ |
| 11 | +// RUN: -o "process status -d" \ |
| 12 | +// RUN: -o "expr x.i != 42" \ |
| 13 | +// RUN: -o "process status -d" \ |
| 14 | +// RUN: -o "expr x.get()" \ |
| 15 | +// RUN: -o "process status -d" \ |
| 16 | +// RUN: -o "expr x.i = 10" \ |
| 17 | +// RUN: -o "process status -d" \ |
| 18 | +// RUN: -o "continue" \ |
| 19 | +// RUN: -o "process status -d" \ |
| 20 | +// RUN: -o "exit" | FileCheck %s -dump-input=fail |
| 21 | + |
| 22 | +class X { |
| 23 | + int i = 0; |
| 24 | + |
| 25 | +public: |
| 26 | + int get() { return i; } |
| 27 | +}; |
| 28 | + |
| 29 | +int main() { |
| 30 | + X x; |
| 31 | + x.get(); |
| 32 | + |
| 33 | + __builtin_debugtrap(); |
| 34 | + __builtin_debugtrap(); |
| 35 | + return 0; |
| 36 | +} |
| 37 | + |
| 38 | +// CHECK-LABEL: process status -d |
| 39 | +// CHECK: m_stop_id: 2 |
| 40 | +// CHECK: m_memory_id: 0 |
| 41 | + |
| 42 | +// CHECK-LABEL: expr x.i != 42 |
| 43 | +// IDs are not changed when executing simple expressions |
| 44 | + |
| 45 | +// CHECK-LABEL: process status -d |
| 46 | +// CHECK: m_stop_id: 2 |
| 47 | +// CHECK: m_memory_id: 0 |
| 48 | + |
| 49 | +// CHECK-LABEL: expr x.get() |
| 50 | +// Expression causes ID to be bumped because LLDB has to execute function and in doing |
| 51 | +// so must write the return address to the stack. |
| 52 | + |
| 53 | +// CHECK-LABEL: process status -d |
| 54 | +// CHECK: m_stop_id: 3 |
| 55 | +// CHECK: m_memory_id: 1 |
| 56 | + |
| 57 | +// CHECK-LABEL: expr x.i = 10 |
| 58 | +// Expression causes MemoryID to be bumped because LLDB writes to non-cache memory |
| 59 | + |
| 60 | +// CHECK-LABEL: process status -d |
| 61 | +// CHECK: m_stop_id: 3 |
| 62 | +// CHECK: m_memory_id: 2 |
| 63 | + |
| 64 | +// CHECK-LABEL: continue |
| 65 | +// Continue causes StopID to be bumped because process is resumed |
| 66 | + |
| 67 | +// CHECK-LABEL: process status -d |
| 68 | +// CHECK: m_stop_id: 4 |
| 69 | +// CHECK: m_memory_id: 2 |
0 commit comments