sizes.h
skip.c
specials.h
+stab.c
stack.c
stack.str
statement.g
#undef REGCOUNT 1 /* count occurrences for register messages */
+!File: dbsymtab.h
+#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
+
+
#undef REGCOUNT 1 /* count occurrences for register messages */
+!File: dbsymtab.h
+#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */
+
+
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 \
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
#undef REGCOUNT 1 /* count occurrences for register messages */
+!File: dbsymtab.h
+#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */
+
+
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
#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"
#ifdef LINT
#include "l_lint.h"
#endif LINT
+#ifdef DBSYMTAB
+#include <stb.h>
+#endif /* DBSYMTAB */
label lab_count = 1;
label datlab_count = 1;
extern char options[];
extern char *symbol2str();
+extern char *source;
#ifndef LINT
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());
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;
}
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)
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)
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);
}
}
/* 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 */
}
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)
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; */
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}; */
store_val(&vl, tp);
}
#else LINT
- id->id_def->df_set = 1;
+ df->df_set = 1;
#endif LINT
free_expression(expr);
}
{
/* 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)
#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
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
{
#include "lint.h"
+#include "dbsymtab.h"
#include <alloc.h>
#include "nobitfield.h"
#include "debug.h"
#include "l_lint.h"
#include "l_state.h"
#endif LINT
+
+extern char options[];
}
/* 3.5 */
[
{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 */
struct_declaration_pack(*tpp)
{
(idf->id_struct->tg_busy)--;
+#ifdef DBSYMTAB
+ if (options['g']) {
+ stb_tag(idf->id_struct, idf->id_text);
+ }
+#endif /*DBSYMTAB */
}
|
{
*/
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;
}
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;
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 */
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
#include "align.h"
#include "use_tmp.h"
#include "dataflow.h"
+#include "dbsymtab.h"
#ifndef NOPP
extern char **inctable;
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
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
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++) {
do_pragma()
{
+#if NR_PRAGMAS
register struct pkey *pkp = &pragmas[0];
+#endif
register struct idf *id = GetIdentifier(1);
if (id != (struct idf *)0) {
{
register struct repl *nrepl = ReplaceList;
register struct args *ap = nrepl->r_args;
- struct args *args = repl->r_args;
register char *p;
/* stash identifier name */
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;
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;
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;
--- /dev/null
+/*
+ * (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
/* 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
;
/* 3.6.2 */
-compound_statement:
+compound_statement
+ {
+#ifdef DBSYMTAB
+ static int brc_level = 1;
+ int ndecl = 0;
+#endif /* DBSYMTAB */
+ }
+:
'{'
{
stack_level();
(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 */
}
;
/* TYPE DESCRIPTOR */
#include "nobitfield.h"
+#include "dbsymtab.h"
struct type {
struct type *next; /* used for ARRAY and for qualifiers */
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 */