From d4abf5790494974dd0842cd06e21cfb3b45ab83d Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 4 Dec 1995 15:29:42 +0000 Subject: [PATCH] Fixed warnings, recognize -gdb --- lang/m2/comp/error.c | 50 ++++++++++++++++++++++-------------------- lang/m2/comp/options.c | 5 +++++ lang/m2/comp/stab.c | 30 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index c67236652..2c265f7b6 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -72,7 +72,7 @@ debug(char *fmt, ...) va_start(ap, fmt); { - _error(VDEBUG, NULLNODE, ap); + _error(VDEBUG, NULLNODE, ap, 0); } va_end(ap); } @@ -85,7 +85,7 @@ error(char *fmt, ...) va_start(ap, fmt); { - _error(ERROR, NULLNODE, fmt, ap); + _error(ERROR, NULLNODE, fmt, ap, 0); } va_end(ap); } @@ -97,31 +97,31 @@ node_error(t_node *node, char *fmt, ...) va_start(ap, fmt); { - _error(ERROR, node, fmt, ap); + _error(ERROR, node, fmt, ap, 0); } va_end(ap); } /*VARARGS*/ -warning(char *fmt, ...) +warning(int class, char *fmt, ...) { va_list ap; va_start(ap, fmt); { - _error(WARNING, NULLNODE, fmt, ap); + _error(WARNING, NULLNODE, fmt, ap, class); } va_end(ap); } /*VARARGS*/ -node_warning(t_node *node, char *fmt, ...) +node_warning(t_node *node, int class, char *fmt, ...) { va_list ap; va_start(ap, fmt); { - _error(WARNING, node, fmt, ap); + _error(WARNING, node, fmt, ap, class); } va_end(ap); } @@ -133,19 +133,19 @@ lexerror(char *fmt, ...) va_start(ap, fmt); { - _error(LEXERROR, NULLNODE, fmt, ap); + _error(LEXERROR, NULLNODE, fmt, ap, 0); } va_end(ap); } /*VARARGS*/ -lexwarning(char *fmt, ...) +lexwarning(int class, char *fmt, ...) { va_list ap; va_start(ap, fmt); { - _error(LEXWARNING, NULLNODE, fmt, ap); + _error(LEXWARNING, NULLNODE, fmt, ap, class); } va_end(ap); } @@ -157,7 +157,7 @@ fatal(char *fmt, ...) va_start(ap, fmt); { - _error(FATAL, NULLNODE, fmt, ap); + _error(FATAL, NULLNODE, fmt, ap, 0); } va_end(ap); sys_stop(S_EXIT); @@ -170,7 +170,7 @@ crash(char *fmt, ...) va_start(ap, fmt); { - _error(CRASH, NULLNODE, fmt, ap); + _error(CRASH, NULLNODE, fmt, ap, 0); } va_end(ap); #ifdef DEBUG @@ -190,7 +190,7 @@ debug(va_alist) va_start(ap); { char *fmt = va_arg(ap, char *); - _error(VDEBUG, NULLNODE, fmt, ap); + _error(VDEBUG, NULLNODE, fmt, ap, 0); } va_end(ap); } @@ -205,7 +205,7 @@ error(va_alist) va_start(ap); { char *fmt = va_arg(ap, char *); - _error(ERROR, NULLNODE, fmt, ap); + _error(ERROR, NULLNODE, fmt, ap, 0); } va_end(ap); } @@ -220,7 +220,7 @@ node_error(va_alist) { t_node *node = va_arg(ap, t_node *); char *fmt = va_arg(ap, char *); - _error(ERROR, node, fmt, ap); + _error(ERROR, node, fmt, ap, 0); } va_end(ap); } @@ -233,8 +233,9 @@ warning(va_alist) va_start(ap); { + int class = va_arg(ap, int); char *fmt = va_arg(ap, char *); - _error(WARNING, NULLNODE, fmt, ap); + _error(WARNING, NULLNODE, fmt, ap, class); } va_end(ap); } @@ -248,8 +249,9 @@ node_warning(va_alist) va_start(ap); { t_node *nd = va_arg(ap, t_node *); + int class = va_arg(ap, int); char *fmt = va_arg(ap, char *); - _error(WARNING, nd, fmt, ap); + _error(WARNING, nd, fmt, ap, class); } va_end(ap); } @@ -263,7 +265,7 @@ lexerror(va_alist) va_start(ap); { char *fmt = va_arg(ap, char *); - _error(LEXERROR, NULLNODE, fmt, ap); + _error(LEXERROR, NULLNODE, fmt, ap, 0); } va_end(ap); } @@ -276,8 +278,9 @@ lexwarning(va_alist) va_start(ap); { + int class = va_arg(ap, int); char *fmt = va_arg(ap, char *); - _error(LEXWARNING, NULLNODE, fmt, ap); + _error(LEXWARNING, NULLNODE, fmt, ap, class); } va_end(ap); } @@ -291,7 +294,7 @@ fatal(va_alist) va_start(ap); { char *fmt = va_arg(ap, char *); - _error(FATAL, NULLNODE, fmt, ap); + _error(FATAL, NULLNODE, fmt, ap, 0); } va_end(ap); sys_stop(S_EXIT); @@ -306,7 +309,7 @@ crash(va_alist) va_start(ap); { char *fmt = va_arg(ap, char *); - _error(CRASH, NULLNODE, fmt, ap); + _error(CRASH, NULLNODE, fmt, ap, 0); } va_end(ap); #ifdef DEBUG @@ -317,18 +320,18 @@ crash(va_alist) } #endif -_error(class, node, fmt, ap) +_error(class, node, fmt, ap, warn_class) int class; t_node *node; char *fmt; register va_list ap; + int warn_class; { /* _error attempts to limit the number of error messages for a given line to MAXERR_LINE. */ unsigned int ln = 0; register char *remark = 0; - int warn_class; /* check visibility of message */ if (class == ERROR || class == WARNING) { @@ -355,7 +358,6 @@ _error(class, node, fmt, ap) switch (class) { case WARNING: case LEXWARNING: - warn_class = va_arg(ap, int); if (! (warn_class & warning_classes)) return; switch(warn_class) { #ifndef STRICT_3RD_ED diff --git a/lang/m2/comp/options.c b/lang/m2/comp/options.c index 8e3be2ba0..2fb671f4d 100644 --- a/lang/m2/comp/options.c +++ b/lang/m2/comp/options.c @@ -35,6 +35,7 @@ recognize some keywords! extern int idfsize; static int ndirs = 1; int warning_classes = W_INITIAL; +int gdb_flag; DoOption(text) register char *text; @@ -64,6 +65,10 @@ DoOption(text) #ifdef DBSYMTAB case 'g': /* generate symbol table for debugger */ options['g']++; + if (*text == 'd') { + /* Assume -gdb. */ + gdb_flag = 1; + } options['n']++; /* no register vars ??? */ break; #endif /* DBSYMTAB */ diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index a87c86a70..c9c0c1495 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -27,6 +27,8 @@ #include "scope.h" #include "main.h" +extern int gdb_flag; + #define INCR_SIZE 64 extern int proclevel; @@ -276,12 +278,34 @@ stb_string(df, kind) addc_db_str(':'); switch(kind) { case D_MODULE: - adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); + if (gdb_flag) { + addc_db_str('F'); + stb_type(void_type, 0); + addc_db_str(';'); + } + else { + adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); + } C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->mod_vis->sc_scope->sc_name); break; case D_PROCEDURE: - adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); + if (gdb_flag) { + addc_db_str('f'); + } + else adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); stb_type(tp->tp_next ? tp->tp_next : void_type, 0); + if (gdb_flag) { + t_scopelist *sc = df->prc_vis; + sc = enclosing(sc); + while (sc) { + t_def *d = sc->sc_scope->sc_definedby; + + if (d && d->df_kind == D_PROCEDURE) { + adds_db_str(sprint(buf, ",%s", d->df_idf->id_text)); + } + sc = enclosing(sc); + } + } addc_db_str(';'); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->prc_vis->sc_scope->sc_name); { @@ -293,10 +317,12 @@ stb_string(df, kind) } break; case D_END: + if (gdb_flag) break; adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count)); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); break; case D_PEND: + if (gdb_flag) break; adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); break;