version 1.16, 2006/02/08 02:11:19 |
version 1.25, 2018/03/29 01:32:54 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/debug.c,v 1.15 2003/05/14 07:08:48 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/debug.c,v 1.24 2015/08/14 13:51:56 fujimoto Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include <ctype.h> |
#include <ctype.h> |
#if defined(PARI) |
|
#include "genpari.h" |
|
#endif |
|
|
|
extern do_server_in_X11,do_file; |
extern do_server_in_X11,do_file; |
|
|
typedef enum { |
typedef enum { |
D_NEXT, D_STEP, D_FINISH, D_CONT, D_QUIT, |
D_NEXT, D_STEP, D_FINISH, D_CONT, D_QUIT, |
D_UP, D_DOWN, D_FRAME, |
D_UP, D_DOWN, D_FRAME, |
D_LIST, D_PRINT, |
D_LIST, D_PRINT, |
D_SETF, D_SETBP, D_SETTP, D_DELBP, |
D_SETF, D_SETBP, D_SETTP, D_DELBP, |
D_SHOWBP, D_WHERE, D_ALIAS, D_UNKNOWN |
D_SHOWBP, D_WHERE, D_ALIAS, D_UNKNOWN |
} did; |
} did; |
|
|
struct oDEBCOM { |
struct oDEBCOM { |
NODE names; |
NODE names; |
did id; |
did id; |
}; |
}; |
|
|
int nextbp,nextbplevel; |
int nextbp,nextbplevel; |
Line 81 extern int debug_mode; |
|
Line 78 extern int debug_mode; |
|
extern JMP_BUF debug_env; |
extern JMP_BUF debug_env; |
|
|
char *debcom[] = { |
char *debcom[] = { |
"next", |
"next", |
"step", |
"step", |
"finish", |
"finish", |
"cont", |
"cont", |
"quit", |
"quit", |
"up", |
"up", |
"down", |
"down", |
"frame", |
"frame", |
"list", |
"list", |
"print", |
"print", |
"func", |
"func", |
"stop", |
"stop", |
"trace", |
"trace", |
"delete", |
"delete", |
"status", |
"status", |
"where", |
"where", |
"alias", |
"alias", |
}; |
}; |
|
|
struct oDEBCOM dckwd[] = { |
struct oDEBCOM dckwd[] = { |
{0, D_NEXT}, |
{0, D_NEXT}, |
{0, D_STEP}, |
{0, D_STEP}, |
{0, D_FINISH}, |
{0, D_FINISH}, |
{0, D_CONT}, |
{0, D_CONT}, |
{0, D_QUIT}, |
{0, D_QUIT}, |
{0, D_UP}, |
{0, D_UP}, |
{0, D_DOWN}, |
{0, D_DOWN}, |
{0, D_FRAME}, |
{0, D_FRAME}, |
{0, D_LIST}, |
{0, D_LIST}, |
{0, D_PRINT}, |
{0, D_PRINT}, |
{0, D_SETF}, |
{0, D_SETF}, |
{0, D_SETBP}, |
{0, D_SETBP}, |
{0, D_SETTP}, |
{0, D_SETTP}, |
{0, D_DELBP}, |
{0, D_DELBP}, |
{0, D_SHOWBP}, |
{0, D_SHOWBP}, |
{0, D_WHERE}, |
{0, D_WHERE}, |
{0, D_ALIAS}, |
{0, D_ALIAS}, |
{0, D_UNKNOWN} |
{0, D_UNKNOWN} |
}; |
}; |
|
|
void debug_init() { |
void debug_init() { |
int i,n,ac; |
int i,n,ac; |
char *home; |
char *home; |
char buf[BUFSIZ+1]; |
char buf[BUFSIZ+1]; |
#if defined(__MWERKS__) |
#if defined(__MWERKS__) |
char *av[64]; |
char *av[64]; |
#else |
#else |
char *av[BUFSIZ]; |
char *av[BUFSIZ]; |
#endif |
#endif |
FILE *fp; |
FILE *fp; |
|
|
for ( n = 0; dckwd[n].id != D_UNKNOWN; n++ ); |
for ( n = 0; dckwd[n].id != D_UNKNOWN; n++ ); |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
MKNODE(dckwd[i].names,debcom[i],0); |
MKNODE(dckwd[i].names,debcom[i],0); |
home = (char *)getenv("HOME"); |
home = (char *)getenv("HOME"); |
if ( home ) |
if ( home ) |
strcpy(buf,home); |
strcpy(buf,home); |
else |
else |
buf[0] = 0; |
buf[0] = 0; |
strcat(buf,"/.dbxinit"); |
strcat(buf,"/.dbxinit"); |
if ( (fp = fopen(".dbxinit","r")) || (fp = fopen(buf,"r")) ) { |
if ( (fp = fopen(".dbxinit","r")) || (fp = fopen(buf,"r")) ) { |
while ( fgets(buf,BUFSIZ,fp) ) { |
while ( fgets(buf,BUFSIZ,fp) ) { |
stoarg(buf,&ac,av); |
stoarg(buf,&ac,av); |
if ((ac == 3) && !strcmp(av[0],"alias")) |
if ((ac == 3) && !strcmp(av[0],"alias")) |
add_alias(av[2],av[1]); |
add_alias(av[2],av[1]); |
} |
} |
fclose(fp); |
fclose(fp); |
} |
} |
#if 0 |
#if 0 |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 ) |
if ( do_server_in_X11 ) |
init_cmdwin(); |
init_cmdwin(); |
#endif |
#endif |
#endif |
#endif |
} |
} |
|
|
void add_alias(char *com,char *alias) |
void add_alias(char *com,char *alias) |
{ |
{ |
int i; |
int i; |
NODE tn; |
NODE tn; |
char *s; |
char *s; |
|
|
for ( i = 0; dckwd[i].names; i++ ) |
for ( i = 0; dckwd[i].names; i++ ) |
if (!strcmp(com,debcom[i])) { |
if (!strcmp(com,debcom[i])) { |
for ( tn = dckwd[i].names; NEXT(tn); tn = NEXT(tn) ); |
for ( tn = dckwd[i].names; NEXT(tn); tn = NEXT(tn) ); |
s = (char *)MALLOC(strlen(alias)+1); strcpy(s,alias); |
s = (char *)MALLOC(strlen(alias)+1); strcpy(s,alias); |
MKNODE(NEXT(tn),s,0); |
MKNODE(NEXT(tn),s,0); |
return; |
return; |
} |
} |
} |
} |
|
|
void show_alias(char *alias) |
void show_alias(char *alias) |
{ |
{ |
int i; |
int i; |
NODE tn; |
NODE tn; |
|
|
if ( !alias ) |
if ( !alias ) |
for ( i = 0; dckwd[i].names; i++ ) { |
for ( i = 0; dckwd[i].names; i++ ) { |
if ( tn = NEXT(dckwd[i].names) ) |
if ( tn = NEXT(dckwd[i].names) ) |
fprintf(stderr,"%s\t",debcom[i]); |
fprintf(stderr,"%s\t",debcom[i]); |
for ( ; tn; tn = NEXT(tn) ) { |
for ( ; tn; tn = NEXT(tn) ) { |
fputs(BDY(tn),stderr); |
fputs(BDY(tn),stderr); |
if ( NEXT(tn) ) |
if ( NEXT(tn) ) |
fputc(' ',stderr); |
fputc(' ',stderr); |
else |
else |
fputc('\n',stderr); |
fputc('\n',stderr); |
} |
} |
} |
} |
else |
else |
for ( i = 0; dckwd[i].names; i++ ) |
for ( i = 0; dckwd[i].names; i++ ) |
for ( tn = dckwd[i].names; tn; tn = NEXT(tn) ) |
for ( tn = dckwd[i].names; tn; tn = NEXT(tn) ) |
if ( !strcmp(alias,BDY(tn)) ) { |
if ( !strcmp(alias,BDY(tn)) ) { |
fprintf(stderr,"%s->%s\n",alias,debcom[i]); return; |
fprintf(stderr,"%s->%s\n",alias,debcom[i]); return; |
} |
} |
} |
} |
|
|
void debug(SNODE f) |
void debug(SNODE f) |
{ |
{ |
int ac,i,n; |
int ac,i,n; |
did id; |
did id; |
#if defined(__MWERKS__) |
#if defined(__MWERKS__) |
char *av[64]; |
char *av[64]; |
#else |
#else |
char *av[BUFSIZ]; |
char *av[BUFSIZ]; |
#endif |
#endif |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
char prompt[BUFSIZ]; |
char prompt[BUFSIZ]; |
char *p,*pe; |
char *p,*pe; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
char *line; |
char *line; |
#endif |
#endif |
NODE tn; |
NODE tn; |
extern int do_fep; |
extern int do_fep; |
NODE pvss; |
NODE pvss; |
|
|
#if !defined(MPI) && !defined(VISUAL) |
#if !defined(MPI) && !defined(VISUAL) && !defined(__MINGW32__) |
if ( !isatty(fileno(stdin)) && !do_server_in_X11 ) |
if ( !isatty(fileno(stdin)) && !do_server_in_X11 ) |
if ( do_file ) |
if ( do_file ) |
ExitAsir(); |
ExitAsir(); |
else |
else |
return; |
return; |
#endif |
#endif |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
suspend_timer(); |
suspend_timer(); |
#endif |
#endif |
pvss = PVSS; debug_mode = 1; |
pvss = PVSS; debug_mode = 1; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 ) |
if ( do_server_in_X11 ) |
#endif |
#endif |
show_debug_window(1); |
show_debug_window(1); |
sprintf(prompt,"(debug) "); |
sprintf(prompt,"(debug) "); |
SETJMP(debug_env); |
SETJMP(debug_env); |
while ( 1 ) { |
while ( 1 ) { |
#if FEP |
#if FEP |
if ( !do_fep ) |
if ( !do_fep ) |
#endif |
#endif |
if ( !do_server_in_X11 ) |
if ( !do_server_in_X11 ) |
fputs(prompt,stderr); |
fputs(prompt,stderr); |
bzero(buf,BUFSIZ); |
bzero(buf,BUFSIZ); |
while ( 1 ) { |
while ( 1 ) { |
#if FEP |
#if FEP |
if ( do_fep ) { |
if ( do_fep ) { |
line = (char *)readline_console(prompt); |
line = (char *)readline_console(prompt); |
strcpy(buf,line); free(line); |
strcpy(buf,line); free(line); |
} else |
} else |
#endif |
#endif |
{ |
{ |
int len; |
int len; |
|
|
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 ) |
if ( do_server_in_X11 ) |
get_line(buf); |
get_line(buf); |
else |
else |
#endif |
#endif |
if ( !fgets(buf,BUFSIZ,stdin) ) |
if ( !fgets(buf,BUFSIZ,stdin) ) |
goto LAST; |
goto LAST; |
len = strlen(buf); |
len = strlen(buf); |
if ( buf[len-1] == '\n' ) |
if ( buf[len-1] == '\n' ) |
buf[len-1] = 0; |
buf[len-1] = 0; |
} |
} |
for ( p = buf; *p && isspace(*p); p++ ); |
for ( p = buf; *p && isspace(*p); p++ ); |
if ( *p ) |
if ( *p ) |
break; |
break; |
} |
} |
for ( pe = p; *pe && !isspace(*pe); pe++ ); |
for ( pe = p; *pe && !isspace(*pe); pe++ ); |
*pe = 0; |
*pe = 0; |
for ( i = 0; dckwd[i].names; i++ ) { |
for ( i = 0; dckwd[i].names; i++ ) { |
for ( tn = dckwd[i].names; tn; tn = NEXT(tn) ) |
for ( tn = dckwd[i].names; tn; tn = NEXT(tn) ) |
if ( !strcmp(BDY(tn),p) ) |
if ( !strcmp(BDY(tn),p) ) |
break; |
break; |
if ( tn ) |
if ( tn ) |
break; |
break; |
} |
} |
id = dckwd[i].id; p = pe+1; |
id = dckwd[i].id; p = pe+1; |
switch ( id ) { |
switch ( id ) { |
case D_NEXT: |
case D_NEXT: |
if ( f ) { nextbp = 1; nextbplevel = 0; } |
if ( f ) { nextbp = 1; nextbplevel = 0; } |
goto LAST; break; |
goto LAST; break; |
case D_STEP: |
case D_STEP: |
if ( f ) { nextbp = 1; nextbplevel = -1; } |
if ( f ) { nextbp = 1; nextbplevel = -1; } |
goto LAST; break; |
goto LAST; break; |
case D_FINISH: |
case D_FINISH: |
if ( f ) { nextbp = 1; nextbplevel = 1; } |
if ( f ) { nextbp = 1; nextbplevel = 1; } |
goto LAST; break; |
goto LAST; break; |
case D_CONT: case D_QUIT: |
case D_CONT: case D_QUIT: |
goto LAST; break; |
goto LAST; break; |
case D_UP: |
case D_UP: |
if ( f ) { |
if ( f ) { |
stoarg(p,&ac,av); n = ac ? atoi(av[0]) : 1; |
stoarg(p,&ac,av); n = ac ? atoi(av[0]) : 1; |
change_stack(n,&pvss); |
change_stack(n,&pvss); |
} |
} |
break; |
break; |
case D_DOWN: |
case D_DOWN: |
if ( f ) { |
if ( f ) { |
stoarg(p,&ac,av); n = ac ? atoi(av[0]) : 1; |
stoarg(p,&ac,av); n = ac ? atoi(av[0]) : 1; |
change_stack(-n,&pvss); |
change_stack(-n,&pvss); |
} |
} |
break; |
break; |
case D_FRAME: |
case D_FRAME: |
if ( f ) { |
if ( f ) { |
stoarg(p,&ac,av); |
stoarg(p,&ac,av); |
if ( !ac ) |
if ( !ac ) |
show_stack((VS)BDY(pvss)); |
show_stack((VS)BDY(pvss)); |
else { |
else { |
n = atoi(av[0]); |
n = atoi(av[0]); |
change_stack(((VS)BDY(pvss))->level-((VS)BDY(PVSS))->level+n,&pvss); |
change_stack(((VS)BDY(pvss))->level-((VS)BDY(PVSS))->level+n,&pvss); |
} |
} |
} |
} |
break; |
break; |
case D_PRINT: |
case D_PRINT: |
printvars(p,pvss?(VS)BDY(pvss):GPVS); break; |
printvars(p,pvss?(VS)BDY(pvss):GPVS); break; |
case D_LIST: |
case D_LIST: |
stoarg(p,&ac,av); println(ac,av,10); break; |
stoarg(p,&ac,av); println(ac,av,10); break; |
case D_SETF: |
case D_SETF: |
stoarg(p,&ac,av); setf(ac,av); break; |
stoarg(p,&ac,av); setf(ac,av); break; |
case D_SETBP: |
case D_SETBP: |
setbp(p); break; |
setbp(p); break; |
case D_SETTP: |
case D_SETTP: |
settp(p); break; |
settp(p); break; |
case D_DELBP: |
case D_DELBP: |
stoarg(p,&ac,av); delbp(ac,av); break; |
stoarg(p,&ac,av); delbp(ac,av); break; |
case D_SHOWBP: |
case D_SHOWBP: |
showbps(); break; |
showbps(); break; |
case D_WHERE: |
case D_WHERE: |
showpos(); break; |
showpos(); break; |
case D_ALIAS: |
case D_ALIAS: |
stoarg(p,&ac,av); |
stoarg(p,&ac,av); |
switch ( ac ) { |
switch ( ac ) { |
case 0: |
case 0: |
show_alias(0); break; |
show_alias(0); break; |
case 1: |
case 1: |
show_alias(av[0]); break; |
show_alias(av[0]); break; |
case 2: default: |
case 2: default: |
add_alias(av[1],av[0]); break; |
add_alias(av[1],av[0]); break; |
} |
} |
break; |
break; |
default: |
default: |
break; |
break; |
} |
} |
} |
} |
LAST: |
LAST: |
debug_mode = 0; |
debug_mode = 0; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 ) |
if ( do_server_in_X11 ) |
#endif |
#endif |
show_debug_window(0); |
show_debug_window(0); |
} |
} |
|
|
void setf(int ac,char **av) |
void setf(int ac,char **av) |
{ |
{ |
FUNC r; |
FUNC r; |
|
|
if ( !ac ) |
if ( !ac ) |
return; |
return; |
searchuf(av[0],&r); |
searchuf(av[0],&r); |
if ( r ) { |
if ( r ) { |
targetf = r; |
targetf = r; |
curline = targetf->f.usrf->startl; |
curline = targetf->f.usrf->startl; |
} |
} |
} |
} |
|
|
#define MAXBP 64 |
#define MAXBP 64 |
|
|
static struct { |
static struct { |
int at; |
int at; |
FUNC f; |
FUNC f; |
SNODE *snp; |
SNODE *snp; |
char *texpr; |
char *texpr; |
char *cond; |
char *cond; |
} bpt[MAXBP]; |
} bpt[MAXBP]; |
|
|
static int bpindex = 0; |
static int bpindex = 0; |
|
|
void setbp(char *p) |
void setbp(char *p) |
{ |
{ |
int ac; |
int ac; |
char *av[BUFSIZ]; |
char *av[BUFSIZ]; |
char *buf,*savp; |
char *buf,*savp; |
char *fname; |
char *fname; |
FUNC r; |
FUNC r; |
USRF uf,t; |
USRF uf,t; |
SNODE *snp = 0; |
SNODE *snp = 0; |
FNODE cond; |
FNODE cond; |
NODE tn; |
NODE tn; |
int n,at,ln,bpi; |
int n,at,ln,bpi; |
|
|
buf = (char *)ALLOCA(strlen(p)+1); strcpy(buf,p); stoarg(buf,&ac,av); |
buf = (char *)ALLOCA(strlen(p)+1); strcpy(buf,p); stoarg(buf,&ac,av); |
if ( ac < 2 ) |
if ( ac < 2 ) |
return; |
return; |
if ( !strcmp(av[0],"at") ) { |
if ( !strcmp(av[0],"at") ) { |
if ( !targetf ) |
if ( !targetf ) |
return; |
return; |
n = atoi(av[1]); |
n = atoi(av[1]); |
uf = targetf->f.usrf; |
uf = targetf->f.usrf; |
fname = uf->fname; |
fname = uf->fname; |
tn = uf->module?uf->module->usrf_list:usrf; |
tn = uf->module?uf->module->usrf_list:usrf; |
for ( ; tn; tn = NEXT(tn) ) { |
for ( ; tn; tn = NEXT(tn) ) { |
r = (FUNC)BDY(tn); t = r->f.usrf; |
r = (FUNC)BDY(tn); t = r->f.usrf; |
if ( t && t->fname && !strcmp(t->fname,fname) |
if ( t && t->fname && !strcmp(t->fname,fname) |
&& ( t->startl <= n ) && ( n <= t->endl ) ) |
&& ( t->startl <= n ) && ( n <= t->endl ) ) |
break; |
break; |
} |
} |
if ( !r ) { |
if ( !r ) { |
fprintf(stderr,"no such line in %s\n",fname); |
fprintf(stderr,"no such line in %s\n",fname); |
return; |
return; |
} else { |
} else { |
targetf = r; curline = n; |
targetf = r; curline = n; |
} |
} |
at = 1; searchsn(&BDY(t),n,&snp); |
at = 1; searchsn(&BDY(t),n,&snp); |
} else if ( !strcmp(av[0],"in") ) { |
} else if ( !strcmp(av[0],"in") ) { |
searchuf(av[1],&r); |
searchuf(av[1],&r); |
if ( !r ) { |
if ( !r ) { |
fprintf(stderr,"%s() : no such function\n",av[1]); |
fprintf(stderr,"%s() : no such function\n",av[1]); |
return; |
return; |
} else if ( r->id == A_UNDEF ) { |
} else if ( r->id == A_UNDEF ) { |
fprintf(stderr,"%s : undefined\n",av[1]); |
fprintf(stderr,"%s : undefined\n",av[1]); |
return; |
return; |
} |
} |
for ( tn = (NODE)FA0(BDY(r->f.usrf)); tn && !BDY(tn); tn = NEXT(tn) ); |
for ( tn = (NODE)FA0(BDY(r->f.usrf)); tn && !BDY(tn); tn = NEXT(tn) ); |
if ( tn ) { |
if ( tn ) { |
snp = (SNODE *)&(BDY(tn)); at = 0; targetf = r; curline = (*snp)->ln; |
snp = (SNODE *)&(BDY(tn)); at = 0; targetf = r; curline = (*snp)->ln; |
} |
} |
} else |
} else |
return; |
return; |
if ( snp ) { |
if ( snp ) { |
cond = 0; |
cond = 0; |
if ( ac >= 3 && !strncmp(av[2],"if",2) ) { |
if ( ac >= 3 && !strncmp(av[2],"if",2) ) { |
savp = p+(av[2]-buf)+2; |
savp = p+(av[2]-buf)+2; |
exprparse(targetf,savp,&cond); |
exprparse(targetf,savp,&cond); |
} |
} |
bpi = searchbp(); |
bpi = searchbp(); |
if ( bpi < 0 ) |
if ( bpi < 0 ) |
fprintf(stderr,"too many breakpoints\n"); |
fprintf(stderr,"too many breakpoints\n"); |
else if ( ID(*snp) == S_BP ) |
else if ( ID(*snp) == S_BP ) |
return; |
return; |
else { |
else { |
switch ( ID(*snp) ) { |
switch ( ID(*snp) ) { |
case S_IFELSE: case S_FOR: case S_DO: |
case S_IFELSE: case S_FOR: case S_DO: |
ln = (int)FA0(*snp); break; |
ln = (int)FA0(*snp); break; |
default: |
default: |
ln = (*snp)->ln; break; |
ln = (*snp)->ln; break; |
} |
} |
*snp = (SNODE)mksnode(3,S_BP,*snp,cond,0); |
*snp = (SNODE)mksnode(3,S_BP,*snp,cond,NULLP); |
(*snp)->ln = ln; |
(*snp)->ln = ln; |
if ( cond ) { |
if ( cond ) { |
bpt[bpi].cond = (char *)MALLOC(strlen(savp)+1); |
bpt[bpi].cond = (char *)MALLOC(strlen(savp)+1); |
strcpy(bpt[bpi].cond,savp); |
strcpy(bpt[bpi].cond,savp); |
} else |
} else |
bpt[bpi].cond = 0; |
bpt[bpi].cond = 0; |
bpt[bpi].at = at; |
bpt[bpi].at = at; |
bpt[bpi].f = targetf; |
bpt[bpi].f = targetf; |
bpt[bpi].snp = snp; |
bpt[bpi].snp = snp; |
bpt[bpi].texpr = 0; |
bpt[bpi].texpr = 0; |
showbp(bpi); |
showbp(bpi); |
} |
} |
} |
} |
} |
} |
|
|
void settp(char *p) |
void settp(char *p) |
{ |
{ |
int ac; |
int ac; |
char *_av[BUFSIZ]; |
char *_av[BUFSIZ]; |
char **av; |
char **av; |
char *buf,*savp; |
char *buf,*savp; |
char *fname; |
char *fname; |
char *texprname; |
char *texprname; |
FUNC r; |
FUNC r; |
USRF t; |
USRF t; |
SNODE *snp = 0; |
SNODE *snp = 0; |
FNODE cond,texpr; |
FNODE cond,texpr; |
NODE tn; |
NODE tn; |
int n,at,ln,bpi; |
int n,at,ln,bpi; |
|
|
av = _av; |
av = _av; |
buf = (char *)ALLOCA(strlen(p)+1); strcpy(buf,p); stoarg(buf,&ac,av); |
buf = (char *)ALLOCA(strlen(p)+1); strcpy(buf,p); stoarg(buf,&ac,av); |
if ( ac < 3 ) |
if ( ac < 3 ) |
return; |
return; |
texprname = av[0]; ac--; av++; |
texprname = av[0]; ac--; av++; |
if ( !strcmp(av[0],"at") ) { |
if ( !strcmp(av[0],"at") ) { |
if ( !targetf ) |
if ( !targetf ) |
return; |
return; |
n = atoi(av[1]); fname = targetf->f.usrf->fname; |
n = atoi(av[1]); fname = targetf->f.usrf->fname; |
for ( tn = usrf; tn; tn = NEXT(tn) ) { |
for ( tn = usrf; tn; tn = NEXT(tn) ) { |
r = (FUNC)BDY(tn); t = r->f.usrf; |
r = (FUNC)BDY(tn); t = r->f.usrf; |
if ( t && t->fname && !strcmp(t->fname,fname) |
if ( t && t->fname && !strcmp(t->fname,fname) |
&& ( t->startl <= n ) && ( n <= t->endl ) ) |
&& ( t->startl <= n ) && ( n <= t->endl ) ) |
break; |
break; |
} |
} |
if ( !r ) { |
if ( !r ) { |
fprintf(stderr,"no such line in %s\n",fname); |
fprintf(stderr,"no such line in %s\n",fname); |
return; |
return; |
} else { |
} else { |
targetf = r; curline = n; |
targetf = r; curline = n; |
} |
} |
at = 1; searchsn(&BDY(t),n,&snp); |
at = 1; searchsn(&BDY(t),n,&snp); |
} else if ( !strcmp(av[0],"in") ) { |
} else if ( !strcmp(av[0],"in") ) { |
searchuf(av[1],&r); |
searchuf(av[1],&r); |
if ( !r ) { |
if ( !r ) { |
fprintf(stderr,"%s() : no such function\n",av[1]); |
fprintf(stderr,"%s() : no such function\n",av[1]); |
return; |
return; |
} |
} |
for ( tn = (NODE)FA0(BDY(r->f.usrf)); tn && !BDY(tn); tn = NEXT(tn) ); |
for ( tn = (NODE)FA0(BDY(r->f.usrf)); tn && !BDY(tn); tn = NEXT(tn) ); |
if ( tn ) { |
if ( tn ) { |
snp = (SNODE *)&(BDY(tn)); at = 0; targetf = r; curline = (*snp)->ln; |
snp = (SNODE *)&(BDY(tn)); at = 0; targetf = r; curline = (*snp)->ln; |
} |
} |
} else |
} else |
return; |
return; |
if ( snp ) { |
if ( snp ) { |
cond = 0; |
cond = 0; |
exprparse(targetf,texprname,&texpr); |
exprparse(targetf,texprname,&texpr); |
if ( ac >= 3 && !strncmp(av[2],"if",2) ) { |
if ( ac >= 3 && !strncmp(av[2],"if",2) ) { |
savp = p+(av[2]-buf)+2; |
savp = p+(av[2]-buf)+2; |
exprparse(targetf,savp,&cond); |
exprparse(targetf,savp,&cond); |
} |
} |
bpi = searchbp(); |
bpi = searchbp(); |
if ( bpi < 0 ) |
if ( bpi < 0 ) |
fprintf(stderr,"too many breakpoints\n"); |
fprintf(stderr,"too many breakpoints\n"); |
else if ( ID(*snp) == S_BP ) |
else if ( ID(*snp) == S_BP ) |
return; |
return; |
else { |
else { |
switch ( ID(*snp) ) { |
switch ( ID(*snp) ) { |
case S_IFELSE: case S_FOR: case S_DO: |
case S_IFELSE: case S_FOR: case S_DO: |
ln = (int)FA0(*snp); break; |
ln = (int)FA0(*snp); break; |
default: |
default: |
ln = (*snp)->ln; break; |
ln = (*snp)->ln; break; |
} |
} |
*snp = (SNODE)mksnode(3,S_BP,*snp,cond,texpr); |
*snp = (SNODE)mksnode(3,S_BP,*snp,cond,texpr); |
(*snp)->ln = ln; |
(*snp)->ln = ln; |
if ( cond ) { |
if ( cond ) { |
bpt[bpi].cond = (char *)MALLOC(strlen(savp)+1); |
bpt[bpi].cond = (char *)MALLOC(strlen(savp)+1); |
strcpy(bpt[bpi].cond,savp); |
strcpy(bpt[bpi].cond,savp); |
} else |
} else |
bpt[bpi].cond = 0; |
bpt[bpi].cond = 0; |
bpt[bpi].at = at; |
bpt[bpi].at = at; |
bpt[bpi].f = targetf; |
bpt[bpi].f = targetf; |
bpt[bpi].snp = snp; |
bpt[bpi].snp = snp; |
bpt[bpi].texpr = (char *)MALLOC(strlen(texprname)+1); |
bpt[bpi].texpr = (char *)MALLOC(strlen(texprname)+1); |
strcpy(bpt[bpi].texpr,texprname); |
strcpy(bpt[bpi].texpr,texprname); |
showbp(bpi); |
showbp(bpi); |
} |
} |
} |
} |
} |
} |
|
|
void clearbp(FUNC f) |
void clearbp(FUNC f) |
{ |
{ |
int i; |
int i; |
|
|
if ( !f ) |
if ( !f ) |
return; |
return; |
for ( i = 0; i < bpindex; i++ ) |
for ( i = 0; i < bpindex; i++ ) |
if ( bpt[i].snp && !strcmp(f->name,bpt[i].f->name) ) { |
if ( bpt[i].snp && !strcmp(f->name,bpt[i].f->name) ) { |
bpt[i].at = 0; bpt[i].f = 0; bpt[i].snp = 0; |
bpt[i].at = 0; bpt[i].f = 0; bpt[i].snp = 0; |
} |
} |
} |
} |
|
|
int searchbp() |
int searchbp() |
{ |
{ |
int i; |
int i; |
|
|
for ( i = 0; i < bpindex; i++ ) |
for ( i = 0; i < bpindex; i++ ) |
if ( !bpt[i].snp ) |
if ( !bpt[i].snp ) |
return i; |
return i; |
if ( bpindex == MAXBP ) |
if ( bpindex == MAXBP ) |
return -1; |
return -1; |
else |
else |
return bpindex++; |
return bpindex++; |
} |
} |
|
|
void delbp(int ac,char **av) |
void delbp(int ac,char **av) |
{ |
{ |
int n; |
int n; |
|
|
if ( !ac ) |
if ( !ac ) |
return; |
return; |
if ( (n = atoi(av[0])) >= bpindex ) |
if ( (n = atoi(av[0])) >= bpindex ) |
return; |
return; |
if ( bpt[n].snp ) { |
if ( bpt[n].snp ) { |
*bpt[n].snp = (SNODE)FA0(*bpt[n].snp); |
*bpt[n].snp = (SNODE)FA0(*bpt[n].snp); |
bpt[n].snp = 0; |
bpt[n].snp = 0; |
} |
} |
} |
} |
|
|
void showbps() { |
void showbps() { |
int i; |
int i; |
|
|
for ( i = 0; i < bpindex; i++ ) |
for ( i = 0; i < bpindex; i++ ) |
showbp(i); |
showbp(i); |
} |
} |
|
|
void showbp(int n) |
void showbp(int n) |
{ |
{ |
if ( bpt[n].snp ) |
if ( bpt[n].snp ) |
if ( bpt[n].texpr ) |
if ( bpt[n].texpr ) |
if ( bpt[n].at ) { |
if ( bpt[n].at ) { |
if ( bpt[n].cond ) |
if ( bpt[n].cond ) |
fprintf(stderr,"(%d) trace %s at \"%s\":%d if %s\n", |
fprintf(stderr,"(%d) trace %s at \"%s\":%d if %s\n", |
n,bpt[n].texpr,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln,bpt[n].cond); |
n,bpt[n].texpr,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln,bpt[n].cond); |
else |
else |
fprintf(stderr,"(%d) trace %s at \"%s\":%d\n", |
fprintf(stderr,"(%d) trace %s at \"%s\":%d\n", |
n,bpt[n].texpr,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln); |
n,bpt[n].texpr,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln); |
} else { |
} else { |
if ( bpt[n].cond ) |
if ( bpt[n].cond ) |
fprintf(stderr,"(%d) trace %s in %s if %s\n", |
fprintf(stderr,"(%d) trace %s in %s if %s\n", |
n,bpt[n].texpr,bpt[n].f->name,bpt[n].cond); |
n,bpt[n].texpr,bpt[n].f->name,bpt[n].cond); |
else |
else |
fprintf(stderr,"(%d) trace %s in %s\n",n,bpt[n].texpr,bpt[n].f->name); |
fprintf(stderr,"(%d) trace %s in %s\n",n,bpt[n].texpr,bpt[n].f->name); |
} |
} |
else |
else |
if ( bpt[n].at ) { |
if ( bpt[n].at ) { |
if ( bpt[n].cond ) |
if ( bpt[n].cond ) |
fprintf(stderr,"(%d) stop at \"%s\":%d if %s\n", |
fprintf(stderr,"(%d) stop at \"%s\":%d if %s\n", |
n,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln,bpt[n].cond); |
n,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln,bpt[n].cond); |
else |
else |
fprintf(stderr,"(%d) stop at \"%s\":%d\n", |
fprintf(stderr,"(%d) stop at \"%s\":%d\n", |
n,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln); |
n,bpt[n].f->f.usrf->fname,(*bpt[n].snp)->ln); |
} else { |
} else { |
if ( bpt[n].cond ) |
if ( bpt[n].cond ) |
fprintf(stderr,"(%d) stop in %s if %s\n", |
fprintf(stderr,"(%d) stop in %s if %s\n", |
n,bpt[n].f->name,bpt[n].cond); |
n,bpt[n].f->name,bpt[n].cond); |
else |
else |
fprintf(stderr,"(%d) stop in %s\n",n,bpt[n].f->name); |
fprintf(stderr,"(%d) stop in %s\n",n,bpt[n].f->name); |
} |
} |
} |
} |
|
|
void searchsn(SNODE *fp,int n,SNODE **fpp) |
void searchsn(SNODE *fp,int n,SNODE **fpp) |
{ |
{ |
NODE tn; |
NODE tn; |
SNODE sn; |
SNODE sn; |
SNODE *snp; |
SNODE *snp; |
|
|
*fpp = 0; |
*fpp = 0; |
switch (ID(*fp)) { |
switch (ID(*fp)) { |
case S_CPLX: |
case S_CPLX: |
for ( tn = (NODE)FA0(*fp); tn; tn = NEXT(tn) ) |
for ( tn = (NODE)FA0(*fp); tn; tn = NEXT(tn) ) |
if ( sn = (SNODE)BDY(tn) ) { |
if ( sn = (SNODE)BDY(tn) ) { |
snp = (SNODE *)(ID(sn) == S_BP ? &FA0(sn) : &BDY(tn)); |
snp = (SNODE *)(ID(sn) == S_BP ? &FA0(sn) : &BDY(tn)); |
if ( (*snp)->ln >= n ) { |
if ( (*snp)->ln >= n ) { |
searchsn(snp,n,fpp); break; |
searchsn(snp,n,fpp); break; |
} |
} |
} |
} |
break; |
break; |
case S_IFELSE: |
case S_IFELSE: |
if ( n <= (int)FA0(*fp) ) |
if ( n <= (int)FA0(*fp) ) |
*fpp = fp; |
*fpp = fp; |
else if ( n <= ((SNODE)FA2(*fp))->ln ) |
else if ( n <= ((SNODE)FA2(*fp))->ln ) |
searchsn((SNODE *)&FA2(*fp),n,fpp); |
searchsn((SNODE *)&FA2(*fp),n,fpp); |
else if ( FA3(*fp) ) |
else if ( FA3(*fp) ) |
searchsn((SNODE *)&FA3(*fp),n,fpp); |
searchsn((SNODE *)&FA3(*fp),n,fpp); |
if ( !(*fpp) ) |
if ( !(*fpp) ) |
*fpp = fp; |
*fpp = fp; |
break; |
break; |
case S_FOR: |
case S_FOR: |
if ( n <= (int)FA0(*fp) ) |
if ( n <= (int)FA0(*fp) ) |
*fpp = fp; |
*fpp = fp; |
else |
else |
searchsn((SNODE *)&FA4(*fp),n,fpp); |
searchsn((SNODE *)&FA4(*fp),n,fpp); |
if ( !(*fpp) ) |
if ( !(*fpp) ) |
*fpp = fp; |
*fpp = fp; |
break; |
break; |
case S_DO: |
case S_DO: |
if ( n <= (int)FA0(*fp) ) |
if ( n <= (int)FA0(*fp) ) |
*fpp = fp; |
*fpp = fp; |
else |
else |
searchsn((SNODE *)&FA1(*fp),n,fpp); |
searchsn((SNODE *)&FA1(*fp),n,fpp); |
if ( !(*fpp) ) |
if ( !(*fpp) ) |
*fpp = fp; |
*fpp = fp; |
break; |
break; |
case S_BP: |
case S_BP: |
switch ( ID((SNODE)FA0(*fp)) ) { |
switch ( ID((SNODE)FA0(*fp)) ) { |
case S_SINGLE: |
case S_SINGLE: |
*fpp = fp; break; |
*fpp = fp; break; |
default: |
default: |
searchsn((SNODE *)&FA0(*fp),n,fpp); break; |
searchsn((SNODE *)&FA0(*fp),n,fpp); break; |
} |
} |
break; |
break; |
case S_SINGLE: default: |
case S_SINGLE: default: |
*fpp = fp; |
*fpp = fp; |
break; |
break; |
} |
} |
} |
} |
|
|
void bp(SNODE f) |
void bp(SNODE f) |
{ |
{ |
int ln; |
int ln; |
|
|
if ( !f || (CPVS == GPVS) ) |
if ( !f || (CPVS == GPVS) ) |
return; |
return; |
|
|
switch ( ID(f) ) { |
switch ( ID(f) ) { |
case S_IFELSE: case S_FOR: |
case S_IFELSE: case S_FOR: |
ln = (int)FA0(f); break; |
ln = (int)FA0(f); break; |
default: |
default: |
ln = f->ln; break; |
ln = f->ln; break; |
} |
} |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 ) |
if ( do_server_in_X11 ) |
#endif |
#endif |
show_debug_window(1); |
show_debug_window(1); |
fprintf(stderr,"stopped in %s at line %d in file \"%s\"\n", |
fprintf(stderr,"stopped in %s at line %d in file \"%s\"\n", |
CPVS->usrf->name,ln,CPVS->usrf->f.usrf->fname); |
CPVS->usrf->name,ln,CPVS->usrf->f.usrf->fname); |
targetf = CPVS->usrf; curline = ln; |
targetf = CPVS->usrf; curline = ln; |
println(0,0,1); |
println(0,0,1); |
#if !defined(MPI) && !defined(VISUAL) |
#if !defined(MPI) && !defined(VISUAL) && !defined(__MINGW32__) |
if ( do_server_in_X11 || isatty(0) ) |
if ( do_server_in_X11 || isatty(0) ) |
#endif |
#endif |
debug(f); |
debug(f); |
} |
} |
|
|
void println(int ac,char **av,int l) |
void println(int ac,char **av,int l) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char buf[BUFSIZ+1]; |
char buf[BUFSIZ+1]; |
int i; |
int i; |
int ln; |
int ln; |
FUNC r; |
FUNC r; |
|
|
if ( !ac ) |
if ( !ac ) |
ln = curline; |
ln = curline; |
else if ( isdigit(av[0][0]) ) |
else if ( isdigit(av[0][0]) ) |
ln = atoi(av[0]); |
ln = atoi(av[0]); |
else { |
else { |
searchuf(av[0],&r); |
searchuf(av[0],&r); |
if ( r && r->id != A_UNDEF ) { |
if ( r && r->id != A_UNDEF ) { |
targetf = r; |
targetf = r; |
ln = r->f.usrf->startl; |
ln = r->f.usrf->startl; |
} else { |
} else { |
fprintf(stderr,"%s undefined\n",av[0]); |
fprintf(stderr,"%s undefined\n",av[0]); |
ln = curline; |
ln = curline; |
} |
} |
} |
} |
if ( !targetf ) |
if ( !targetf ) |
return; |
return; |
fp = fopen(targetf->f.usrf->fname,"r"); |
fp = fopen(targetf->f.usrf->fname,"r"); |
if ( !fp ) { |
if ( !fp ) { |
fprintf(stderr,"\"%s\" not found\n",targetf->name); |
fprintf(stderr,"\"%s\" not found\n",targetf->name); |
return; |
return; |
} |
} |
for ( i = 1; i < ln; i++ ) |
for ( i = 1; i < ln; i++ ) |
if ( !fgets(buf,BUFSIZ,fp) ) |
if ( !fgets(buf,BUFSIZ,fp) ) |
return; |
return; |
for ( i = 0; i < l; i++ ) { |
for ( i = 0; i < l; i++ ) { |
if ( !fgets(buf,BUFSIZ,fp) ) |
if ( !fgets(buf,BUFSIZ,fp) ) |
break; |
break; |
fprintf(stderr,"%d %s",ln+i,buf); |
fprintf(stderr,"%d %s",ln+i,buf); |
} |
} |
curline = ln + i; |
curline = ln + i; |
fclose(fp); |
fclose(fp); |
} |
} |
|
|
void printvars(char *s,VS vs) |
void printvars(char *s,VS vs) |
{ |
{ |
FNODE expr; |
FNODE expr; |
char *p; |
char *p; |
pointer val = 0; |
pointer val = 0; |
int err; |
int err; |
VS cpvs; |
VS cpvs; |
|
|
for ( p = s; *p; p++ ) |
for ( p = s; *p; p++ ) |
if ( *p == '\n' ) { |
if ( *p == '\n' ) { |
*p = 0; break; |
*p = 0; break; |
} |
} |
if ( exprparse(vs==GPVS?0:vs->usrf,s,&expr) ) { |
if ( exprparse(vs==GPVS?0:vs->usrf,s,&expr) ) { |
cpvs = CPVS; CPVS = vs; |
cpvs = CPVS; CPVS = vs; |
if ( !(err = SETJMP(debug_env)) ) |
if ( !(err = SETJMP(debug_env)) ) |
val = eval(expr); |
val = eval(expr); |
CPVS = cpvs; |
CPVS = cpvs; |
if ( !err ) { |
if ( !err ) { |
#if defined(PARI) |
asir_out = stderr; |
#if defined(PARI1) |
for ( p = s; isspace(*p); p++ ); |
outfile = stderr; |
fprintf(asir_out,"%s = ",p); |
#else |
if ( val && ID((R)val) == O_MAT ) |
pari_outfile = stderr; |
putc('\n',asir_out); |
#endif |
|
#endif |
|
asir_out = stderr; |
|
for ( p = s; isspace(*p); p++ ); |
|
fprintf(asir_out,"%s = ",p); |
|
if ( val && ID((R)val) == O_MAT ) |
|
putc('\n',asir_out); |
|
#if defined(VISUAL_LIB) |
#if defined(VISUAL_LIB) |
w_noflush_stderr(1); |
w_noflush_stderr(1); |
#endif |
#endif |
printexpr(CO,val); putc('\n',asir_out); fflush(asir_out); |
printexpr(CO,val); putc('\n',asir_out); fflush(asir_out); |
#if defined(VISUAL_LIB) |
#if defined(VISUAL_LIB) |
w_noflush_stderr(0); |
w_noflush_stderr(0); |
#endif |
#endif |
#if defined(PARI) |
asir_out = stdout; |
#if defined(PARI1) |
} |
outfile = stdout; |
} |
#else |
|
pari_outfile = stdout; |
|
#endif |
|
#endif |
|
asir_out = stdout; |
|
} |
|
} |
|
} |
} |
|
|
void showpos() |
void showpos() |
{ |
{ |
NODE n; |
NODE n; |
VS vs; |
VS vs; |
int level; |
int level; |
|
|
if ( PVSS ) { |
if ( PVSS ) { |
if ( cur_binf ) |
if ( cur_binf ) |
fprintf(stderr,"%s() (builtin)\n",cur_binf->name); |
fprintf(stderr,"%s() (builtin)\n",cur_binf->name); |
((VS)BDY(PVSS))->at = evalstatline; |
((VS)BDY(PVSS))->at = evalstatline; |
level = ((VS)BDY(PVSS))->level; |
level = ((VS)BDY(PVSS))->level; |
for ( n = PVSS; n; n = NEXT(n) ) { |
for ( n = PVSS; n; n = NEXT(n) ) { |
vs = (VS)BDY(n); |
vs = (VS)BDY(n); |
fprintf(stderr,"#%d %s(), line %d in \"%s\"\n", |
fprintf(stderr,"#%d %s(), line %d in \"%s\"\n", |
level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
} |
} |
} |
} |
} |
} |
|
|
void showpos_to_string(char *buf) |
void showpos_to_string(char *buf) |
{ |
{ |
NODE n; |
NODE n; |
VS vs; |
VS vs; |
int level; |
int level; |
|
|
buf[0] = 0; |
buf[0] = 0; |
if ( PVSS ) { |
if ( PVSS ) { |
if ( cur_binf ) |
if ( cur_binf ) |
sprintf(buf,"%s() (builtin)\n",cur_binf->name); |
sprintf(buf,"%s() (builtin)\n",cur_binf->name); |
buf += strlen(buf); |
buf += strlen(buf); |
((VS)BDY(PVSS))->at = evalstatline; |
((VS)BDY(PVSS))->at = evalstatline; |
level = ((VS)BDY(PVSS))->level; |
level = ((VS)BDY(PVSS))->level; |
for ( n = PVSS; n; n = NEXT(n) ) { |
for ( n = PVSS; n; n = NEXT(n) ) { |
vs = (VS)BDY(n); |
vs = (VS)BDY(n); |
sprintf(buf,"#%d %s(), line %d in \"%s\"\n", |
sprintf(buf,"#%d %s(), line %d in \"%s\"\n", |
level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
buf += strlen(buf); |
buf += strlen(buf); |
} |
} |
} |
} |
} |
} |
|
|
/* [[file,line,name],...] */ |
/* [[file,line,name],...] */ |
|
|
|
extern int at_root; |
|
|
void showpos_to_list(LIST *r) |
void showpos_to_list(LIST *r) |
{ |
{ |
NODE n,u,u1,t; |
NODE n,u,u1,t; |
VS vs; |
VS vs; |
STRING null,name,fname; |
STRING null,name,fname,kwd; |
LIST l; |
LIST l,b; |
Q q; |
USINT us; |
|
|
u = 0; |
u = 0; |
if ( PVSS ) { |
if ( PVSS ) { |
if ( cur_binf ) { |
if ( cur_binf ) { |
/* builtin : [0,0,name] */ |
/* builtin : [0,0,name] */ |
MKSTR(null,""); |
MKSTR(null,""); |
MKSTR(name,cur_binf->name); |
MKSTR(name,cur_binf->name); |
t = mknode(3,null,name,0); |
t = mknode(3,null,name,NULLP); |
MKLIST(l,t); |
MKLIST(l,t); |
MKNODE(u1,l,0); u = u1; |
MKNODE(u1,l,0); u = u1; |
} |
} |
((VS)BDY(PVSS))->at = evalstatline; |
((VS)BDY(PVSS))->at = evalstatline; |
for ( n = PVSS; n; n = NEXT(n) ) { |
for ( n = PVSS; n; n = NEXT(n) ) { |
vs = (VS)BDY(n); |
vs = (VS)BDY(n); |
MKSTR(fname,vs->usrf->f.usrf->fname); |
MKSTR(fname,vs->usrf->f.usrf->fname); |
STOQ(vs->at,q); |
MKUSINT(us,vs->at); |
MKSTR(name,vs->usrf->name); |
MKSTR(name,vs->usrf->name); |
t = mknode(3,fname,name,q); |
t = mknode(3,fname,name,us); |
MKLIST(l,t); |
MKLIST(l,t); |
MKNODE(u1,l,u); u = u1; |
MKNODE(u1,l,u); u = u1; |
} |
} |
} |
} |
MKLIST(*r,u); |
/* line number at the toplevel */ |
|
MKSTR(fname,"toplevel"); MKUSINT(us,at_root); |
|
t = mknode(2,fname,us); MKLIST(l,t); MKNODE(u1,l,u); u = u1; |
|
MKLIST(b,u); |
|
|
|
MKSTR(kwd,"asir_where"); |
|
t = mknode(2,kwd,b); |
|
MKLIST(*r,t); |
} |
} |
|
|
void change_stack(int level,NODE *pvss) |
void change_stack(int level,NODE *pvss) |
{ |
{ |
extern NODE PVSS; |
extern NODE PVSS; |
NODE n; |
NODE n; |
int i; |
int i; |
VS vs; |
VS vs; |
|
|
if ( !level || !PVSS ) |
if ( !level || !PVSS ) |
return; |
return; |
if ( level < 0 ) { |
if ( level < 0 ) { |
for ( n = PVSS, i = 0; n && n != *pvss; n = NEXT(n), i++ ); |
for ( n = PVSS, i = 0; n && n != *pvss; n = NEXT(n), i++ ); |
for ( n = PVSS, i = MAX(i+level,0); n && i; n = NEXT(n), i-- ); |
for ( n = PVSS, i = MAX(i+level,0); n && i; n = NEXT(n), i-- ); |
} else |
} else |
for ( n = *pvss, i = level; NEXT(n) && i; n = NEXT(n), i-- ); |
for ( n = *pvss, i = level; NEXT(n) && i; n = NEXT(n), i-- ); |
*pvss = n; vs = (VS)BDY(n); |
*pvss = n; vs = (VS)BDY(n); |
((VS)BDY(PVSS))->at = evalstatline; |
((VS)BDY(PVSS))->at = evalstatline; |
show_stack(vs); |
show_stack(vs); |
targetf = vs->usrf; curline = vs->at; |
targetf = vs->usrf; curline = vs->at; |
} |
} |
|
|
void show_stack(VS vs) |
void show_stack(VS vs) |
{ |
{ |
fprintf(stderr,"#%d %s(), line %d in \"%s\"\n", |
fprintf(stderr,"#%d %s(), line %d in \"%s\"\n", |
((VS)BDY(PVSS))->level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
((VS)BDY(PVSS))->level-vs->level,vs->usrf->name,vs->at,vs->usrf->f.usrf->fname); |
} |
} |