home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / debug.prog / RCS / debug.c,v < prev    next >
Encoding:
Text File  |  1991-08-21  |  1.5 KB  |  78 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    mendel:1.1; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     88.10.28.09.04.26;  author ouster;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* 
  26.  * debug.c --
  27.  *
  28.  *    Command to start a process but have it immediately enter
  29.  *    the debugger, before executing any instructions.
  30.  *
  31.  * Copyright 1988 Regents of the University of California
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that the above copyright
  35.  * notice appear in all copies.  The University of California
  36.  * makes no representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  */
  40.  
  41. #ifndef lint
  42. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  43. #endif not lint
  44.  
  45. #include <errno.h>
  46. #include <stdio.h>
  47. #include <string.h>
  48.  
  49. /*
  50.  * Secret trap door into exec to make it put the process into debug state.
  51.  */
  52.  
  53. extern int _execDebug;
  54.  
  55. main(argc, argv)
  56.     int  argc;
  57.     char *argv[];
  58. {
  59.     int    pid;
  60.  
  61.     if (argc < 2) {
  62.     fprintf(stderr, "Usage: %s command arg arg ...\n", argv[0]);
  63.     exit(1);
  64.     }
  65.     pid = getpid();
  66.     printf("Process %X: \"%s\"\n", pid, argv[1]);
  67.     _execDebug = 1;
  68.     execvp(argv[1], &(argv[1]));
  69.  
  70.     /*
  71.      * The exec failed.
  72.      */
  73.  
  74.     fprintf(stderr, "Couldn't execute \"%s\": %s\n", argv[1], strerror(errno));
  75.     exit(1);
  76. }
  77. @
  78.