199451b44SJordan Rupprecht volatile int x; 299451b44SJordan Rupprecht sink()399451b44SJordan Rupprechtvoid __attribute__((noinline)) sink() { 499451b44SJordan Rupprecht x++; //% self.filecheck("bt", "main.cpp", "-implicit-check-not=artificial") 5bddd2888SPavel Labath // CHECK: frame #0: 0x{{[0-9a-f]+}} a.out`sink() at main.cpp:[[@LINE-1]]:4 60081149fSPavel Labath // CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3() at main.cpp:26:3 7bddd2888SPavel Labath // CHECK-SAME: [artificial] 8bddd2888SPavel Labath // CHECK-NEXT: frame #2: 0x{{[0-9a-f]+}} a.out`func2() 90081149fSPavel Labath // CHECK-NEXT: frame #3: 0x{{[0-9a-f]+}} a.out`func1() at main.cpp:35:3 10bddd2888SPavel Labath // CHECK-SAME: [artificial] 11bddd2888SPavel Labath // CHECK-NEXT: frame #4: 0x{{[0-9a-f]+}} a.out`main 120081149fSPavel Labath // In the GNU style, the artificial frames will point after the tail call 130081149fSPavel Labath // instruction. In v5 they should point to the instruction itself. 140081149fSPavel Labath //% frame1 = self.thread().GetFrameAtIndex(1) 150081149fSPavel Labath //% func3 = frame1.GetFunction() 160081149fSPavel Labath //% func3_insns = func3.GetInstructions(self.target()) 170081149fSPavel Labath //% self.trace("func3:\n%s"%func3_insns) 180081149fSPavel Labath //% last_insn = func3_insns.GetInstructionAtIndex(func3_insns.GetSize()-1) 190081149fSPavel Labath //% addr = last_insn.GetAddress() 200081149fSPavel Labath //% if "GNU" in self.name: addr.OffsetAddress(last_insn.GetByteSize()) 21*80fcecb1SJonas Devlieghere //% self.assertEqual(frame1.GetPCAddress(), addr) 2299451b44SJordan Rupprecht } 2399451b44SJordan Rupprecht func3()2403e29e2cSVedant Kumarvoid __attribute__((noinline)) func3() { 2503e29e2cSVedant Kumar x++; 2603e29e2cSVedant Kumar sink(); /* tail */ 2703e29e2cSVedant Kumar } 2899451b44SJordan Rupprecht func2()2903e29e2cSVedant Kumarvoid __attribute__((disable_tail_calls, noinline)) func2() { 3003e29e2cSVedant Kumar func3(); /* regular */ 3103e29e2cSVedant Kumar } 3299451b44SJordan Rupprecht func1()3303e29e2cSVedant Kumarvoid __attribute__((noinline)) func1() { 3403e29e2cSVedant Kumar x++; 3503e29e2cSVedant Kumar func2(); /* tail */ 3603e29e2cSVedant Kumar } 3799451b44SJordan Rupprecht main()3899451b44SJordan Rupprechtint __attribute__((disable_tail_calls)) main() { 3903e29e2cSVedant Kumar // DEBUG: self.runCmd("log enable lldb step -f /tmp/lldbstep.log") 4099451b44SJordan Rupprecht func1(); /* regular */ 4199451b44SJordan Rupprecht return 0; 4299451b44SJordan Rupprecht } 43