Changeset ad4bc9 in git


Ignore:
Timestamp:
May 6, 1999, 6:53:35 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
c59d88ee06883f262adb708e6846ac13d54018e3
Parents:
8d4732632f41e8c44b6ae3e871af2513fba44823
Message:
* hannes: Debugger-changes, typo fixes


git-svn-id: file:///usr/local/Singular/svn/trunk@3028 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r8d4732 rad4bc9  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.90 1999-04-29 11:38:40 Singular Exp $ */
     4/* $Id: extra.cc,v 1.91 1999-05-06 16:53:21 Singular Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    940940        {
    941941          sdb_lines[i]=lineno;
     942          sdb_files[i]=p->libname;
    942943          i++;
    943944          Print("breakpoint %d, at line %d in %s\n",i,lineno,p->procname);
     
    948949      {
    949950        WerrorS("system(\"breakpoint\",`proc`,`int`) expected");
     951        return TRUE;
     952      }
     953      return FALSE;
     954    }
     955    else
     956/*==================== sdb_flags =================*/
     957    if (strcmp(sys_cmd, "sdb_flags") == 0)
     958    {
     959      if ((h!=NULL) && (h->Typ()==INT_CMD))
     960      {
     961        sdb_flags=(int)h->Data();
     962      }
     963      else
     964      {
     965        WerrorS("system(\"sdb_flags\",`int`) expected");
     966        return TRUE;
     967      }
     968      return FALSE;
     969    }
     970    else
     971/*==================== sdb_edit =================*/
     972    if (strcmp(sys_cmd, "sdb_edit") == 0)
     973    {
     974      if ((h!=NULL) && (h->Typ()==PROC_CMD))
     975      {
     976        procinfov p=(procinfov)h->Data();
     977        sdb_edit(p);
     978      }
     979      else
     980      {
     981        WerrorS("system(\"sdb_edit\",`proc`) expected");
    950982        return TRUE;
    951983      }
  • Singular/febase.inc

    r8d4732 rad4bc9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: febase.inc,v 1.23 1999-04-29 16:57:12 Singular Exp $ */
     4/* $Id: febase.inc,v 1.24 1999-05-06 16:53:22 Singular Exp $ */
    55/*
    66* ABSTRACT: handling of 'voices'
     
    430430  && (currentVoice->pi->trace_flag!=0))
    431431  {
    432     sdb(currentVoice, anf, len_s, b);
     432    sdb(currentVoice, anf, len_s);
    433433  }
    434434  prompt_char = '.';
     
    447447    {
    448448  NewBuff:
    449       int i=0;
    450       int startfptr=currentVoice->fptr;
     449      register int i=0;
     450      long startfptr=currentVoice->fptr;
     451      long tmp_ptr=currentVoice->fptr;
    451452      l--;
    452453      loop
    453454      {
    454         char c=
    455         b[i]=currentVoice->buffer[currentVoice->fptr];
     455        register char c=
     456        b[i]=currentVoice->buffer[tmp_ptr/*currentVoice->fptr*/];
    456457        i++;
    457458        if (yy_noeof==noeof_block)
     
    469470        }
    470471        if (i>=l) break;
    471         currentVoice->fptr++;
    472         if(currentVoice->buffer[currentVoice->fptr]=='\0') break;
    473       }
     472        tmp_ptr++;/*currentVoice->fptr++;*/
     473        if(currentVoice->buffer[tmp_ptr/*currentVoice->fptr*/]=='\0') break;
     474      }
     475      currentVoice->fptr=tmp_ptr;
    474476      b[i]='\0';
    475477      if (currentVoice->sw==BI_buffer)
     
    522524      s=fe_fgets_stdin(fe_promptstr,
    523525                       currentVoice->buffer+offset,
    524                        (4096-1-sizeof(ADDRESS))-offset);
     526                       (4096-1-sizeof(ADDRESS))-offset);
    525527    }
    526528    else if (currentVoice->sw==BI_file)
     
    530532    }
    531533    //else /* BI_buffer */ s==NULL  => return 0
    532     //{
    533     //  return 0;
    534     //}
     534    // done by the default return
    535535  }
    536536  if (s!=NULL)
     
    556556  /* else if (s==NULL) */
    557557  {
    558     char *err=NULL;
     558    char *err;
    559559    switch(yy_noeof)
    560560    {
     
    579579        break;
    580580      default:
    581         break;
    582     }
    583     if (err!=NULL)
    584       Werror("premature end of file while reading %s",err);
     581        return 0;
     582    }
     583    Werror("premature end of file while reading %s",err);
    585584    return 0;
    586585  }
  • Singular/grammar.y

    r8d4732 rad4bc9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: grammar.y,v 1.59 1999-04-16 07:53:32 obachman Exp $ */
     4/* $Id: grammar.y,v 1.60 1999-05-06 16:53:23 Singular Exp $ */
    55/*
    66* ABSTRACT: SINGULAR shell grammatik
     
    3939#include "ipshell.h"
    4040#include "ipconv.h"
     41#include "sdb.h"
    4142#include "ideals.h"
    4243#include "numbers.h"
     
    121122  if ((currentVoice!=NULL)
    122123  && (currentVoice->prev!=NULL)
    123   && (myynest>0))
     124  && (myynest>0)
     125  && ((sdb_flags &1)==0))
    124126  {
    125127    Werror("leaving %s",VoiceName());
     
    323325            #endif
    324326            prompt_char = '>';
     327            if (sdb_flags & 2) { sdb_flags=0; YYERROR; }
    325328            if(siCntrlc)
    326329            {
     
    377380            yyerror("");
    378381            yyerrok;
     382            if ((sdb_flags & 1) && currentVoice->pi!=NULL)
     383            {
     384              currentVoice->pi->trace_flag |=1;
     385            }
     386            else
    379387            if (myynest>0)
    380388            {
     
    391399              exitVoice();
    392400            }
     401            if (sdb_flags &2) sdb_flags=1;
    393402          }
    394403        ;
  • Singular/ipid.cc

    r8d4732 rad4bc9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ipid.cc,v 1.31 1999-03-16 15:33:13 Singular Exp $ */
     4/* $Id: ipid.cc,v 1.32 1999-05-06 16:53:24 Singular Exp $ */
    55
    66/*
     
    6565    {
    6666      return h;
    67     } 
     67    }
    6868#endif
    6969// =============================================================
     
    8989    l=IDLEV(h);
    9090    if ((l==0)||(l==lev))
    91     { 
     91    {
    9292      id=IDID(h);
    9393      if (*(short *)s==*(short *)id)
     
    350350    if(t==PACKAGE_CMD) {
    351351      killhdl(h,&NSROOT(namespaceroot->root));
    352     } else 
     352    } else
    353353#endif /* HAVE_NAMESPACES */
    354354    {
     
    416416#ifdef HAVE_NAMESPACES
    417417  // package -------------------------------------------------------------
    418   else if (IDTYP(h) == PACKAGE_CMD) {
    419     if(IDPACKAGE(h)->language!=LANG_TOP) {
     418  else if (IDTYP(h) == PACKAGE_CMD)
     419  {
     420    if(IDPACKAGE(h)->language!=LANG_TOP)
     421    {
    420422      if(!paKill(IDPACKAGE(h))) return;
    421     } else {
    422       if(strcmp(IDID(h), "Top")!=0) {
     423    }
     424    else
     425    {
     426      if(strcmp(IDID(h), "Top")!=0)
     427      {
    423428        if(!paKill(IDPACKAGE(h))) return;
    424429      }
    425       else {
     430      else
     431      {
    426432        if(!paKill(IDPACKAGE(h), TRUE)) return;
    427433      }
     
    857863  ns->name    = mstrdup(name);
    858864  ns->myynest = nesting;
    859  
     865
    860866  //ns->currRing = currRing;
    861867  //ns->currRingHdl = currRingHdl;
     
    915921{
    916922  namehdl nshdl = namespaceroot;
    917      
     923
    918924  for(nshdl=namespaceroot; nshdl->isroot != TRUE; nshdl = nshdl->next) {
    919925    //Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest);
     
    931937  }
    932938  return TRUE;
    933  
    934 }
    935 #endif /* HAVE_NAMESPACES */
     939
     940}
     941#endif /* HAVE_NAMESPACES */
  • Singular/sdb.cc

    r8d4732 rad4bc9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: sdb.cc,v 1.3 1999-04-29 16:57:18 Singular Exp $ */
     4/* $Id: sdb.cc,v 1.4 1999-05-06 16:53:25 Singular Exp $ */
    55/*
    66* ABSTRACT: Singular debugger
    77*/
    88
     9#include <unistd.h>   // for unlink,fork,execlp,getpid
     10#include <sys/wait.h> // for wait
    911#include "mod2.h"
    1012#include "tok.h"
     
    1618
    1719int sdb_lines[]={-1,-1,-1,-1,-1,-1,-1,-1};
     20char * sdb_files[6];
     21int sdb_flags=1;
    1822
    1923int sdb_checkline(char f)
     
    3135}
    3236
     37void sdb_edit(procinfo *pi)
     38{
     39  char * filename = "/tmp/sd000000";
     40  sprintf(filename+7,"%d",getpid());
     41  FILE *fp=fopen(filename,"w");
     42  if (fp==NULL)
     43  {
     44    Print("cannot open %s\n",filename);
     45    return;
     46  }
     47  if (pi->language!= LANG_SINGULAR)
     48  {
     49    Print("cannot edit type %d\n",pi->language);
     50    fclose(fp);
     51    fp=NULL;
     52  }
     53  else
     54  {
     55    char *editor=getenv("EDITOR");
     56    if (editor==NULL)
     57      editor=getenv("VISUAL");
     58    if (editor==NULL)
     59      editor="vi";
     60
     61    if (pi->data.s.body==NULL)
     62    {
     63      iiGetLibProcBuffer(pi);
     64      if (pi->data.s.body==NULL)
     65      {
     66        PrintS("cannot get the procedure body\n");
     67        fclose(fp);
     68        unlink(filename);
     69        return;
     70      }
     71    }
     72
     73    fwrite(pi->data.s.body,1,strlen(pi->data.s.body),fp);
     74    fclose(fp);
     75
     76    int pid=fork();
     77    if (pid!=0)
     78    {
     79      wait(&pid);
     80    }
     81    else if(pid==0)
     82    {
     83      execlp(editor,editor,filename,NULL);
     84      Print("cannot exec %s\n",editor);
     85    }
     86    else
     87    {
     88      PrintS("cannot fork\n");
     89    }
     90
     91    fp=fopen(filename,"r");
     92    if (fp==NULL)
     93    {
     94      Print("cannot read from %s\n",filename);
     95    }
     96    else
     97    {
     98      fseek(fp,0L,SEEK_END);
     99      long len=ftell(fp);
     100      fseek(fp,0L,SEEK_SET);
     101
     102      FreeL((ADDRESS)pi->data.s.body);
     103      pi->data.s.body=(char *)AllocL((int)len+1);
     104      myfread( pi->data.s.body, len, 1, fp);
     105      pi->data.s.body[len]='\0';
     106      fclose(fp);
     107    }
     108  }
     109  unlink(filename);
     110}
     111
     112static char *sdb_find_arg(char *p)
     113{
     114  p++;
     115  while (*p==' ') p++;
     116  char *pp=p;
     117  while (*pp>' ') pp++;
     118  *pp='\0';
     119  return p;
     120}
     121
    33122static char sdb_lastcmd='c';
    34123
    35 void sdb(Voice * currentVoice, char * currLine, int len, char *b)
     124void sdb(Voice * currentVoice, const char * currLine, int len)
    36125{
    37126  int bp=0;
     
    44133    {
    45134      char gdb[80];
    46       char *p=currLine+len-1;
     135      char *p=(char *)currLine+len-1;
    47136      while ((*p<=' ') && (p!=currLine))
    48137      {
     
    52141
    53142      currentVoice->pi->trace_flag&= ~1; // delete flag for "all lines"
    54       fprintf(stdout,"(%s,%d) >>",currentVoice->filename,yylineno);mflush();
     143      Print("(%s,%d) >>",currentVoice->filename,yylineno);
    55144      fwrite(currLine,1,len,stdout);
    56       fprintf(stdout,"<<\nbreakpoint %d (p..,f,b,c,n,q,e..)\n",bp);mflush();
    57       fgets(gdb,80,stdin);
    58       p=gdb;
     145      Print("<<\nbreakpoint %d (press ? for list of commands)\n",bp);
     146      p=fe_fgets_stdin("!",gdb,80);
    59147      while (*p==' ') p++;
    60148      if (*p >' ')
     
    62150        sdb_lastcmd=*p;
    63151      }
    64       printf("command:%c\n",sdb_lastcmd);
     152      Print("command:%c\n",sdb_lastcmd);
    65153      switch(sdb_lastcmd)
    66154      {
     155        case '?':
     156        case 'h':
     157        {
     158          PrintS(
     159          "b - print backtrace of calling stack\n"
     160          "c - continue\n"
     161          "d - delete current breakpoint\n"
     162          "e - edit the current procedure (current call will be aborted)\n"
     163          "h,? - display this help screen\n"
     164          "n - execute current line, break at next line\n"
     165          "p <var> - display type and value of the variable <var>\n"
     166          "q <flags> - quit debugger, set debugger flags(0,1,2)\n"
     167          "Q - quit Singular\n");
     168          int i;
     169          for(i=0;i<7;i++)
     170          {
     171            if (sdb_lines[i] != -1)
     172              Print("breakpoint %d at line %d in %s\n",
     173                i,sdb_lines[i],sdb_files[i]);
     174          }
     175          break;
     176        }
    67177        case 'd':
    68178        {
    69           fprintf(stdout,"delete break point %d\n",bp);
     179          Print("delete break point %d\n",bp);
    70180          currentVoice->pi->trace_flag &= (~Sy_bit(bp));
    71181          if (bp!=0)
     
    73183            sdb_lines[bp-1]=-1;
    74184          }
    75           int f=currentVoice->pi->trace_flag;
    76           fprintf(stdout,"active breakpoints: \n");
    77           int i;
    78           for(i=1;i<=7;i++)
    79           {
    80             f=f>>1;
    81             if (f&1)
    82               fprintf(stdout,"%d:line %d", i,  sdb_lines[i-1]);
    83           }
    84           fprintf(stdout,"\n");
    85185          break;
    86186        }
     
    90190        case 'e':
    91191        {
    92           int i=strlen(b);
    93           while ((i>=0) && (b[i]<=' ')) i--;
    94           if (i<0)
    95           {
    96             fprintf(stdout,"cannot set ~ at empty line\n");
    97             break;
    98           }
    99           if (b[i]!=';')
    100           {
    101             fprintf(stdout,"cannot set ~ at char `%c`\n",b[i]);
    102             break;
    103           }
    104           b[i+1]='~';
    105           b[i+2]=';';
    106           b[i+3]='\n';
    107           b[i+4]='\0';
    108           return;
    109         }
    110 //          sdb_lastcmd='c';
    111 //          if (*(p+1)!=' ')
    112 //          {
    113 //            printf("?? no string to execute\n");
    114 //          }
    115 //          else
    116 //          {
    117 //            p+=2;
    118 //            char *s=(char *)AllocL(strlen(p) + 4);
    119 //            strcpy( s,p);
    120 //            strcat( s,"\n;\n");
    121 //            newBuffer(s,BT_execute);
    122 //          }
    123 //          return;
    124 //        }
     192          sdb_edit(currentVoice->pi);
     193          sdb_flags=2;
     194          return;
     195        }
    125196        case 'p':
    126197        {
    127           p+=2;
    128           char *pp=p+1;
    129           while (*pp>' ') pp++;
    130           *pp='\0';
    131           printf("request `%s`",p);
     198          p=sdb_find_arg(p);
     199          Print("request `%s`",p);
    132200          idhdl h=ggetid(p,TRUE);
    133           if (h==NULL) printf("NULL\n");
     201          if (h==NULL)
     202            PrintS("NULL\n");
    134203          else
    135204          {
     
    138207            tmp.rtyp=IDHDL;
    139208            tmp.data=h;
    140             printf("(type %s):",Tok2Cmdname(tmp.Typ()));
     209            Print("(type %s):",Tok2Cmdname(tmp.Typ()));
    141210            tmp.Print();
    142211          }
     
    147216          break;
    148217        case 'q':
     218        {
     219          p=sdb_find_arg(p);
     220          if (*p!='\0')
     221          {
     222            sdb_flags=atoi(p);
     223            Print("new sdb_flags:%d\n",sdb_flags);
     224          }
     225          return;
     226        }
     227        case 'Q':
    149228          m2_end(999);
    150229        case 'c':
  • Singular/sdb.h

    r8d4732 rad4bc9  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: sdb.h,v 1.3 1999-04-29 16:57:18 Singular Exp $ */
     6/* $Id: sdb.h,v 1.4 1999-05-06 16:53:25 Singular Exp $ */
    77/*
    88* ABSTRACT: Singular debugger
     
    1010
    1111#include "febase.h"
     12#include "structs.h"
    1213
    13 extern int sdb_lines[];
     14extern int    sdb_lines[];
     15extern char * sdb_files[];
     16extern int    sdb_flags;
    1417
    15 void sdb(Voice * currentVoice, char * currLine, int len, char * buffer);
     18void sdb_edit(procinfo *pi);
     19void sdb(Voice * currentVoice, const char * currLine, int len);
    1620#endif
    1721
Note: See TracChangeset for help on using the changeset viewer.