Motr  M0
kassert.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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 
29 #include <linux/kernel.h> /* pr_emerg */
30 #include <linux/bug.h> /* BUG */
31 #include <linux/string.h> /* strcmp */
32 #include <linux/delay.h> /* mdelay */
33 /*#include <linux/kgdb.h>*/ /* kgdb_breakpoint() */
34 
35 #include "lib/assert.h" /* m0_failed_condition */
36 #include "motr/version.h" /* m0_build_info */
37 
38 static int m0_panic_delay_msec = 110;
39 
41 {
42  dump_stack();
43 }
44 
45 M0_INTERNAL void m0_arch_panic(const struct m0_panic_ctx *c, va_list ap)
46 {
47  const struct m0_build_info *bi = m0_build_info_get();
48 
49  pr_emerg("Motr panic: %s at %s() %s:%i (last failed: %s) [git: %s]\n",
50  c->pc_expr, c->pc_func, c->pc_file, c->pc_lineno,
51  m0_failed_condition ?: "none", bi->bi_git_describe);
52  if (c->pc_fmt != NULL) {
53  pr_emerg("Motr panic reason: ");
54  vprintk(c->pc_fmt, ap);
55  pr_emerg("\n");
56  }
57  dump_stack();
58  /*
59  * Delay BUG() call in in order to allow m0traced process to fetch all
60  * trace records from kernel buffer, before system-wide Kernel Panic is
61  * triggered.
62  */
63  mdelay(m0_panic_delay_msec);
64  BUG();
65 }
66 
67 M0_INTERNAL void m0_debugger_invoke(void)
68 {
69 /*
70 #ifdef CONFIG_KGDB
71  kgdb_breakpoint();
72 #endif
73 */
74 }
75 
78 /*
79  * Local variables:
80  * c-indentation-style: "K&R"
81  * c-basic-offset: 8
82  * tab-width: 8
83  * fill-column: 80
84  * scroll-step: 1
85  * End:
86  */
87 /*
88  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
89  */
#define NULL
Definition: misc.h:38
M0_INTERNAL const char * m0_failed_condition
Definition: misc.c:224
const struct m0_build_info * m0_build_info_get(void)
Definition: version.c:61
static struct m0_addb2_callback c
Definition: consumer.c:41
M0_INTERNAL void m0_debugger_invoke(void)
Definition: kassert.c:67
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
static int m0_panic_delay_msec
Definition: kassert.c:38