1990-10-29 11:38:35 +00:00
|
|
|
/* $Header$ */
|
|
|
|
|
1990-08-31 18:22:53 +00:00
|
|
|
#include <stdio.h>
|
1990-11-06 12:23:41 +00:00
|
|
|
#include <signal.h>
|
1993-11-10 15:11:28 +00:00
|
|
|
#if __STDC__
|
|
|
|
#include <stdarg.h>
|
|
|
|
#else
|
|
|
|
#include <varargs.h>
|
|
|
|
#endif
|
1990-08-31 18:22:53 +00:00
|
|
|
|
|
|
|
#include "tokenname.h"
|
|
|
|
#include "position.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "symbol.h"
|
|
|
|
#include "scope.h"
|
1990-09-25 17:40:47 +00:00
|
|
|
#include "Lpars.h"
|
1990-12-19 11:17:06 +00:00
|
|
|
#include "type.h"
|
1993-06-09 14:18:43 +00:00
|
|
|
#include "langdep.h"
|
1993-11-10 15:11:28 +00:00
|
|
|
#include "misc.h"
|
1990-08-31 18:22:53 +00:00
|
|
|
|
1990-09-21 16:58:20 +00:00
|
|
|
static char *usage = "Usage: %s [<ack.out>] [<a.out>]";
|
1990-10-11 08:42:07 +00:00
|
|
|
char *progname;
|
1990-08-31 18:22:53 +00:00
|
|
|
char *AckObj;
|
|
|
|
char *AObj;
|
|
|
|
char *dirs[] = { "", 0 };
|
|
|
|
FILE *db_out;
|
|
|
|
FILE *db_in;
|
|
|
|
int debug;
|
|
|
|
extern struct tokenname tkidf[];
|
|
|
|
extern char *strindex();
|
1990-11-12 13:46:31 +00:00
|
|
|
extern void signal_child();
|
|
|
|
extern void init_del();
|
|
|
|
extern void init_run();
|
1990-10-11 08:42:07 +00:00
|
|
|
extern int eof_seen;
|
1990-10-17 17:00:03 +00:00
|
|
|
extern int interrupted;
|
1990-08-31 18:22:53 +00:00
|
|
|
|
1990-09-25 17:40:47 +00:00
|
|
|
static struct tokenname shorts[] = {
|
|
|
|
{LIST, "l"},
|
|
|
|
{CONT, "c"},
|
|
|
|
{STEP, "s"},
|
|
|
|
{NEXT, "n"},
|
|
|
|
{DELETE, "d"},
|
|
|
|
{PRINT, "p"},
|
|
|
|
{RESTORE, "r"},
|
|
|
|
{TRACE, "t"},
|
1990-10-11 08:42:07 +00:00
|
|
|
{WHERE, "w"},
|
1990-09-25 17:40:47 +00:00
|
|
|
{ 0, 0}
|
|
|
|
};
|
|
|
|
|
1990-08-31 18:22:53 +00:00
|
|
|
main(argc, argv)
|
|
|
|
char *argv[];
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
db_out = stdout;
|
|
|
|
db_in = stdin;
|
|
|
|
progname = argv[0];
|
1990-10-11 08:42:07 +00:00
|
|
|
init_del();
|
1990-08-31 18:22:53 +00:00
|
|
|
while (p = strindex(progname, '/')) {
|
|
|
|
progname = p + 1;
|
|
|
|
}
|
1990-12-19 11:17:06 +00:00
|
|
|
while (argv[1] && argv[1][0] == '-') {
|
1990-08-31 18:22:53 +00:00
|
|
|
switch(argv[1][1]) {
|
1990-12-19 11:17:06 +00:00
|
|
|
case 'v':
|
1990-08-31 18:22:53 +00:00
|
|
|
debug++;
|
|
|
|
break;
|
1990-12-19 11:17:06 +00:00
|
|
|
case 'i':
|
|
|
|
int_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
short_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
long_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
float_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
double_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
pointer_size = atoi(&argv[1][2]);
|
|
|
|
break;
|
1990-08-31 18:22:53 +00:00
|
|
|
default:
|
|
|
|
fatal(usage, progname);
|
|
|
|
}
|
|
|
|
argv++;
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
if (argc > 3) {
|
|
|
|
fatal(usage, progname);
|
|
|
|
}
|
|
|
|
AckObj = argv[1] ? argv[1] : "a.out";
|
|
|
|
if (argc == 3) AObj = argv[2];
|
|
|
|
init_types();
|
|
|
|
init_scope();
|
|
|
|
init_languages();
|
1990-10-29 11:38:35 +00:00
|
|
|
if (DbRead(AckObj) && AObj == 0) AObj = AckObj;
|
1990-08-31 18:22:53 +00:00
|
|
|
else if (AObj == 0) AObj = "a.out";
|
|
|
|
reserve(tkidf);
|
1990-09-25 17:40:47 +00:00
|
|
|
reserve(shorts);
|
1990-11-12 13:46:31 +00:00
|
|
|
init_run();
|
1993-06-09 14:18:43 +00:00
|
|
|
if (! currlang) {
|
|
|
|
fatal("could not determine source language. Recompile with -g?");
|
|
|
|
}
|
1990-08-31 18:22:53 +00:00
|
|
|
prompt();
|
|
|
|
Commands();
|
1990-11-06 12:23:41 +00:00
|
|
|
signal_child(SIGKILL);
|
1990-10-29 11:38:35 +00:00
|
|
|
if (eof_seen) putc('\n', db_out);
|
1990-08-31 18:22:53 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt()
|
|
|
|
{
|
|
|
|
if (isatty(fileno(db_in))) {
|
1990-10-11 08:42:07 +00:00
|
|
|
fprintf(db_out, "-> ");
|
1990-08-31 18:22:53 +00:00
|
|
|
fflush(db_out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-11-10 15:11:28 +00:00
|
|
|
extern int errorgiven;
|
|
|
|
|
|
|
|
#if __STDC__
|
|
|
|
void
|
|
|
|
fatal(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
{
|
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
error(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
if (! interrupted) {
|
|
|
|
va_start(ap, fmt);
|
|
|
|
{
|
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
errorgiven = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
warning(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
{
|
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
1990-10-29 11:38:35 +00:00
|
|
|
/*VARARGS*/
|
1993-11-10 15:11:28 +00:00
|
|
|
void
|
1990-08-31 18:22:53 +00:00
|
|
|
fatal(va_alist)
|
|
|
|
va_dcl
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *fmt;
|
|
|
|
|
|
|
|
va_start(ap);
|
|
|
|
{
|
|
|
|
fmt = va_arg(ap, char *);
|
1990-10-11 08:42:07 +00:00
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1990-10-29 11:38:35 +00:00
|
|
|
/*VARARGS*/
|
1993-11-10 15:11:28 +00:00
|
|
|
void
|
1990-08-31 18:22:53 +00:00
|
|
|
error(va_alist)
|
|
|
|
va_dcl
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *fmt;
|
|
|
|
|
1990-10-17 17:00:03 +00:00
|
|
|
if (! interrupted) {
|
|
|
|
va_start(ap);
|
|
|
|
{
|
|
|
|
fmt = va_arg(ap, char *);
|
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
|
|
|
errorgiven = 1;
|
|
|
|
}
|
|
|
|
|
1990-10-29 11:38:35 +00:00
|
|
|
/*VARARGS*/
|
1993-11-10 15:11:28 +00:00
|
|
|
void
|
1990-09-14 14:37:26 +00:00
|
|
|
warning(va_alist)
|
|
|
|
va_dcl
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *fmt;
|
|
|
|
|
|
|
|
va_start(ap);
|
|
|
|
{
|
|
|
|
fmt = va_arg(ap, char *);
|
1990-10-11 08:42:07 +00:00
|
|
|
fprintf(db_out, "%s: ", progname);
|
|
|
|
vfprintf(db_out, fmt, ap);
|
|
|
|
fprintf(db_out, "\n");
|
1990-09-14 14:37:26 +00:00
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
1993-11-10 15:11:28 +00:00
|
|
|
#endif
|
1990-09-14 14:37:26 +00:00
|
|
|
|
1993-11-10 15:11:28 +00:00
|
|
|
void
|
1990-08-31 18:22:53 +00:00
|
|
|
rd_fatal()
|
|
|
|
{
|
|
|
|
fatal("read error in %s", AckObj);
|
|
|
|
}
|
|
|
|
|
1993-11-10 15:11:28 +00:00
|
|
|
void
|
1990-08-31 18:22:53 +00:00
|
|
|
No_Mem()
|
|
|
|
{
|
|
|
|
fatal("out of memory");
|
|
|
|
}
|