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
14volatile bool shutting_down_ = true;
15volatile bool tearing_down_ = true;
16
17void __attribute__((optnone)) setCrashString(const char *) {}
18void __attribute__((optnone)) doTailCall() {}
19extern "C" void __declspec(noreturn) abort();
20
21void __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
29void __declspec(noinline) callerOfInlineCrashFrame(bool is_keeping_alive) {
30 if (is_keeping_alive)
31 inlineCrashFrame();
32 else
33 doTailCall();
34}
35
36int __attribute__((optnone)) main() {
37 callerOfInlineCrashFrame(true);
38}
39
40/*
41DexExpectProgramState({'frames':[
42 {'function': 'inlineCrashFrame', 'location':{'lineno' : ref('stop')} },
43 {'function': 'callerOfInlineCrashFrame'},
44 {'function': 'main'}
45]})
46*/
47

source code of cross-project-tests/debuginfo-tests/dexter-tests/inline-line-gap.cpp