aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/Expr/TestProcessModificationIdOnExpr.cpp
blob: 4d672007450187e4009babdb9e8d771db6889c37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Tests that ProcessModID.m_memory_id is not bumped when evaluating expressions without side effects.

// REQUIRES: target-windows && (target-x86 || target-x86_64)
// 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()
// 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 "process status -d" \
// RUN:   -o "expr x.get()" \
// RUN:   -o "process status -d" \
// RUN:   -o "process status -d" \
// RUN:   -o "expr x.i = 10" \
// RUN:   -o "process status -d" \
// 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: [[#STOP_ID:]]
// CHECK: m_memory_id: [[#MEMORY_ID:]]

// CHECK-LABEL: expr x.i != 42
// IDs are not changed when executing simple expressions

// CHECK-LABEL: process status -d
// CHECK: m_stop_id: [[#STOP_ID]]
// CHECK: m_memory_id: [[#MEMORY_ID]]

// CHECK-LABEL: process status -d
// Remember new values
// CHECK: m_stop_id: [[#STOP_ID:]]
// CHECK: m_memory_id: [[#MEMORY_ID:]]

// 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-NOT: m_stop_id: [[#STOP_ID]]
// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]

// CHECK-LABEL: process status -d
// Remember new values
// CHECK: m_stop_id: [[#STOP_ID:]]
// CHECK: m_memory_id: [[#MEMORY_ID:]]

// 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: [[#STOP_ID]]
// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]

// CHECK-LABEL: process status -d
// Remember new values
// CHECK: m_stop_id: [[#STOP_ID:]]
// CHECK: m_memory_id: [[#MEMORY_ID:]]

// CHECK-LABEL: continue
// Continue causes StopID to be bumped because process is resumed

// CHECK-LABEL: process status -d
// CHECK-NOT: m_stop_id: [[#STOP_ID]]
// CHECK: m_memory_id: [[#MEMORY_ID]]