1// Tests that ProcessModID.m_memory_id is not bumped when evaluating expressions without side effects.
2
3// REQUIRES: target-windows && (target-x86 || target-x86_64)
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/x64 because on x86/x64, 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 "process status -d" \
15// RUN: -o "expr x.get()" \
16// RUN: -o "process status -d" \
17// RUN: -o "process status -d" \
18// RUN: -o "expr x.i = 10" \
19// RUN: -o "process status -d" \
20// RUN: -o "process status -d" \
21// RUN: -o "continue" \
22// RUN: -o "process status -d" \
23// RUN: -o "exit" | FileCheck %s -dump-input=fail
24
25class X {
26 int i = 0;
27
28public:
29 int get() { return i; }
30};
31
32int main() {
33 X x;
34 x.get();
35
36 __builtin_debugtrap();
37 __builtin_debugtrap();
38 return 0;
39}
40
41// CHECK-LABEL: process status -d
42// CHECK: m_stop_id: [[#STOP_ID:]]
43// CHECK: m_memory_id: [[#MEMORY_ID:]]
44
45// CHECK-LABEL: expr x.i != 42
46// IDs are not changed when executing simple expressions
47
48// CHECK-LABEL: process status -d
49// CHECK: m_stop_id: [[#STOP_ID]]
50// CHECK: m_memory_id: [[#MEMORY_ID]]
51
52// CHECK-LABEL: process status -d
53// Remember new values
54// CHECK: m_stop_id: [[#STOP_ID:]]
55// CHECK: m_memory_id: [[#MEMORY_ID:]]
56
57// CHECK-LABEL: expr x.get()
58// Expression causes ID to be bumped because LLDB has to execute function and in doing
59// so must write the return address to the stack.
60
61// CHECK-LABEL: process status -d
62// CHECK-NOT: m_stop_id: [[#STOP_ID]]
63// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]
64
65// CHECK-LABEL: process status -d
66// Remember new values
67// CHECK: m_stop_id: [[#STOP_ID:]]
68// CHECK: m_memory_id: [[#MEMORY_ID:]]
69
70// CHECK-LABEL: expr x.i = 10
71// Expression causes MemoryID to be bumped because LLDB writes to non-cache memory
72
73// CHECK-LABEL: process status -d
74// CHECK: m_stop_id: [[#STOP_ID]]
75// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]
76
77// CHECK-LABEL: process status -d
78// Remember new values
79// CHECK: m_stop_id: [[#STOP_ID:]]
80// CHECK: m_memory_id: [[#MEMORY_ID:]]
81
82// CHECK-LABEL: continue
83// Continue causes StopID to be bumped because process is resumed
84
85// CHECK-LABEL: process status -d
86// CHECK-NOT: m_stop_id: [[#STOP_ID]]
87// CHECK: m_memory_id: [[#MEMORY_ID]]
88

source code of lldb/test/Shell/Expr/TestProcessModificationIdOnExpr.cpp