/Users/buildslave/jenkins/workspace/coverage/llvm-project/libcxx/src/legacy_debug_handler.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===----------------------------------------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include <__config> |
10 | | #include <cstdio> |
11 | | #include <cstdlib> |
12 | | #include <string> |
13 | | |
14 | | // This file defines the legacy default debug handler and related mechanisms |
15 | | // to set it. This is for backwards ABI compatibility with code that has been |
16 | | // using this debug handler previously. |
17 | | |
18 | | _LIBCPP_BEGIN_NAMESPACE_STD |
19 | | |
20 | | struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { |
21 | | _LIBCPP_EXPORTED_FROM_ABI string what() const; |
22 | | |
23 | | const char* __file_; |
24 | | int __line_; |
25 | | const char* __pred_; |
26 | | const char* __msg_; |
27 | | }; |
28 | | |
29 | 0 | std::string __libcpp_debug_info::what() const { |
30 | 0 | string msg = __file_; |
31 | 0 | msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '"; |
32 | 0 | msg += __pred_; |
33 | 0 | msg += "' failed. "; |
34 | 0 | msg += __msg_; |
35 | 0 | return msg; |
36 | 0 | } |
37 | | |
38 | 0 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __libcpp_abort_debug_function(__libcpp_debug_info const& info) { |
39 | 0 | std::fprintf(stderr, "%s\n", info.what().c_str()); |
40 | 0 | std::abort(); |
41 | 0 | } |
42 | | |
43 | | typedef void (*__libcpp_debug_function_type)(__libcpp_debug_info const&); |
44 | | |
45 | | _LIBCPP_EXPORTED_FROM_ABI |
46 | | constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function; |
47 | | |
48 | | _LIBCPP_EXPORTED_FROM_ABI |
49 | 0 | bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) { |
50 | 0 | __libcpp_debug_function = __func; |
51 | 0 | return true; |
52 | 0 | } |
53 | | |
54 | | _LIBCPP_END_NAMESPACE_STD |