57 lines · c
1// XFAIL: *2//// Suboptimal coverage, see below.3 4// REQUIRES: lldb5// UNSUPPORTED: system-windows6// RUN: %clang -std=gnu11 -O3 -glldb %s -o %t7// RUN: %dexter --fail-lt 1.0 -w %dexter_lldb_args --binary %t -- %s8 9//// Check that escaped local 'param' in function 'fun' has sensible debug info10//// after the escaping function 'use' gets arg promotion (int* -> int). Currently11//// we lose track of param after the loop header.12 13int g = 0;14//// A no-inline, read-only function with internal linkage is a good candidate15//// for arg promotion.16__attribute__((__noinline__))17static void use(const int* p) {18 //// Promoted args would be a good candidate for an DW_OP_implicit_pointer.19 //// This desirable behaviour is checked for in the test implicit-ptr.c.20 g = *p;21}22 23__attribute__((__noinline__))24void do_thing(int x) {25 g *= x;26}27 28__attribute__((__noinline__))29int fun(int param) {30 do_thing(0); // DexLabel('s2')31 for (int i = 0; i < param; ++i) {32 use(¶m);33 }34 35 //// x86 loop body looks like this, with param in ebx:36 //// 4004b0: mov edi,ebx37 //// 4004b2: call 4004d0 <_ZL3usePKi>38 //// 4004b7: add ebp,0xffffffff39 //// 4004ba: jne 4004b0 <_Z3funi+0x20>40 41 //// But we lose track of param's location before the loop:42 //// DW_TAG_formal_parameter43 //// DW_AT_location (0x00000039:44 //// [0x0000000000400490, 0x0000000000400495): DW_OP_reg5 RDI45 //// [0x0000000000400495, 0x00000000004004a2): DW_OP_reg3 RBX)46 //// DW_AT_name ("param")47 48 return g; // DexLabel('s3')49}50 51int main() {52 return fun(5);53}54 55// DexExpectWatchValue('*p', 5, 5, 5, 5, 5, on_line=ref('s1'))56// DexExpectWatchValue('param', 5, from_line=ref('s2'), to_line=ref('s3'))57