kdebug.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (c) 2011 The Regents of the University of California
  2. * Barret Rhoden <brho@cs.berkeley.edu>
  3. * See LICENSE for details.
  4. *
  5. * Arch-independent kernel debugging */
  6. #include "u.h"
  7. #include "../port/lib.h"
  8. #include "mem.h"
  9. #include "dat.h"
  10. #include "fns.h"
  11. #include "../port/error.h"
  12. int printx_on = 1;
  13. static int tab_depth = 0;
  14. static void __iprint_hdr(void)
  15. {
  16. Proc *up = externup();
  17. // struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
  18. iprint("Core %2d ", 0); //core_id()); /* may help with multicore output */
  19. if (! islo()) {
  20. iprint("IRQ :");
  21. } else if (up) {
  22. iprint("%d: ", up->pid);
  23. }
  24. }
  25. void __print_func_entry(const char *func, const char *file)
  26. {
  27. char tentabs[] = "\t\t\t\t\t\t\t\t\t\t"; // ten tabs and a \0
  28. char *ourtabs = &tentabs[10 - MIN(tab_depth, 10)];
  29. if (!printx_on)
  30. return;
  31. // if (is_blacklisted(func))
  32. // return;
  33. __iprint_hdr();
  34. iprint("%s%s() in %s\n", ourtabs, func, file);
  35. tab_depth++;
  36. }
  37. void __print_func_exit(const char *func, const char *file)
  38. {
  39. char tentabs[] = "\t\t\t\t\t\t\t\t\t\t"; // ten tabs and a \0
  40. char *ourtabs;
  41. if (!printx_on)
  42. return;
  43. // if (is_blacklisted(func))
  44. // return;
  45. tab_depth--;
  46. ourtabs = &tentabs[10 - MIN(tab_depth, 10)];
  47. __iprint_hdr();
  48. iprint("%s---- %s()\n", ourtabs, func);
  49. }
  50. void set_printx(int mode)
  51. {
  52. switch (mode) {
  53. case 0:
  54. printx_on = 0;
  55. break;
  56. case 1:
  57. printx_on = 1;
  58. break;
  59. case 2:
  60. printx_on = !printx_on;
  61. break;
  62. }
  63. }