home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixlib_1 / !UnixLib37_src_sys_c_debug < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-09  |  2.6 KB  |  124 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/sys/c/RCS/debug,v $
  4.  * $Date: 1996/10/30 21:59:00 $
  5.  * $Revision: 1.3 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: debug,v $
  10.  * Revision 1.3  1996/10/30 21:59:00  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.2  1996/05/06 09:03:14  unixlib
  14.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  15.  * Saved for 3.7a release.
  16.  *
  17.  * Revision 1.1  1996/04/19 21:34:24  simon
  18.  * Initial revision
  19.  *
  20.  ***************************************************************************/
  21.  
  22. static const char rcs_id[] = "$Id: debug,v 1.3 1996/10/30 21:59:00 unixlib Rel $";
  23.  
  24. #ifndef DEBUG
  25. #define DEBUG
  26. #endif
  27.  
  28. /* __debug(s) dumps UNIX status with title "s" */
  29.  
  30. #include <string.h>
  31.  
  32. #include <sys/os.h>
  33. #include <sys/unix.h>
  34. #include <sys/syslib.h>
  35. #include <sys/debug.h>
  36.  
  37. static void
  38. __debugval (char *s, int i)
  39. {
  40.   char *p = "        ";
  41.   int x;
  42.  
  43.   os_print (s);
  44.   x = (strlen (s) & 7);
  45.   x = x ? x : 8;
  46.   os_print (p + x);
  47.   os_prhex (i);
  48. }
  49.  
  50. static void
  51. __debugnl (void)
  52. {
  53.   os_print ("\r\n");
  54. }
  55.  
  56. #define NL() __debugnl()
  57. #define VAL(s,i) __debugval(s,i)
  58.  
  59. void
  60. __debug (char *s)
  61. {
  62.   struct file *f;
  63.   int i;
  64.  
  65.   NL ();
  66.   os_print ("# ");
  67.   if (s)
  68.     os_print (s);
  69.   NL ();
  70.   VAL ("__base: ", (int) __base);
  71.   NL ();
  72.   VAL ("__lomem: ", (int) __lomem);
  73.   VAL (" __himem: ", (int) __himem);
  74.   NL ();
  75.   VAL ("__break: ", (int) __break);
  76.   VAL (" __stack: ", (int) __stack);
  77.   NL ();
  78.   VAL ("__u:", (int) __u);
  79.   NL ();
  80.   VAL ("argc:", __u->argc);
  81.   VAL (" argv:", (int) __u->argv);
  82.   NL ();
  83.   for (i = 0; i < __u->argc; i++)
  84.     {
  85.       VAL ("argv[", (int) (__u->argv + i));
  86.       VAL (" ", i);
  87.       VAL (" ]:", (int) __u->argv[i]);
  88.       os_print (" ");
  89.       os_print (__u->argv[i]);
  90.       NL ();
  91.     }
  92.   VAL ("argb:", (int) __u->argb);
  93.   os_print (" ");
  94.   os_print (__u->argb);
  95.   NL ();
  96.   if (f = __u->file)
  97.     for (i = 0; i < 16; i++)
  98.       {
  99.     VAL ("f[", (int) (f + i));
  100.     VAL (" ", i);
  101.     VAL (" ].dup:", (int) f[i].dup);
  102.     NL ();
  103.       }
  104.   VAL ("pid:", (int) __u->pid);
  105.   VAL (" ppid:", (int) __u->ppid);
  106.   NL ();
  107.   VAL ("pproc:", (int) __u->pproc);
  108.   NL ();
  109.   VAL ("signal_exit:", (int) __u->status.signal_exit);
  110.   NL ();
  111.   VAL ("core_dump:", (int) __u->status.core_dump);
  112.   NL ();
  113.   VAL ("stopped:", (int) __u->status.stopped);
  114.   NL ();
  115.   VAL ("signal:", (int) __u->status.signal);
  116.   NL ();
  117.   VAL ("return_code:", (int) __u->status.return_code);
  118.   NL ();
  119.   VAL (" vreg:", (int) __u->vreg);
  120.   NL ();
  121.   NL ();
  122.   /* os_get (); */
  123. }
  124.