Motr  M0
assert.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB
24 #include "lib/trace.h"
25 
26 #include "lib/assert.h"
27 #include "lib/misc.h" /* M0_CAT */
28 #include "lib/trace_internal.h" /* m0_trace_file_path_get */
29 #include "motr/version.h" /* m0_build_info */
30 
40 void m0_panic(const struct m0_panic_ctx *ctx, ...)
41 {
42  static int repanic = 0;
43  va_list ap;
44  const struct m0_build_info *bi = m0_build_info_get();
45 
46  if (repanic++ == 0) {
47  M0_LOG(M0_FATAL, "panic: %s at %s() (%s:%i) %s [git: %s] %s",
48  ctx->pc_expr, ctx->pc_func, ctx->pc_file, ctx->pc_lineno,
51  va_start(ap, ctx);
52  m0_arch_panic(ctx, ap);
53  va_end(ap);
54  } else {
55  /* The death of God left the angels in a strange position. */
56  while (true) {
57  ;
58  }
59  }
60 }
61 M0_EXPORTED(m0_panic);
62 
63 M0_INTERNAL void m0_panic_only(const struct m0_panic_ctx *ctx, ...)
64 {
65  va_list ap;
66 
67  va_start(ap, ctx);
68  m0_arch_panic(ctx, ap);
69  va_end(ap);
70 }
71 
72 void m0_backtrace(void)
73 {
75 }
76 M0_EXPORTED(m0_backtrace);
77 
78 M0_INTERNAL void m0__assertion_hook(void)
79 {
80 }
81 M0_EXPORTED(m0__assertion_hook);
82 
84 #undef M0_TRACE_SUBSYSTEM
85 
86 /*
87  * Local variables:
88  * c-indentation-style: "K&R"
89  * c-basic-offset: 8
90  * tab-width: 8
91  * fill-column: 80
92  * scroll-step: 1
93  * End:
94  */
void m0_backtrace(void)
Definition: assert.c:72
#define M0_LOG(level,...)
Definition: trace.h:167
void m0_panic(const struct m0_panic_ctx *ctx,...)
Definition: assert.c:40
M0_INTERNAL const char * m0_trace_file_path_get(void)
Definition: ktrace.c:72
M0_INTERNAL const char * m0_failed_condition
Definition: misc.c:224
M0_INTERNAL void m0_panic_only(const struct m0_panic_ctx *ctx,...)
Definition: assert.c:63
M0_INTERNAL void m0__assertion_hook(void)
Definition: assert.c:78
const struct m0_build_info * m0_build_info_get(void)
Definition: version.c:61
M0_INTERNAL void m0_arch_backtrace(void)
Definition: kassert.c:40
const char * bi_git_describe
Definition: version.h:35
M0_INTERNAL void m0_arch_panic(const struct m0_panic_ctx *ctx, va_list ap) __attribute__((noreturn))
Definition: kassert.c:45
Definition: nucleus.c:42