1 #ifndef _FTAPE_TRACING_H
2 #define _FTAPE_TRACING_H
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.h,v $
25 * $Date: 1997/10/05 19:18:28 $
27 * This file contains definitions that eases the debugging of the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
31 #include <linux/kernel.h>
34 * Be very careful with TRACE_EXIT and TRACE_ABORT.
36 * if (something) TRACE_EXIT error;
44 * instead. Maybe a bit dangerous, but save lots of lines of code.
47 #define LL_X "%d/%d KB"
48 #define LL(x) (unsigned int)((__u64)(x)>>10), (unsigned int)((x)&1023)
63 #ifdef CONFIG_FT_NO_TRACE_AT_ALL
64 /* the compiler will optimize away most TRACE() macros
66 #define FT_TRACE_TOP_LEVEL ft_t_bug
67 #define TRACE_FUN(level) do {} while(0)
68 #define TRACE_EXIT return
69 #define TRACE(l, m, i...) \
71 if ((ft_trace_t)(l) == FT_TRACE_TOP_LEVEL) { \
72 printk(KERN_INFO"ftape%s(%s):\n" \
73 KERN_INFO m".\n" ,__FILE__, __FUNCTION__ , ##i); \
76 #define SET_TRACE_LEVEL(l) if ((l) == (l)) do {} while(0)
77 #define TRACE_LEVEL FT_TRACE_TOP_LEVEL
81 #ifdef CONFIG_FT_NO_TRACE
82 /* the compiler will optimize away many TRACE() macros
83 * the ftape_simple_trace_call() function simply increments
84 * the function nest level.
86 #define FT_TRACE_TOP_LEVEL ft_t_warn
87 #define TRACE_FUN(level) ftape_function_nest_level++
88 #define TRACE_EXIT ftape_function_nest_level--; return
91 #ifdef CONFIG_FT_FULL_DEBUG
92 #define FT_TRACE_TOP_LEVEL ft_t_any
94 #define FT_TRACE_TOP_LEVEL ft_t_flow
96 #define TRACE_FUN(level) \
97 const ft_trace_t _tracing = level; \
98 if (ftape_tracing >= (ft_trace_t)(level) && \
99 (ft_trace_t)(level) <= FT_TRACE_TOP_LEVEL) \
100 ftape_trace_call(__FILE__, __FUNCTION__); \
101 ftape_function_nest_level ++;
104 --ftape_function_nest_level; \
105 if (ftape_tracing >= (ft_trace_t)(_tracing) && \
106 (ft_trace_t)(_tracing) <= FT_TRACE_TOP_LEVEL) \
107 ftape_trace_exit(__FILE__, __FUNCTION__); \
112 #define TRACE(l, m, i...) \
114 if (ftape_tracing >= (ft_trace_t)(l) && \
115 (ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
116 ftape_trace_log(__FILE__, __FUNCTION__); \
117 printk(m".\n" ,##i); \
121 #define SET_TRACE_LEVEL(l) \
123 if ((ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
124 ftape_tracing = (ft_trace_t)(l); \
126 ftape_tracing = FT_TRACE_TOP_LEVEL; \
129 #define TRACE_LEVEL \
130 ((ftape_tracing <= FT_TRACE_TOP_LEVEL) ? ftape_tracing : FT_TRACE_TOP_LEVEL)
133 /* Global variables declared in tracing.c
135 extern ft_trace_t ftape_tracing; /* sets default level */
136 extern int ftape_function_nest_level;
138 /* Global functions declared in tracing.c
140 extern void ftape_trace_call(const char *file, const char *name);
141 extern void ftape_trace_exit(const char *file, const char *name);
142 extern void ftape_trace_log (const char *file, const char *name);
144 #endif /* !defined(CONFIG_FT_NO_TRACE_AT_ALL) */
147 * Abort with a message.
149 #define TRACE_ABORT(res, i...) \
155 /* The following transforms the common "if(result < 0) ... " into a
158 #define _TRACE_CATCH(level, fun, action) \
162 do { action /* */ ; } while(0); \
163 TRACE_ABORT(_res, level, "%s failed: %d", #fun, _res); \
167 #define TRACE_CATCH(fun, fail) _TRACE_CATCH(ft_t_err, fun, fail)
169 /* Abort the current function when signalled. This doesn't belong here,
170 * but rather into ftape-rw.h (maybe)
172 #define FT_SIGNAL_EXIT(sig_mask) \
173 if (sigtestsetmask(¤t->pending.signal, sig_mask)) { \
174 TRACE_ABORT(-EINTR, \
176 "interrupted by non-blockable signal"); \
179 #endif /* _FTAPE_TRACING_H */