Changeset 16366


Ignore:
Timestamp:
Apr 11, 2015, 11:42:54 PM (4 years ago)
Author:
gb
Message:

newfangled --debug option. Seems to work on Linux, untested elsewhere.

Location:
trunk/source/lisp-kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/lisp-debug.c

    r16314 r16366  
    2828#include <errno.h>
    2929#include <stdio.h>
    30 
    31 #ifdef WINDOWS
     30#include <sys/stat.h>
     31
     32
    3233#include <fcntl.h>
    33 #else
     34#ifndef WINDOWS
    3435#include <sys/socket.h>
    3536#include <dlfcn.h>
    3637#endif
    37 #include <sys/stat.h>
    38 
    39 FILE *dbgout = NULL;
     38
     39
     40FILE *dbgout = NULL, *dbgin=NULL;
    4041
    4142typedef enum {
     
    219220#endif
    220221
     222void
     223redirect_debugger_io()
     224{
     225#ifndef WINDOWS
     226  if (!isatty(fileno(dbgin))) {
     227    int fd = open("/dev/tty", O_RDWR);
     228    if (fd >=0) {
     229      dbgin=fdopen(fd,"r");
     230      open_debug_output(fd);
     231    }
     232#endif
     233  }
     234}
     235     
    221236int
    222237readc()
     
    226241
    227242  while (tries) {
    228     c = getchar();
     243    c = fgetc(dbgin);
    229244    switch(c) {
    230245    case '\n':
     
    873888    fprintf(dbgout, "\n %s :",prompt);
    874889    buf[0] = 0;
    875     res = fgets(buf, sizeof(buf), stdin);
     890    res = fgets(buf, sizeof(buf),dbgin);
    876891  } while (0);
    877892  p = strchr(res, '\n');
     
    893908    fprintf(dbgout, "\n  %s :", prompt);
    894909    s[0]=0;
    895     res = fgets(s, 24, stdin);
     910    res = fgets(s, 24, dbgin);
    896911    val = strtoul(res,&endptr,0);
    897912  } while (*endptr);
     
    909924    fpurge(stdin);
    910925    fprintf(dbgout, "\n  %s :", prompt);
    911     res = fgets(s, 24, stdin);
     926    res = fgets(s, 24, dbgin);
    912927    n = sscanf(res, "%i", &val);
    913928  } while ((n != 1) || (val > 31));
  • trunk/source/lisp-kernel/lisp.h

    r16135 r16366  
    9292void ensure_static_conses(ExceptionInformation *, TCR *,natural);
    9393
    94 extern FILE *dbgout;
     94extern FILE *dbgout,*dbgin;
     95
     96extern void redirect_debugger_io(void);
    9597
    9698#define RESERVE_FOR_LISP 1
     
    105107extern void lower_heap_start(BytePtr, area*);
    106108
     109
    107110#endif /* __lisp__ */
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r16314 r16366  
    11661166  fprintf(dbgout, "\t-b, --batch: exit when EOF on *STANDARD-INPUT*\n");
    11671167  fprintf(dbgout, "\t--no-sigtrap : obscure option for running under GDB\n");
     1168  fprintf(dbgout, "\t--debug : try to ensure that kernel debugger uses a TTY for I/O\n");
    11681169  fprintf(dbgout, "\t-I, --image-name <image-name>\n");
    11691170#ifndef WINDOWS
     
    12401241  extern int NXArgc;
    12411242#endif
    1242 
     1243  dbgin = stdin;
    12431244  for (i = 1; i < argc;) {
    12441245    arg = argv[i];
     
    13691370        batch_flag = 1;
    13701371        num_elide = 1;
    1371       } else if (strcmp(arg,"--") == 0) {
     1372      } else if ((strcmp (arg, "-d") == 0) ||
     1373                 (strcmp (arg, "--debug")  == 0)) {
     1374        redirect_debugger_io();
     1375        num_elide=1;
     1376       
     1377        } else if (strcmp(arg,"--") == 0) {
     1378                     
    13721379        break;
    13731380      } else {
Note: See TracChangeset for help on using the changeset viewer.