aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp
blob: 4fc88b62730c7b7fd4ec1c72c07e02cddfb47b78 (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
// Tests evaluating expressions with side effects.
// Applied side effect should be visible to the debugger.

// RUN: %build %s -o %t
// RUN: %lldb %t \
// RUN:   -o "settings set target.process.track-memory-cache-changes false" \
// RUN:   -o "run" \
// RUN:   -o "frame variable x" \
// RUN:   -o "expr x.inc()" \
// RUN:   -o "frame variable x" \
// RUN:   -o "continue" \
// RUN:   -o "frame variable x" \
// RUN:   -o "expr x.i = 10" \
// RUN:   -o "frame variable x" \
// RUN:   -o "continue" \
// RUN:   -o "frame variable x" \
// RUN:   -o "exit" | FileCheck %s -dump-input=fail

class X {
  int i = 0;

public:
  void inc() { ++i; }
};

int main() {
  X x;
  x.inc();

  __builtin_debugtrap();
  __builtin_debugtrap();
  __builtin_debugtrap();
  return 0;
}

// CHECK-LABEL: frame variable x
// CHECK: (X) x = (i = 1)

// CHECK-LABEL: expr x.inc()
// CHECK-LABEL: frame variable x
// CHECK: (X) x = (i = 2)

// CHECK-LABEL: continue
// CHECK-LABEL: frame variable x
// CHECK: (X) x = (i = 2)

// CHECK-LABEL: expr x.i = 10
// CHECK: (int) $0 = 10

// CHECK-LABEL: frame variable x
// CHECK: (X) x = (i = 10)

// CHECK-LABEL: continue
// CHECK-LABEL: frame variable x
// CHECK: (X) x = (i = 10)