pfnc.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "rc.h"
  10. #include "exec.h"
  11. #include "io.h"
  12. #include "fns.h"
  13. struct{
  14. void (*f)(void);
  15. char *name;
  16. } fname[] = {
  17. Xappend, "Xappend",
  18. Xassign, "Xassign",
  19. Xasync, "Xasync",
  20. Xbackq, "Xbackq",
  21. Xbang, "Xbang",
  22. Xcase, "Xcase",
  23. Xclose, "Xclose",
  24. Xconc, "Xconc",
  25. Xcount, "Xcount",
  26. Xdelfn, "Xdelfn",
  27. Xdelhere, "Xdelhere",
  28. Xdol, "Xdol",
  29. Xdup, "Xdup",
  30. Xeflag, "Xeflag",
  31. (void (*)(void))Xerror, "Xerror",
  32. Xexit, "Xexit",
  33. Xfalse, "Xfalse",
  34. Xfn, "Xfn",
  35. Xfor, "Xfor",
  36. Xglob, "Xglob",
  37. Xif, "Xif",
  38. Xifnot, "Xifnot",
  39. Xjump, "Xjump",
  40. Xlocal, "Xlocal",
  41. Xmark, "Xmark",
  42. Xmatch, "Xmatch",
  43. Xpipe, "Xpipe",
  44. Xpipefd, "Xpipefd",
  45. Xpipewait, "Xpipewait",
  46. Xpopm, "Xpopm",
  47. Xpopredir, "Xpopredir",
  48. Xqdol, "Xqdol",
  49. Xrdcmds, "Xrdcmds",
  50. Xrdfn, "Xrdfn",
  51. Xrdwr, "Xrdwr",
  52. Xread, "Xread",
  53. Xreturn, "Xreturn",
  54. Xsimple, "Xsimple",
  55. Xsub, "Xsub",
  56. Xsubshell, "Xsubshell",
  57. Xtrue, "Xtrue",
  58. Xunlocal, "Xunlocal",
  59. Xwastrue, "Xwastrue",
  60. Xword, "Xword",
  61. Xwrite, "Xwrite",
  62. 0
  63. };
  64. void
  65. pfnc(io *fd, thread *t)
  66. {
  67. int i;
  68. void (*fn)(void) = t->code[t->pc].f;
  69. list *a;
  70. pfmt(fd, "pid %d cycle %p %d ", getpid(), t->code, t->pc);
  71. for (i = 0; fname[i].f; i++)
  72. if (fname[i].f == fn) {
  73. pstr(fd, fname[i].name);
  74. break;
  75. }
  76. if (!fname[i].f)
  77. pfmt(fd, "%p", fn);
  78. for (a = t->argv; a; a = a->next)
  79. pfmt(fd, " (%v)", a->words);
  80. pchr(fd, '\n');
  81. flush(fd);
  82. }