Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / libcfs / libcfs / darwin / darwin-debug.c
1 # define DEBUG_SUBSYSTEM S_LNET
2
3 #include <libcfs/libcfs.h>
4 #include "tracefile.h"
5
6 void libcfs_debug_dumpstack(cfs_task_t *tsk)
7
8         return;
9 }
10
11 void libcfs_run_lbug_upcall(char *file, const char *fn, const int line)
12 {
13 }
14
15 void lbug_with_loc(char *file, const char *func, const int line)
16 {
17         libcfs_catastrophe = 1;
18         CEMERG("LBUG: pid: %u thread: %#x\n",
19                (unsigned)cfs_curproc_pid(), (unsigned)current_thread());
20         libcfs_debug_dumplog();
21         libcfs_run_lbug_upcall(file, func, line);
22         while (1)
23                 cfs_schedule();
24
25         /* panic("lbug_with_loc(%s, %s, %d)", file, func, line) */
26 }
27
28 #if ENTRY_NESTING_SUPPORT
29
30 static inline struct cfs_debug_data *__current_cdd(void)
31 {
32         struct cfs_debug_data *cdd;
33
34         cdd = (struct cfs_debug_data *)current_uthread()->uu_nlminfo;
35         if (cdd != NULL &&
36             cdd->magic1 == CDD_MAGIC1 && cdd->magic2 == CDD_MAGIC2 &&
37             cdd->nesting_level < 1000)
38                 return cdd;
39         else
40                 return NULL;
41 }
42
43 static inline void __current_cdd_set(struct cfs_debug_data *cdd)
44 {
45         current_uthread()->uu_nlminfo = (void *)cdd;
46 }
47
48 void __entry_nesting(struct cfs_debug_data *child)
49 {
50         struct cfs_debug_data *parent;
51
52         parent = __current_cdd();
53         if (parent != NULL) {
54                 child->parent        = parent;
55                 child->nesting_level = parent->nesting_level + 1;
56         }
57         __current_cdd_set(child);
58 }
59
60 void __exit_nesting(struct cfs_debug_data *child)
61 {
62         __current_cdd_set(child->parent);
63 }
64
65 unsigned int __current_nesting_level(void)
66 {
67         struct cfs_debug_data *cdd;
68
69         cdd = __current_cdd();
70         if (cdd != NULL)
71                 return cdd->nesting_level;
72         else
73                 return 0;
74 }
75 /* ENTRY_NESTING_SUPPORT */
76 #endif