Added support for debugger, de-linted somewhat
authorceriel <none@none>
Mon, 1 Oct 1990 15:28:28 +0000 (15:28 +0000)
committerceriel <none@none>
Mon, 1 Oct 1990 15:28:28 +0000 (15:28 +0000)
17 files changed:
lang/cem/cemcom.ansi/.distr
lang/cem/cemcom.ansi/BigPars
lang/cem/cemcom.ansi/LintPars
lang/cem/cemcom.ansi/Makefile
lang/cem/cemcom.ansi/SmallPars
lang/cem/cemcom.ansi/cemcom.1
lang/cem/cemcom.ansi/code.c
lang/cem/cemcom.ansi/declar.g
lang/cem/cemcom.ansi/idf.c
lang/cem/cemcom.ansi/main.c
lang/cem/cemcom.ansi/options
lang/cem/cemcom.ansi/options.c
lang/cem/cemcom.ansi/pragma.c
lang/cem/cemcom.ansi/replace.c
lang/cem/cemcom.ansi/stab.c [new file with mode: 0644]
lang/cem/cemcom.ansi/statement.g
lang/cem/cemcom.ansi/type.str

index fd99368..a922449 100644 (file)
@@ -89,6 +89,7 @@ scan.c
 sizes.h
 skip.c
 specials.h
+stab.c
 stack.c
 stack.str
 statement.g
index c5ecb47..b3bbfb5 100644 (file)
 #undef REGCOUNT                1       /* count occurrences for register messages */
 
 
+!File: dbsymtab.h
+#define DBSYMTAB       1       /* ability to produce symbol table for debugger */
+
+
index 1193386..27f6151 100644 (file)
 #undef REGCOUNT                1       /* count occurrences for register messages */
 
 
+!File: dbsymtab.h
+#undef DBSYMTAB        1       /* ability to produce symbol table for debugger */
+
+
index 56ded6b..10f8850 100644 (file)
@@ -83,7 +83,7 @@ CSRC =        main.c idf.c declarator.c decspecs.c struct.c \
        input.c domacro.c replace.c init.c options.c \
        skip.c stack.c type.c ch3mon.c label.c eval.c \
        switch.c conversion.c util.c proto.c \
-       pragma.c blocks.c dataflow.c Version.c \
+       pragma.c blocks.c dataflow.c Version.c stab.c\
        l_lint.c l_states.c l_misc.c l_ev_ord.c l_outdef.c l_comment.c l_dummy.c
 COBJ = main.o idf.o declarator.o decspecs.o struct.o \
        expr.o ch3.o ch3bin.o cstoper.o fltcstoper.o arith.o \
@@ -92,7 +92,7 @@ COBJ =        main.o idf.o declarator.o decspecs.o struct.o \
        input.o domacro.o replace.o init.o options.o \
        skip.o stack.o type.o ch3mon.o label.o eval.o \
        switch.o conversion.o util.o proto.o \
-       pragma.o blocks.o dataflow.o Version.o \
+       pragma.o blocks.o dataflow.o Version.o stab.o \
        l_lint.o l_states.o l_misc.o l_ev_ord.o l_outdef.o l_comment.o l_dummy.o
 
 # Objects of other generated C files
@@ -281,6 +281,8 @@ main.o: LLlex.h
 main.o: Lpars.h
 main.o: align.h
 main.o: arith.h
+main.o: assert.h
+main.o: dbsymtab.h
 main.o: debug.h
 main.o: declar.h
 main.o: file_info.h
@@ -307,6 +309,7 @@ idf.o: align.h
 idf.o: arith.h
 idf.o: assert.h
 idf.o: botch_free.h
+idf.o: dbsymtab.h
 idf.o: debug.h
 idf.o: declar.h
 idf.o: decspecs.h
@@ -332,6 +335,7 @@ idf.o: type.h
 declarator.o: Lpars.h
 declarator.o: arith.h
 declarator.o: botch_free.h
+declarator.o: dbsymtab.h
 declarator.o: debug.h
 declarator.o: declar.h
 declarator.o: def.h
@@ -351,6 +355,7 @@ declarator.o: type.h
 decspecs.o: Lpars.h
 decspecs.o: arith.h
 decspecs.o: assert.h
+decspecs.o: dbsymtab.h
 decspecs.o: debug.h
 decspecs.o: decspecs.h
 decspecs.o: def.h
@@ -365,6 +370,7 @@ struct.o: align.h
 struct.o: arith.h
 struct.o: assert.h
 struct.o: botch_free.h
+struct.o: dbsymtab.h
 struct.o: debug.h
 struct.o: def.h
 struct.o: field.h
@@ -387,6 +393,7 @@ expr.o: Lpars.h
 expr.o: arith.h
 expr.o: assert.h
 expr.o: botch_free.h
+expr.o: dbsymtab.h
 expr.o: debug.h
 expr.o: declar.h
 expr.o: decspecs.h
@@ -408,6 +415,7 @@ expr.o: use_tmp.h
 ch3.o: Lpars.h
 ch3.o: arith.h
 ch3.o: assert.h
+ch3.o: dbsymtab.h
 ch3.o: debug.h
 ch3.o: def.h
 ch3.o: expr.h
@@ -424,6 +432,7 @@ ch3.o: type.h
 ch3bin.o: Lpars.h
 ch3bin.o: arith.h
 ch3bin.o: botch_free.h
+ch3bin.o: dbsymtab.h
 ch3bin.o: debug.h
 ch3bin.o: expr.h
 ch3bin.o: idf.h
@@ -440,6 +449,7 @@ ch3bin.o: type.h
 cstoper.o: Lpars.h
 cstoper.o: arith.h
 cstoper.o: assert.h
+cstoper.o: dbsymtab.h
 cstoper.o: debug.h
 cstoper.o: expr.h
 cstoper.o: idf.h
@@ -454,6 +464,7 @@ cstoper.o: type.h
 fltcstoper.o: Lpars.h
 fltcstoper.o: arith.h
 fltcstoper.o: assert.h
+fltcstoper.o: dbsymtab.h
 fltcstoper.o: debug.h
 fltcstoper.o: expr.h
 fltcstoper.o: idf.h
@@ -468,6 +479,7 @@ fltcstoper.o: type.h
 arith.o: Lpars.h
 arith.o: arith.h
 arith.o: assert.h
+arith.o: dbsymtab.h
 arith.o: debug.h
 arith.o: expr.h
 arith.o: field.h
@@ -490,6 +502,7 @@ code.o: atw.h
 code.o: botch_free.h
 code.o: code.h
 code.o: dataflow.h
+code.o: dbsymtab.h
 code.o: debug.h
 code.o: declar.h
 code.o: decspecs.h
@@ -514,6 +527,7 @@ code.o: type.h
 code.o: use_tmp.h
 dumpidf.o: Lpars.h
 dumpidf.o: arith.h
+dumpidf.o: dbsymtab.h
 dumpidf.o: debug.h
 dumpidf.o: declar.h
 dumpidf.o: def.h
@@ -547,6 +561,7 @@ field.o: align.h
 field.o: arith.h
 field.o: assert.h
 field.o: code.h
+field.o: dbsymtab.h
 field.o: debug.h
 field.o: expr.h
 field.o: field.h
@@ -647,6 +662,7 @@ options.o: arith.h
 options.o: botch_free.h
 options.o: class.h
 options.o: dataflow.h
+options.o: dbsymtab.h
 options.o: idf.h
 options.o: idfsize.h
 options.o: lint.h
@@ -668,6 +684,7 @@ skip.o: spec_arith.h
 stack.o: Lpars.h
 stack.o: arith.h
 stack.o: botch_free.h
+stack.o: dbsymtab.h
 stack.o: debug.h
 stack.o: def.h
 stack.o: idf.h
@@ -684,6 +701,7 @@ type.o: Lpars.h
 type.o: align.h
 type.o: arith.h
 type.o: botch_free.h
+type.o: dbsymtab.h
 type.o: debug.h
 type.o: decspecs.h
 type.o: def.h
@@ -700,6 +718,7 @@ type.o: type.h
 ch3mon.o: Lpars.h
 ch3mon.o: arith.h
 ch3mon.o: botch_free.h
+ch3mon.o: dbsymtab.h
 ch3mon.o: debug.h
 ch3mon.o: def.h
 ch3mon.o: expr.h
@@ -715,6 +734,7 @@ ch3mon.o: trgt_sizes.h
 ch3mon.o: type.h
 label.o: Lpars.h
 label.o: arith.h
+label.o: dbsymtab.h
 label.o: def.h
 label.o: idf.h
 label.o: label.h
@@ -731,6 +751,7 @@ eval.o: assert.h
 eval.o: atw.h
 eval.o: code.h
 eval.o: dataflow.h
+eval.o: dbsymtab.h
 eval.o: debug.h
 eval.o: def.h
 eval.o: expr.h
@@ -753,6 +774,7 @@ switch.o: arith.h
 switch.o: assert.h
 switch.o: botch_free.h
 switch.o: code.h
+switch.o: dbsymtab.h
 switch.o: debug.h
 switch.o: density.h
 switch.o: expr.h
@@ -768,6 +790,7 @@ switch.o: trgt_sizes.h
 switch.o: type.h
 conversion.o: Lpars.h
 conversion.o: arith.h
+conversion.o: dbsymtab.h
 conversion.o: lint.h
 conversion.o: nobitfield.h
 conversion.o: nocross.h
@@ -792,6 +815,7 @@ proto.o: align.h
 proto.o: arith.h
 proto.o: assert.h
 proto.o: botch_free.h
+proto.o: dbsymtab.h
 proto.o: debug.h
 proto.o: declar.h
 proto.o: decspecs.h
@@ -827,11 +851,26 @@ blocks.o: spec_arith.h
 blocks.o: stack.h
 blocks.o: trgt_sizes.h
 dataflow.o: dataflow.h
+stab.o: LLlex.h
+stab.o: Lpars.h
+stab.o: dbsymtab.h
+stab.o: def.h
+stab.o: field.h
+stab.o: file_info.h
+stab.o: idf.h
+stab.o: level.h
+stab.o: lint.h
+stab.o: nobitfield.h
+stab.o: nopp.h
+stab.o: stack.h
+stab.o: struct.h
+stab.o: type.h
 l_lint.o: LLlex.h
 l_lint.o: Lpars.h
 l_lint.o: arith.h
 l_lint.o: assert.h
 l_lint.o: code.h
+l_lint.o: dbsymtab.h
 l_lint.o: debug.h
 l_lint.o: def.h
 l_lint.o: expr.h
@@ -854,6 +893,7 @@ l_states.o: Lpars.h
 l_states.o: arith.h
 l_states.o: assert.h
 l_states.o: code.h
+l_states.o: dbsymtab.h
 l_states.o: debug.h
 l_states.o: def.h
 l_states.o: expr.h
@@ -877,6 +917,7 @@ l_misc.o: LLlex.h
 l_misc.o: Lpars.h
 l_misc.o: arith.h
 l_misc.o: code.h
+l_misc.o: dbsymtab.h
 l_misc.o: debug.h
 l_misc.o: def.h
 l_misc.o: expr.h
@@ -897,6 +938,7 @@ l_ev_ord.o: Lpars.h
 l_ev_ord.o: arith.h
 l_ev_ord.o: assert.h
 l_ev_ord.o: code.h
+l_ev_ord.o: dbsymtab.h
 l_ev_ord.o: debug.h
 l_ev_ord.o: def.h
 l_ev_ord.o: expr.h
@@ -918,6 +960,7 @@ l_outdef.o: Lpars.h
 l_outdef.o: arith.h
 l_outdef.o: assert.h
 l_outdef.o: code.h
+l_outdef.o: dbsymtab.h
 l_outdef.o: debug.h
 l_outdef.o: def.h
 l_outdef.o: expr.h
@@ -953,6 +996,7 @@ declar.o: LLlex.h
 declar.o: Lpars.h
 declar.o: arith.h
 declar.o: code.h
+declar.o: dbsymtab.h
 declar.o: debug.h
 declar.o: declar.h
 declar.o: decspecs.h
@@ -980,6 +1024,7 @@ statement.o: Lpars.h
 statement.o: arith.h
 statement.o: botch_free.h
 statement.o: code.h
+statement.o: dbsymtab.h
 statement.o: debug.h
 statement.o: def.h
 statement.o: expr.h
@@ -998,6 +1043,7 @@ expression.o: LLlex.h
 expression.o: Lpars.h
 expression.o: arith.h
 expression.o: code.h
+expression.o: dbsymtab.h
 expression.o: debug.h
 expression.o: expr.h
 expression.o: file_info.h
@@ -1015,6 +1061,7 @@ program.o: LLlex.h
 program.o: Lpars.h
 program.o: arith.h
 program.o: code.h
+program.o: dbsymtab.h
 program.o: debug.h
 program.o: declar.h
 program.o: decspecs.h
@@ -1034,6 +1081,7 @@ ival.o: LLlex.h
 ival.o: Lpars.h
 ival.o: arith.h
 ival.o: assert.h
+ival.o: dbsymtab.h
 ival.o: debug.h
 ival.o: def.h
 ival.o: estack.h
index b246092..cac1a4d 100644 (file)
 #undef REGCOUNT                1       /* count occurrences for register messages */
 
 
+!File: dbsymtab.h
+#undef DBSYMTAB        1       /* ability to produce symbol table for debugger */
+
+
index 8ca43e1..b23b487 100644 (file)
@@ -28,6 +28,8 @@ the same as \fB\-D\fIname\fR=1.
 insert \fIdirname\fR in the list of include directories.
 .IP \fB\-M\fP\fIn\fP
 set maximum identifier length to \fIn\fP.
+.IP \fB\-g\fP
+produce a DBX-style symbol table.
 .IP \fB\-n\fR
 do not generate EM register messages.
 The user-declared variables are not stored into registers on the target
index c079145..e771968 100644 (file)
@@ -7,7 +7,8 @@
 
 #include       "lint.h"
 #include       "debug.h"
-#include       <em.h>
+#include       "dbsymtab.h"
+#include       <em_code.h>
 #include       "botch_free.h"
 #include       <alloc.h>
 #include       "dataflow.h"
@@ -34,6 +35,9 @@
 #ifdef LINT
 #include       "l_lint.h"
 #endif LINT
+#ifdef DBSYMTAB
+#include       <stb.h>
+#endif /* DBSYMTAB */
 
 label lab_count = 1;
 label datlab_count = 1;
@@ -53,6 +57,7 @@ static int    pro_id;
 
 extern char options[];
 extern char *symbol2str();
+extern char *source;
 
 #ifndef        LINT
 init_code(dst_file)
@@ -66,6 +71,23 @@ init_code(dst_file)
                fatal("cannot write to %s\n", dst_file);
        C_magic();
        C_ms_emx(word_size, pointer_size);
+#ifdef DBSYMTAB
+       if (options['g']) {
+               C_ms_std(source, N_SO, 0);
+               stb_typedef(int_type, "int");
+               stb_typedef(schar_type, "char");
+               stb_typedef(long_type, "long");
+               stb_typedef(short_type, "short");
+               stb_typedef(uchar_type, "unsigned char");
+               stb_typedef(ushort_type, "unsigned short");
+               stb_typedef(ulong_type, "unsigned long");
+               stb_typedef(uint_type, "unsigned int");
+               stb_typedef(float_type, "float");
+               stb_typedef(double_type, "double");
+               stb_typedef(lngdbl_type, "long double");
+               stb_typedef(void_type, "void");
+       }
+#endif /* DBSYMTAB */
 #ifdef USE_TMP
 #ifdef PREPEND_SCOPES
        C_insertpart(tmp_id = C_getid());
@@ -139,11 +161,10 @@ prepend_scopes()
        C_beginpart(tmp_id);
 #endif USE_TMP
        while (se != 0) {
-               register struct idf *id = se->se_idf;
-               register struct def *df = id->id_def;
+               register struct def *df = se->se_idf->id_def;
                
                if (df && (df->df_initialized || df->df_used || df->df_alloc)) {
-                       code_scope(id->id_text, df);
+                       code_scope(se->se_idf->id_text, df);
                }
                se = se->next;
        }
@@ -272,6 +293,14 @@ begin_proc(ds, idf)                /* to be called when entering a procedure */
                C_fil_dlb(file_name_label, (arith)0);
                C_lin((arith)LineNumber);
        }
+#ifdef DBSYMTAB
+       if (options['g']) {
+               stb_string(def, FUNCTION, name);
+               if (! strcmp(name, "main")) {
+                       C_ms_stb_cst(name, N_MAIN, 0, (arith) 0);
+               }
+       }
+#endif
 }
 
 end_proc(fbytes)
@@ -403,8 +432,14 @@ code_declaration(idf, expr, lvl, sc)
        int fund = def->df_type->tp_fund;
        int def_sc = def->df_sc;
        
-       if (def_sc == TYPEDEF)  /* no code for typedefs         */
+       if (def_sc == TYPEDEF)  {       /* no code for typedefs         */
+#ifdef DBSYMTAB
+               if (options['g']) {
+                       stb_typedef(def->df_type, idf->id_text);
+               }
+#endif /* DBSYMTAB */
                return;
+       }
        if (lvl == L_GLOBAL)    {       /* global variable      */
                /* is this an allocating declaration? */
                if (    (sc == 0 || sc == STATIC)
@@ -421,6 +456,11 @@ code_declaration(idf, expr, lvl, sc)
                        code_scope(idf->id_text, def);
 #endif PREPEND_SCOPES
                        def->df_alloc = ALLOC_DONE;
+#ifdef DBSYMTAB
+                       if (options['g']) {
+                               stb_string(def, sc, idf->id_text);
+                       }
+#endif /* DBSYMTAB */
                        C_df_dnam(idf->id_text);
                }
        }
@@ -436,6 +476,11 @@ code_declaration(idf, expr, lvl, sc)
                        /*      they are handled on the spot and get an
                                integer label in EM.
                        */
+#ifdef DBSYMTAB
+                       if (options['g']) {
+                               stb_string(def, sc, idf->id_text);
+                       }
+#endif /* DBSYMTAB */
                        C_df_dlb((label)def->df_address);
                        if (expr) { /* there is an initialisation */
                        }
@@ -457,6 +502,11 @@ code_declaration(idf, expr, lvl, sc)
                        break;
                case AUTO:
                case REGISTER:
+#ifdef DBSYMTAB
+                       if (options['g']) {
+                               stb_string(def, sc, idf->id_text);
+                       }
+#endif /* DBSYMTAB */
                        if (expr)
                                loc_init(expr, idf);
                        else if ((fund == ARRAY)
@@ -474,32 +524,33 @@ code_declaration(idf, expr, lvl, sc)
 
 loc_init(expr, id)
        struct expr *expr;
-       register struct idf *id;
+       struct idf *id;
 {
        /*      loc_init() generates code for the assignment of
                expression expr to the local variable described by id.
                It frees the expression afterwards.
        */
        register struct expr *e = expr;
-       register struct type *tp = id->id_def->df_type;
+       register struct def *df = id->id_def;
+       register struct type *tp = df->df_type;
        static arith tmpoffset = 0;
        static arith unknownsize = 0;
        
-       ASSERT(id->id_def->df_sc != STATIC);
+       ASSERT(df->df_sc != STATIC);
        switch (tp->tp_fund)    {
        case ARRAY:
-               if (id->id_def->df_type->tp_size == (arith) -1)
+               if (tp->tp_size == (arith) -1)
                        unknownsize = 1;
        case STRUCT:
        case UNION:
-               if (expr != (struct expr *) 0) {
+               if (e != (struct expr *) 0) {
                        break;          /* switch */
                } else if (!tmpoffset) {/* first time for this variable */
-                       tmpoffset = id->id_def->df_address;
-                       id->id_def->df_address = data_label();
-                       C_df_dlb((label)id->id_def->df_address);
+                       tmpoffset = df->df_address;
+                       df->df_address = data_label();
+                       C_df_dlb((label)df->df_address);
                } else {
-                       C_lae_dlb((label)id->id_def->df_address, (arith)0);
+                       C_lae_dlb((label)df->df_address, (arith)0);
                        load_block(tp->tp_size, 1);
                        if (unknownsize) {
                                /* tmpoffset += tp->tp_size; */
@@ -508,13 +559,19 @@ loc_init(expr, id)
                                tmpoffset = NewLocal(tp->tp_size
                                                    , tp->tp_align
                                                    , regtype(tp)
-                                                   , id->id_def->df_sc);
+                                                   , df->df_sc);
                        }
                        C_lal(tmpoffset);
                        store_block(tp->tp_size, 1);
-                       id->id_def->df_address = tmpoffset;
+                       df->df_address = tmpoffset;
                        tmpoffset = 0;
                }
+#ifdef DBSYMTAB
+               if (options['g']) {
+                       stb_string(df, AUTO, id->id_text);
+
+               }
+#endif /* DBSYMTAB */
                return;
        }
        if (ISCOMMA(e)) {       /* embraced: int i = {12};      */
@@ -536,7 +593,7 @@ loc_init(expr, id)
                        store_val(&vl, tp);
                }
 #else  LINT
-               id->id_def->df_set = 1;
+               df->df_set = 1;
 #endif LINT
                free_expression(expr);
        }
@@ -547,12 +604,18 @@ bss(idf)
 {
        /*      bss() allocates bss space for the global idf.
        */
+       register struct def *df = idf->id_def;
        
 #ifndef        PREPEND_SCOPES
-       code_scope(idf->id_text, idf->id_def);
+       code_scope(idf->id_text, df);
 #endif PREPEND_SCOPES
+#ifdef DBSYMTAB
+       if (options['g']) {
+               stb_string(df, df->df_sc, idf->id_text);
+       }
+#endif /* DBSYMTAB */
        C_df_dnam(idf->id_text);
-       C_bss_cst(ATW(idf->id_def->df_type->tp_size), (arith)0, 1);
+       C_bss_cst(ATW(df->df_type->tp_size), (arith)0, 1);
 }
 
 formal_cvt(hasproto,df)
@@ -596,6 +659,9 @@ code_expr(expr, val, code, tlbl, flbl)
 #ifndef        LINT
        if (! options['L'])     /* profiling    */
                C_lin((arith)(expr->ex_line));
+#ifdef DBSYMTAB
+       if (options['g']) db_line(expr->ex_file, (int)expr->ex_line);
+#endif
 
        EVAL(expr, val, code, tlbl, flbl);
 #else  LINT
@@ -690,3 +756,19 @@ prc_exit()
                C_asp(pointer_size);
        }
 }
+
+#ifdef DBSYMTAB
+db_line(file, line)
+       char    *file;
+       int     line;
+{
+       static int      oldline;
+       static char     *oldfile;
+
+       if (file != oldfile || line != oldline) {
+               C_ms_std((char *) 0, N_SLINE, line);
+               oldline = line;
+               oldfile = file;
+       }
+}
+#endif
index 837007a..2eeb12f 100644 (file)
@@ -7,6 +7,7 @@
 
 {
 #include       "lint.h"
+#include       "dbsymtab.h"
 #include       <alloc.h>
 #include       "nobitfield.h"
 #include       "debug.h"
@@ -31,6 +32,8 @@
 #include       "l_lint.h"
 #include       "l_state.h"
 #endif LINT
+
+extern char    options[];
 }
 
 /* 3.5 */
@@ -363,6 +366,13 @@ enum_specifier(register struct type **tpp;)
                [
                        {declare_struct(ENUM, idf, tpp);}
                        enumerator_pack(*tpp, &l)
+                       {
+#ifdef DBSYMTAB
+                               if (options['g']) {
+                                       stb_tag(idf->id_enum, idf->id_text);
+                               }
+#endif /*DBSYMTAB */
+                       }
                |
                        {apply_struct(ENUM, idf, tpp);}
                        /* empty */
@@ -430,6 +440,11 @@ struct_or_union_specifier(register struct type **tpp;)
                        struct_declaration_pack(*tpp)
                        {
                                (idf->id_struct->tg_busy)--;
+#ifdef DBSYMTAB
+                               if (options['g']) {
+                                       stb_tag(idf->id_struct, idf->id_text);
+                               }
+#endif /*DBSYMTAB */
                        }
                |
                        {
index b889feb..bc0f51a 100644 (file)
@@ -695,13 +695,18 @@ declare_formals(idf, fp)
                 */
                formal_cvt(hasproto, def);
 
-               se = se->next;
                def->df_level = L_FORMAL2;      /* CJ */
                RegisterAccount(def->df_address, def->df_type->tp_size,
                                regtype(def->df_type),
                                def->df_sc);
                if (nparams++ >= STDC_NPARAMS)
                        strict("number of formal parameters exceeds ANSI limit");
+#ifdef DBSYMTAB
+               if (options['g']) {
+                       stb_string(def, FORMAL, se->se_idf->id_text);
+               }
+#endif /* DBSYMTAB */
+               se = se->next;
        }
        *fp = f_offset;
 }
index cb680d0..95fbc4c 100644 (file)
@@ -176,7 +176,7 @@ char *source;
 add_dependency(s)
 char *s;
 {
-    register struct idf *p = str2idf(s, 0);
+    register struct idf *p = str2idf(s);
     
     if (! p->id_resmac) {
        p->id_resmac = K_FILE;
@@ -260,7 +260,7 @@ compile(argc, argv)
                FileName = source = argv[0];
        else {
                source = 0;
-               FileName = Salloc("standard input", 16);
+               FileName = Salloc("standard input", (unsigned) 16);
        }
 
        if (!InsertFile(source, (char **) 0, &result)) /* read the source file  */
index 69704e3..83ab797 100644 (file)
@@ -5,6 +5,7 @@ C       while running preprocessor, copy comment
 d      perform a small dataflow analysis
 D      see identifier following as a macro
 E      run preprocessor only
+g      produce symbol table for debugger
 i      suppress /usr/include include files in dependency list
 I      expand include table with directory name following
 m      generate file.o: file1.h format dependency lines
index 20e28fb..e8a9af8 100644 (file)
@@ -19,6 +19,7 @@
 #include       "align.h"
 #include       "use_tmp.h"
 #include       "dataflow.h"
+#include       "dbsymtab.h"
 
 #ifndef NOPP
 extern char **inctable;
@@ -76,6 +77,12 @@ next_option:                 /* to allow combined one-char options */
                break;
 #endif NOPP
 #endif LINT
+#ifdef DBSYMTAB
+       case 'g':       /* symbol table for debugger */
+               options['g'] = 1;
+               options['n'] = 1;
+               break;
+#endif /* DBSYMTAB */
 
 #ifndef        LINT
 #ifdef DATAFLOW
@@ -150,7 +157,7 @@ deleted, is now a debug-flag
                        break;
                }
 
-               macro_def(str2idf(name), mactext, -1, maclen, NOFLAG);
+               macro_def(str2idf(name), mactext, -1, (int)maclen, NOFLAG);
 #else NOPP
                warning("-D option ignored");
 #endif NOPP
@@ -176,7 +183,8 @@ deleted, is now a debug-flag
                        
                        if (++inc_total > inc_max) {
                                inctable = (char **)
-                                  Realloc(inctable,(inc_max+=10)*sizeof(char *));
+                                  Realloc((char *)inctable,
+                                          (unsigned)((inc_max+=10)*sizeof(char *)));
                        }
                                
                        for (i = inc_pos++; i < inc_total ; i++) {
index 8077dad..1849dbc 100644 (file)
@@ -22,7 +22,9 @@ extern struct idf *GetIdentifier();
 
 do_pragma()
 {
+#if    NR_PRAGMAS
        register struct pkey *pkp = &pragmas[0];
+#endif
        register struct idf *id = GetIdentifier(1);
 
        if (id != (struct idf *)0) {
index dc86f11..ce8408e 100644 (file)
@@ -262,7 +262,6 @@ struct repl *repl;
 {
        register struct repl *nrepl = ReplaceList;
        register struct args *ap = nrepl->r_args;
-       struct args *args = repl->r_args;
        register char *p;
 
        /* stash identifier name */
@@ -743,7 +742,7 @@ add2repl(repl, ch)
 
        ASSERT(index < repl->r_size);
        if (index + 2 >= repl->r_size) {
-               repl->r_text = Realloc(repl->r_text, repl->r_size <<= 1);
+               repl->r_text = Realloc(repl->r_text, (unsigned) (repl->r_size <<= 1));
                repl->r_ptr = repl->r_text + index;
        }
        *repl->r_ptr++ = ch;
@@ -768,7 +767,7 @@ stash(repl, ch, stashraw)
                ASSERT(index < args->a_expsize);
                if (index + 1 >= args->a_expsize) {
                        args->a_expbuf = Realloc(args->a_expbuf,
-                                                   args->a_expsize <<= 1);
+                                                   (unsigned) (args->a_expsize <<= 1));
                        args->a_expptr = args->a_expbuf + index;
                }
                *args->a_expptr++ = ch;
@@ -779,7 +778,7 @@ stash(repl, ch, stashraw)
                ASSERT(index < args->a_rawsize);
                if (index + 1 >= args->a_rawsize) {
                        args->a_rawbuf = Realloc(args->a_rawbuf,
-                                                   args->a_rawsize <<= 1);
+                                                   (unsigned)(args->a_rawsize <<= 1));
                        args->a_rawptr = args->a_rawbuf + index;
                }
                *args->a_rawptr++ = ch;
diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c
new file mode 100644 (file)
index 0000000..e208642
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ *
+ * Author: Ceriel J.H. Jacobs
+ */
+
+/* D E B U G G E R   S Y M B O L   T A B L E */
+
+/* $Header$ */
+
+#include       "dbsymtab.h"
+
+#ifdef DBSYMTAB
+
+#include       <alloc.h>
+#include       <em_arith.h>
+#include       <em_label.h>
+#include       <em_code.h>
+#include       <flt_arith.h>
+#include       <stb.h>
+
+#include       "LLlex.h"
+#include       "stack.h"
+#include       "def.h"
+#include       "type.h"
+#include       "struct.h"
+#include       "field.h"
+#include       "idf.h"
+#include       "Lpars.h"
+#include       "level.h"
+
+extern long    full_mask[];
+extern char    *sprint();
+
+#define INCR_SIZE      64
+
+static struct db_str {
+       unsigned        sz;
+       char            *base;
+       char            *currpos;
+} db_str;
+
+static
+create_db_str()
+{
+       if (! db_str.base) {
+               db_str.base = Malloc(INCR_SIZE);
+               db_str.sz = INCR_SIZE;
+       }
+       db_str.currpos = db_str.base;
+}
+
+static
+addc_db_str(c)
+       int     c;
+{
+       int df = db_str.currpos - db_str.base;
+       if (df >= db_str.sz-1) {
+               db_str.sz += INCR_SIZE;
+               db_str.base = Realloc(db_str.base, db_str.sz);
+               db_str.currpos = db_str.base + df;
+       }
+       *db_str.currpos++ = c;
+       *db_str.currpos = '\0';
+}
+
+static
+adds_db_str(s)
+       char    *s;
+{
+       while (*s) addc_db_str(*s++);
+}
+
+static
+stb_type(tp, assign_num)
+       register struct type    *tp;
+{
+       char            buf[128];
+       static int      stb_count;
+       long            l;
+
+       if (tp->tp_dbindex > 0) {
+               adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
+               return;
+       }
+       if (tp->tp_dbindex == 0 && assign_num) {
+               tp->tp_dbindex = ++stb_count;
+       }
+       if (tp->tp_dbindex > 0) {
+               adds_db_str(sprint(buf, "%d=", tp->tp_dbindex));
+       }
+       if (tp == void_type) {
+               adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
+               return;
+       }
+       switch(tp->tp_fund) {
+       /* simple types ... */
+       case INT:
+       case LONG:
+       case CHAR:
+       case SHORT:
+                l = full_mask[(int)tp->tp_size];
+               if (tp->tp_unsigned) {
+                       adds_db_str(sprint(buf,
+                               "r%d;0;%ld",
+                               tp->tp_dbindex,
+                               l));
+               }
+               else {
+                       l &= ~ (1L << ((int)tp->tp_size * 8 - 1));
+                       adds_db_str(sprint(buf,
+                               "r%d;%ld;%ld",
+                               tp->tp_dbindex,
+                               -l-1,
+                               l));
+               }
+               break;
+       case FLOAT:
+       case DOUBLE:
+       case LNGDBL:
+               adds_db_str(sprint(buf,
+                      "r%d;%ld;0",
+                      tp->tp_dbindex,
+                      (long)tp->tp_size));
+               break;
+
+       /* constructed types ... */
+       case POINTER:
+               addc_db_str('*');
+               stb_type(tp->tp_up, 0);
+               break;
+       case ARRAY:
+               if (tp->tp_size > 0) {
+                       adds_db_str("ar");
+                       stb_type(int_type, 0);
+                       adds_db_str(sprint(buf, ";0;%ld;", tp->tp_size / tp->tp_up->tp_size));
+                       stb_type(tp->tp_up, 0);
+               }
+               break;
+       case ENUM:
+               if (tp->tp_size < 0) {
+                       adds_db_str(sprint(buf,
+                                          "xe%s:",
+                                          tp->tp_idf->id_text));
+                       break;
+               }
+               addc_db_str('e');
+               {
+                       register struct stack_entry *se = local_level->sl_entry;
+
+                       while (se) {
+                               register struct def     *edef = se->se_idf->id_def;
+                               while (edef) {
+                                       if (edef->df_type == tp &&
+                                           edef->df_sc == ENUM) {
+                                               adds_db_str(sprint(buf,
+                                                       "%s:%ld,",
+                                                       se->se_idf->id_text,
+                                                       edef->df_address));
+                                       }
+                                       edef = edef->next;
+                               }
+                               se = se->next;
+                       }
+               }
+               addc_db_str(';');
+               break;
+       case STRUCT:
+       case UNION:
+               if (tp->tp_size < 0) {
+                       adds_db_str(sprint(buf,
+                                          "x%c%s:",
+                                          tp->tp_fund == STRUCT ? 's' : 'u',
+                                          tp->tp_idf->id_text));
+                       break;
+               }
+               adds_db_str(sprint(buf,
+                                  "%c%ld",
+                                  tp->tp_fund == STRUCT ? 's' : 'u',
+                                  tp->tp_size));
+               {
+                       register struct sdef    *sdef = tp->tp_sdef;
+
+                       while (sdef) {
+                               adds_db_str(sdef->sd_idf->id_text);
+                               addc_db_str(':');
+                               if (sdef->sd_type->tp_fund == FIELD) {
+                                       stb_type(sdef->sd_type->tp_up, 0);
+                                       adds_db_str(sprint(buf,
+                                               ",%ld,%ld;",
+                                               sdef->sd_offset*8+sdef->sd_type->tp_field->fd_shift,
+                                               sdef->sd_type->tp_field->fd_width));
+                               }
+                               else {
+                                       stb_type(sdef->sd_type, 0);
+                                       adds_db_str(sprint(buf,
+                                               ",%ld,%ld;",
+                                               sdef->sd_offset*8,
+                                               sdef->sd_type->tp_size*8));
+                               }
+                               sdef = sdef->sd_sdef;
+                       }
+               }
+               addc_db_str(';');
+               break;
+       case FUNCTION:
+               addc_db_str('f');
+               stb_type(tp->tp_up, 0);
+       }
+}
+
+stb_tag(tg, str)
+       register struct tag     *tg;
+       char                    *str;
+{
+       create_db_str();
+       adds_db_str(str);
+       adds_db_str(":T");
+       stb_type(tg->tg_type, 1);
+       addc_db_str(';');
+       C_ms_stb_cst(db_str.base,
+                    N_LSYM,
+                    tg->tg_type == void_type || tg->tg_type->tp_size >= 32767
+                      ? 0
+                      : (int)tg->tg_type->tp_size,
+                    (arith) 0);
+}
+
+stb_typedef(tp, str)
+       register struct type    *tp;
+       char                    *str;
+{
+       create_db_str();
+       adds_db_str(str);
+       adds_db_str(":t");
+       stb_type(tp, 1);
+       addc_db_str(';');
+       C_ms_stb_cst(db_str.base,
+                    N_LSYM,
+                    tp == void_type || tp->tp_size >= 32767
+                      ? 0
+                      : (int)tp->tp_size,
+                    (arith) 0);
+}
+
+stb_string(df, kind, str)
+       register struct def     *df;
+       char                    *str;
+{
+       register struct type    *tp = df->df_type;
+
+       create_db_str();
+       adds_db_str(str);
+       addc_db_str(':');
+       switch(kind) {
+       case FUNCTION:
+               addc_db_str(df->df_sc == STATIC ? 'f' : 'F');
+               stb_type(tp->tp_up, 0);
+               addc_db_str(';');
+               C_ms_stb_pnam(db_str.base, N_FUN, 1 /* proclevel */, str);
+               break;
+       default:
+               if (df->df_sc == FORMAL ||
+                   (df->df_sc == REGISTER && df->df_address >= 0)) {
+                                               /* value parameter */
+                       addc_db_str('p');
+                       stb_type(tp, 0);
+                       addc_db_str(';');
+                       C_ms_stb_cst(db_str.base, N_PSYM, 0, df->df_address);
+               }
+               else if (df->df_sc != AUTO && df->df_sc != REGISTER) {
+                                               /* global */
+                       if (df->df_sc == STATIC) {
+                               if (df->df_level == L_LOCAL) {
+                                       addc_db_str('V');
+                               }
+                               else {
+                                       addc_db_str('S');
+                               }
+                       }
+                       else {
+                               addc_db_str('G');
+                       }
+                       stb_type(tp, 0);
+                       addc_db_str(';');
+                       C_ms_stb_dnam(db_str.base, N_LCSYM, 0, str, (arith) 0);
+               }
+               else {  /* local variable */
+                       stb_type(tp, 1);        /* assign type num to avoid
+                                                  difficult to parse string */
+                       addc_db_str(';');
+                       C_ms_stb_cst(db_str.base, N_LSYM, 0, df->df_address);
+               }
+               break;
+       }
+}
+
+#endif DBSYMTAB
index 03f4bc6..ecdb747 100644 (file)
@@ -6,11 +6,12 @@
 /*     STATEMENT SYNTAX PARSER */
 
 {
-#include       <em.h>
+#include       <em_code.h>
 
 #include       "lint.h"
 #include       "debug.h"
 #include       "botch_free.h"
+#include       "dbsymtab.h"
 
 #include       <flt_arith.h>
 #include       "arith.h"
 #include       "l_lint.h"
 #include       "l_state.h"
 #endif LINT
+#ifdef DBSYMTAB
+#include       <stb.h>
+#endif /* DBSYMTAB */
 
 extern int level;
+extern char options[];
 }
 
 /* Each statement construction is stacked in order to trace a
@@ -463,7 +468,14 @@ jump
 ;
 
 /* 3.6.2 */
-compound_statement:
+compound_statement
+       {
+#ifdef DBSYMTAB
+       static int      brc_level = 1;
+       int             ndecl = 0;
+#endif /* DBSYMTAB */
+       }
+:
        '{'
                {
                        stack_level();
@@ -472,12 +484,31 @@ compound_statement:
                 (DOT == IDENTIFIER && AHEAD == IDENTIFIER))
                        /* >>> conflict on TYPE_IDENTIFIER, IDENTIFIER */
                declaration
+               {
+#ifdef DBSYMTAB
+                       ndecl++;
+#endif /* DBSYMTAB */
+               }
        ]*
+               {
+#ifdef DBSYMTAB
+                       ++brc_level;
+                       if (options['g'] && ndecl) {
+                               C_ms_std((char *) 0, N_LBRAC, brc_level);
+                       }
+#endif /* DBSYMTAB */
+               }
        [%persistent
                statement
        ]*
        '}'
                {
                        unstack_level();
+#ifdef DBSYMTAB
+                       if (options['g'] && ndecl) {
+                               C_ms_std((char *) 0, N_RBRAC, brc_level);
+                       }
+                       brc_level--;
+#endif /* DBSYMTAB */
                }
 ;
index ec34be5..2126130 100644 (file)
@@ -6,6 +6,7 @@
 /* TYPE DESCRIPTOR */
 
 #include       "nobitfield.h"
+#include       "dbsymtab.h"
 
 struct type    {
        struct type *next;      /* used for ARRAY and for qualifiers */
@@ -16,6 +17,9 @@ struct type   {
        arith tp_size;          /* -1 if declared but not defined */
        struct type *tp_pointer;        /* to POINTER */
        struct type *tp_array;          /* to ARRAY */
+#ifdef DBSYMTAB
+       int tp_dbindex;
+#endif
 #if 0
 /* This field is not needed now; see comment in function_of() routine. */
        struct type *tp_function;       /* to FUNCTION */