brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 69e3b80 Raw
78 lines · c
1// XFAIL:*2//// Suboptimal coverage, see description 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//// Adapted from https://bugs.llvm.org/show_bug.cgi?id=34136#c110//// LowerDbgDeclare has since been updated to look through bitcasts. We still11//// get suboptimal coverage at the beginning of 'main' though. For each local,12//// LowerDbgDeclare inserts a dbg.value and a dbg.value+DW_OP_deref before the13//// store (after the call to 'getint') and the call to 'alias' respectively.14//// The first dbg.value describes the result of the 'getint' call, eventually15//// becoming a register location. The second points back into the stack16//// home. There is a gap in the coverage between the quickly clobbered register17//// location and the stack location, even though the stack location is valid18//// during that gap. For x86 we end up with this code at the start of main:19//// 00000000004004b0 <main>:20////   4004b0:  sub    rsp,0x1821////   4004b4:  mov    edi,0x522////   4004b9:  call   400480 <getint>23////   4004be:  mov    DWORD PTR [rsp+0x14],eax24////   4004c2:  mov    edi,0x525////   4004c7:  call   400480 <getint>26////   4004cc:  mov    DWORD PTR [rsp+0x10],eax27////   4004d0:  mov    edi,0x528////   4004d5:  call   400480 <getint>29////   4004da:  mov    DWORD PTR [rsp+0xc],eax30////   ...31//// With these variable locations:32////  DW_TAG_variable33////    DW_AT_location        (0x00000000:34////       [0x00000000004004be, 0x00000000004004cc): DW_OP_reg0 RAX35////       [0x00000000004004de, 0x0000000000400503): DW_OP_breg7 RSP+20)36////    DW_AT_name    ("x")37////    ...38////  DW_TAG_variable39////    DW_AT_location        (0x00000037:40////       [0x00000000004004cc, 0x00000000004004da): DW_OP_reg0 RAX41////       [0x00000000004004e8, 0x0000000000400503): DW_OP_breg7 RSP+16)42////    DW_AT_name    ("y")43////    ...44////  DW_TAG_variable45////    DW_AT_location        (0x0000006e:46////       [0x00000000004004da, 0x00000000004004e8): DW_OP_reg0 RAX47////       [0x00000000004004f2, 0x0000000000400503): DW_OP_breg7 RSP+12)48////    DW_AT_name    ("z")49////    ...50 51char g = 1;52int five = 5;53__attribute__((__noinline__))54int getint(int x) {55  g = x - 4;56  return x * g;57}58 59__attribute__((__noinline__))60void alias(char* c) {61  g = *c;62  *c = (char)five;63}64 65int main() {66  int x = getint(5);67  int y = getint(5); // DexLabel('s1')68  int z = getint(5); // DexLabel('s2')69  alias((char*)&x);  // DexLabel('s3')70  alias((char*)&y);71  alias((char*)&z);72  return 0;          // DexLabel('s4')73}74 75// DexExpectWatchValue('x', '5',  from_line=ref('s1'), to_line=ref('s4'))76// DexExpectWatchValue('y', '5',  from_line=ref('s2'), to_line=ref('s4'))77// DexExpectWatchValue('z', '5',  from_line=ref('s3'), to_line=ref('s4'))78