cling/test/Prompt/Exceptions.C
Jonas Hahnfeld c7558a2c0d Reset function sections before JITting
This makes all functions end up in the same text section, which is
important for TCling on macOS to catch exceptions from constructors:
Stack unwinding requires information about program addresses to find
out which objects to destroy and what code should be called to handle
the exception. These addresses are relocated against a single __text
section when loading the produced MachO binary, which breaks if the
call sites of global constructors end up in a separate init section.

Fixes ROOT-10703 and ROOT-10962
2021-02-10 15:18:14 +01:00

29 lines
931 B
C

//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// RUN: cat %s | %cling 2>&1 | FileCheck %s
extern "C" int printf(const char*,...);
struct TheStruct {
char m_Storage[100];
};
// CHECK: About to throw "ABC"
printf("About to throw \"ABC\"\n");
TheStruct getStructButThrows() { throw "ABC!"; }
// CHECK: Exception occurred. Recovering...
getStructButThrows()
struct ThrowInConstructor {
ThrowInConstructor() { throw 1; }
};
// CHECK: About to throw in constructor
printf("About to throw in constructor\n");
// CHECK: Exception occurred. Recovering...
ThrowInConstructor t;