xref: /llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/inline-line-gap.cpp (revision 45a40c163932d12b72b33bd1d8a84519392b5d39)
1 // REQUIRES: system-windows
2 //
3 // RUN: %clang_cl /Od /Z7 /Zi %s -o %t
4 // RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'dbgeng' -- %s
5 //
6 // RUN: %clang_cl /O2 /Z7 /Zi %s -o %t
7 // RUN: %dexter --fail-lt 1.0 -w --binary %t \
8 // RUN:      --debugger 'dbgeng' -- %s
9 
10 // This code is structured to have an early exit with an epilogue in the middle
11 // of the function, which creates a gap between the beginning of the inlined
12 // code region and the end. Previously, this confused cdb.
13 
14 volatile bool shutting_down_ = true;
15 volatile bool tearing_down_ = true;
16 
setCrashString(const char *)17 void __attribute__((optnone)) setCrashString(const char *) {}
doTailCall()18 void __attribute__((optnone)) doTailCall() {}
19 extern "C" void __declspec(noreturn) abort();
20 
inlineCrashFrame()21 void __forceinline inlineCrashFrame() {
22   if (shutting_down_ || tearing_down_) {
23     setCrashString("crashing");
24     // MSVC lays out calls to abort out of line, gets the layout we want.
25     abort(); // DexLabel('stop')
26   }
27 }
28 
callerOfInlineCrashFrame(bool is_keeping_alive)29 void __declspec(noinline) callerOfInlineCrashFrame(bool is_keeping_alive) {
30   if (is_keeping_alive)
31     inlineCrashFrame();
32   else
33     doTailCall();
34 }
35 
main()36 int __attribute__((optnone)) main() {
37   callerOfInlineCrashFrame(true);
38 }
39 
40 /*
41 DexExpectProgramState({'frames':[
42      {'function': 'inlineCrashFrame', 'location':{'lineno' : ref('stop')} },
43      {'function': 'callerOfInlineCrashFrame'},
44      {'function': 'main'}
45 ]})
46 */
47