ftape-tracing.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 1993-1996 Bas Laarhoven,
  3. * (C) 1996-1997 Claus-Justus Heine.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  15. *
  16. * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.c,v $
  17. * $Revision: 1.2 $
  18. * $Date: 1997/10/05 19:18:27 $
  19. *
  20. * This file contains the reading code
  21. * for the QIC-117 floppy-tape driver for Linux.
  22. */
  23. #include <linux/ftape.h>
  24. #include "../lowlevel/ftape-tracing.h"
  25. /* Global vars.
  26. */
  27. /* tracing
  28. * set it to: to log :
  29. * 0 bugs
  30. * 1 + errors
  31. * 2 + warnings
  32. * 3 + information
  33. * 4 + more information
  34. * 5 + program flow
  35. * 6 + fdc/dma info
  36. * 7 + data flow
  37. * 8 + everything else
  38. */
  39. ft_trace_t ftape_tracing = ft_t_info; /* Default level: information and up */
  40. int ftape_function_nest_level;
  41. /* Local vars.
  42. */
  43. static __u8 trace_id;
  44. static char spacing[] = "* ";
  45. void ftape_trace_call(const char *file, const char *name)
  46. {
  47. char *indent;
  48. /* Since printk seems not to work with "%*s" format
  49. * we'll use this work-around.
  50. */
  51. if (ftape_function_nest_level < 0) {
  52. printk(KERN_INFO "function nest level (%d) < 0\n",
  53. ftape_function_nest_level);
  54. ftape_function_nest_level = 0;
  55. }
  56. if (ftape_function_nest_level < sizeof(spacing)) {
  57. indent = (spacing +
  58. sizeof(spacing) - 1 -
  59. ftape_function_nest_level);
  60. } else {
  61. indent = spacing;
  62. }
  63. printk(KERN_INFO "[%03d]%s+%s (%s)\n",
  64. (int) trace_id++, indent, file, name);
  65. }
  66. void ftape_trace_exit(const char *file, const char *name)
  67. {
  68. char *indent;
  69. /* Since printk seems not to work with "%*s" format
  70. * we'll use this work-around.
  71. */
  72. if (ftape_function_nest_level < 0) {
  73. printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
  74. ftape_function_nest_level = 0;
  75. }
  76. if (ftape_function_nest_level < sizeof(spacing)) {
  77. indent = (spacing +
  78. sizeof(spacing) - 1 -
  79. ftape_function_nest_level);
  80. } else {
  81. indent = spacing;
  82. }
  83. printk(KERN_INFO "[%03d]%s-%s (%s)\n",
  84. (int) trace_id++, indent, file, name);
  85. }
  86. void ftape_trace_log(const char *file, const char *function)
  87. {
  88. char *indent;
  89. /* Since printk seems not to work with "%*s" format
  90. * we'll use this work-around.
  91. */
  92. if (ftape_function_nest_level < 0) {
  93. printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
  94. ftape_function_nest_level = 0;
  95. }
  96. if (ftape_function_nest_level < sizeof(spacing)) {
  97. indent = (spacing +
  98. sizeof(spacing) - 1 -
  99. ftape_function_nest_level);
  100. } else {
  101. indent = spacing;
  102. }
  103. printk(KERN_INFO "[%03d]%s%s (%s) - ",
  104. (int) trace_id++, indent, file, function);
  105. }