1// REQUIRES: lldb
2// UNSUPPORTED: system-windows
3// RUN: %clang -std=gnu11 -O2 -glldb %s -o %t
4// RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s
5
6//// Check that we give good locations to a variable ('local') which is escaped
7//// down some control paths and not others. This example is handled well currently.
8
9int g;
10__attribute__((__noinline__))
11void leak(int *ptr) {
12 g = *ptr;
13 *ptr = 2;
14}
15
16__attribute__((__noinline__))
17int fun(int cond) {
18 int local = 0; // DexLabel('s1')
19 if (cond)
20 leak(ptr: &local);
21 else
22 local = 1;
23 return local; // DexLabel('s2')
24}
25
26int main() {
27 int a = fun(cond: 1);
28 int b = fun(cond: 0);
29 return a + b;
30}
31
32//// fun(1) fun(0)
33// DexExpectWatchValue('local', '0', '0', on_line=ref('s1'))
34// DexExpectWatchValue('local', '2', '1', on_line=ref('s2'))
35

source code of cross-project-tests/debuginfo-tests/dexter-tests/memvars/ctrl-flow.c