Changeset ad4bc9 in git
- Timestamp:
- May 6, 1999, 6:53:35 PM (25 years ago)
- Branches:
- (u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
- Children:
- c59d88ee06883f262adb708e6846ac13d54018e3
- Parents:
- 8d4732632f41e8c44b6ae3e871af2513fba44823
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
r8d4732 rad4bc9 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.9 0 1999-04-29 11:38:40Singular Exp $ */4 /* $Id: extra.cc,v 1.91 1999-05-06 16:53:21 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 940 940 { 941 941 sdb_lines[i]=lineno; 942 sdb_files[i]=p->libname; 942 943 i++; 943 944 Print("breakpoint %d, at line %d in %s\n",i,lineno,p->procname); … … 948 949 { 949 950 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"); 950 982 return TRUE; 951 983 } -
Singular/febase.inc
r8d4732 rad4bc9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: febase.inc,v 1.2 3 1999-04-29 16:57:12 Singular Exp $ */4 /* $Id: febase.inc,v 1.24 1999-05-06 16:53:22 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: handling of 'voices' … … 430 430 && (currentVoice->pi->trace_flag!=0)) 431 431 { 432 sdb(currentVoice, anf, len_s , b);432 sdb(currentVoice, anf, len_s); 433 433 } 434 434 prompt_char = '.'; … … 447 447 { 448 448 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; 451 452 l--; 452 453 loop 453 454 { 454 char c=455 b[i]=currentVoice->buffer[ currentVoice->fptr];455 register char c= 456 b[i]=currentVoice->buffer[tmp_ptr/*currentVoice->fptr*/]; 456 457 i++; 457 458 if (yy_noeof==noeof_block) … … 469 470 } 470 471 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; 474 476 b[i]='\0'; 475 477 if (currentVoice->sw==BI_buffer) … … 522 524 s=fe_fgets_stdin(fe_promptstr, 523 525 currentVoice->buffer+offset, 524 526 (4096-1-sizeof(ADDRESS))-offset); 525 527 } 526 528 else if (currentVoice->sw==BI_file) … … 530 532 } 531 533 //else /* BI_buffer */ s==NULL => return 0 532 //{ 533 // return 0; 534 //} 534 // done by the default return 535 535 } 536 536 if (s!=NULL) … … 556 556 /* else if (s==NULL) */ 557 557 { 558 char *err =NULL;558 char *err; 559 559 switch(yy_noeof) 560 560 { … … 579 579 break; 580 580 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); 585 584 return 0; 586 585 } -
Singular/grammar.y
r8d4732 rad4bc9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: grammar.y,v 1. 59 1999-04-16 07:53:32 obachmanExp $ */4 /* $Id: grammar.y,v 1.60 1999-05-06 16:53:23 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: SINGULAR shell grammatik … … 39 39 #include "ipshell.h" 40 40 #include "ipconv.h" 41 #include "sdb.h" 41 42 #include "ideals.h" 42 43 #include "numbers.h" … … 121 122 if ((currentVoice!=NULL) 122 123 && (currentVoice->prev!=NULL) 123 && (myynest>0)) 124 && (myynest>0) 125 && ((sdb_flags &1)==0)) 124 126 { 125 127 Werror("leaving %s",VoiceName()); … … 323 325 #endif 324 326 prompt_char = '>'; 327 if (sdb_flags & 2) { sdb_flags=0; YYERROR; } 325 328 if(siCntrlc) 326 329 { … … 377 380 yyerror(""); 378 381 yyerrok; 382 if ((sdb_flags & 1) && currentVoice->pi!=NULL) 383 { 384 currentVoice->pi->trace_flag |=1; 385 } 386 else 379 387 if (myynest>0) 380 388 { … … 391 399 exitVoice(); 392 400 } 401 if (sdb_flags &2) sdb_flags=1; 393 402 } 394 403 ; -
Singular/ipid.cc
r8d4732 rad4bc9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ipid.cc,v 1.3 1 1999-03-16 15:33:13Singular Exp $ */4 /* $Id: ipid.cc,v 1.32 1999-05-06 16:53:24 Singular Exp $ */ 5 5 6 6 /* … … 65 65 { 66 66 return h; 67 } 67 } 68 68 #endif 69 69 // ============================================================= … … 89 89 l=IDLEV(h); 90 90 if ((l==0)||(l==lev)) 91 { 91 { 92 92 id=IDID(h); 93 93 if (*(short *)s==*(short *)id) … … 350 350 if(t==PACKAGE_CMD) { 351 351 killhdl(h,&NSROOT(namespaceroot->root)); 352 } else 352 } else 353 353 #endif /* HAVE_NAMESPACES */ 354 354 { … … 416 416 #ifdef HAVE_NAMESPACES 417 417 // 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 { 420 422 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 { 423 428 if(!paKill(IDPACKAGE(h))) return; 424 429 } 425 else { 430 else 431 { 426 432 if(!paKill(IDPACKAGE(h), TRUE)) return; 427 433 } … … 857 863 ns->name = mstrdup(name); 858 864 ns->myynest = nesting; 859 865 860 866 //ns->currRing = currRing; 861 867 //ns->currRingHdl = currRingHdl; … … 915 921 { 916 922 namehdl nshdl = namespaceroot; 917 923 918 924 for(nshdl=namespaceroot; nshdl->isroot != TRUE; nshdl = nshdl->next) { 919 925 //Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest); … … 931 937 } 932 938 return TRUE; 933 934 } 935 #endif /* HAVE_NAMESPACES */ 939 940 } 941 #endif /* HAVE_NAMESPACES */ -
Singular/sdb.cc
r8d4732 rad4bc9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sdb.cc,v 1. 3 1999-04-29 16:57:18Singular Exp $ */4 /* $Id: sdb.cc,v 1.4 1999-05-06 16:53:25 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: Singular debugger 7 7 */ 8 8 9 #include <unistd.h> // for unlink,fork,execlp,getpid 10 #include <sys/wait.h> // for wait 9 11 #include "mod2.h" 10 12 #include "tok.h" … … 16 18 17 19 int sdb_lines[]={-1,-1,-1,-1,-1,-1,-1,-1}; 20 char * sdb_files[6]; 21 int sdb_flags=1; 18 22 19 23 int sdb_checkline(char f) … … 31 35 } 32 36 37 void 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 112 static 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 33 122 static char sdb_lastcmd='c'; 34 123 35 void sdb(Voice * currentVoice, c har * currLine, int len, char *b)124 void sdb(Voice * currentVoice, const char * currLine, int len) 36 125 { 37 126 int bp=0; … … 44 133 { 45 134 char gdb[80]; 46 char *p= currLine+len-1;135 char *p=(char *)currLine+len-1; 47 136 while ((*p<=' ') && (p!=currLine)) 48 137 { … … 52 141 53 142 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); 55 144 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); 59 147 while (*p==' ') p++; 60 148 if (*p >' ') … … 62 150 sdb_lastcmd=*p; 63 151 } 64 printf("command:%c\n",sdb_lastcmd);152 Print("command:%c\n",sdb_lastcmd); 65 153 switch(sdb_lastcmd) 66 154 { 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 } 67 177 case 'd': 68 178 { 69 fprintf(stdout,"delete break point %d\n",bp);179 Print("delete break point %d\n",bp); 70 180 currentVoice->pi->trace_flag &= (~Sy_bit(bp)); 71 181 if (bp!=0) … … 73 183 sdb_lines[bp-1]=-1; 74 184 } 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");85 185 break; 86 186 } … … 90 190 case 'e': 91 191 { 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 } 125 196 case 'p': 126 197 { 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); 132 200 idhdl h=ggetid(p,TRUE); 133 if (h==NULL) printf("NULL\n"); 201 if (h==NULL) 202 PrintS("NULL\n"); 134 203 else 135 204 { … … 138 207 tmp.rtyp=IDHDL; 139 208 tmp.data=h; 140 printf("(type %s):",Tok2Cmdname(tmp.Typ()));209 Print("(type %s):",Tok2Cmdname(tmp.Typ())); 141 210 tmp.Print(); 142 211 } … … 147 216 break; 148 217 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': 149 228 m2_end(999); 150 229 case 'c': -
Singular/sdb.h
r8d4732 rad4bc9 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: sdb.h,v 1. 3 1999-04-29 16:57:18Singular Exp $ */6 /* $Id: sdb.h,v 1.4 1999-05-06 16:53:25 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT: Singular debugger … … 10 10 11 11 #include "febase.h" 12 #include "structs.h" 12 13 13 extern int sdb_lines[]; 14 extern int sdb_lines[]; 15 extern char * sdb_files[]; 16 extern int sdb_flags; 14 17 15 void sdb(Voice * currentVoice, char * currLine, int len, char * buffer); 18 void sdb_edit(procinfo *pi); 19 void sdb(Voice * currentVoice, const char * currLine, int len); 16 20 #endif 17 21
Note: See TracChangeset
for help on using the changeset viewer.