fixed bug with undefined structs

ceriel changed debugging information
This commit is contained in:
eck 1990-10-19 11:50:32 +00:00
parent c3f305bea1
commit b4f97588b7
6 changed files with 66 additions and 44 deletions

View file

@ -26,6 +26,11 @@
#include "macro.h"
#include "macbuf.h"
#include "replace.h"
#include "dbsymtab.h"
#ifdef DBSYMTAB
#include <stb.h>
int IncludeLevel = 0;
#endif
extern char options[];
extern char **inctable; /* list of include directories */
@ -313,6 +318,12 @@ do_include()
FileName = result;
LineNumber = 0;
nestlow = nestlevel;
#ifdef DBSYMTAB
IncludeLevel++;
if (options['g']) {
C_ms_std(FileName, N_BINCL, 0);
}
#endif /* DBSYMTAB */
}
}
}
@ -777,24 +788,14 @@ do_line(l)
{
struct token tk;
int t = GetToken(&tk);
static char *saved_name = (char *)0;
if (t != EOI) SkipToNewLine();
LineNumber = l; /* the number of the next input line */
if (t == STRING) { /* is there a filespecifier? */
extern char *source; /* defined in main.c */
if (FileName != source) { /* source points into argv */
/* Since we are looking one token ahead, we can't
* free the string when it is mentioned in dot.
*/
if (dot.tok_file != FileName) {
free(FileName);
} else if (dot.tok_file != saved_name) {
if (saved_name) free(saved_name);
saved_name = dot.tok_file;
}
}
/*
* Do not attempt to free the old string, since it might
* be used in a def structure.
*/
FileName = tk.tk_bts;
}
}

View file

@ -205,10 +205,11 @@ declare_idf(ds, dc, lvl)
but it has to be:
*/
extern char *symbol2str();
if (type->tp_fund != VOID)
if (type->tp_fund != VOID) {
if (level != L_GLOBAL)
error("unknown %s-type",
symbol2str(type->tp_fund));
else error("void is not a complete type");
} else error("void is not a complete type");
}
else if (type->tp_fund != LABEL) {
/* CJ */

View file

@ -15,7 +15,14 @@ struct file_info finfo;
#include "nopp.h"
#include <inp_pkg.body>
#include "dbsymtab.h"
#ifndef NOPP
#ifdef DBSYMTAB
#include <stb.h>
extern int IncludeLevel;
extern char options[];
#endif
char *
getwdir(fn)
register char *fn;
@ -65,6 +72,12 @@ AtEoIF()
if (NoUnstack) lexerror("unexpected EOF");
#ifndef NOPP
nestlevel = nestlow;
#ifdef DBSYMTAB
if (options['g'] && IncludeLevel > 0) {
C_ms_std(FileName, N_EINCL, 0);
}
IncludeLevel--;
#endif
#endif /* NOPP */
return 0;
}

View file

@ -161,6 +161,7 @@ gen_simple_exp(tpp, expp)
check_and_pad(expp, tpp);
break;
case ERRONEOUS:
case FUNCTION:
case VOID:
gen_error = pack_level;
break;

View file

@ -177,7 +177,7 @@ add_dependency(s)
char *s;
{
register struct idf *p = str2idf(s);
if (! p->id_resmac) {
p->id_resmac = K_FILE;
p->id_file = (char *) file_head;
@ -269,6 +269,14 @@ compile(argc, argv)
init();
LineNumber = 0;
nestlow = -1;
#ifndef LINT
init_code(destination
&& strcmp(destination, "-") != 0
? destination
: 0);
#endif LINT
#ifndef NOPP
WorkingDir = getwdir(source);
PushLex(); /* initialize lex machine */
@ -284,11 +292,6 @@ compile(argc, argv)
#endif NOPP
#endif DEBUG
{
#ifndef LINT
init_code(destination && strcmp(destination, "-") != 0 ?
destination : 0);
#endif LINT
/* compile the source text */
C_program();
@ -380,7 +383,7 @@ init_specials(si)
{
while (si->si_identifier) {
struct idf *idf = str2idf(si->si_identifier);
if (idf->id_special)
fatal("maximum identifier length insufficient");
idf->id_special = si->si_flag;

View file

@ -73,7 +73,7 @@ adds_db_str(s)
}
static
stb_type(tp, assign_num)
stb_type(tp)
register struct type *tp;
{
char buf[128];
@ -84,18 +84,19 @@ stb_type(tp, assign_num)
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));
if (tp->tp_dbindex < 0 && tp->tp_size < 0) {
adds_db_str(sprint(buf, "%d", -tp->tp_dbindex));
return;
}
if (tp->tp_dbindex <= 0) {
tp->tp_dbindex = ++stb_count;
}
adds_db_str(sprint(buf, "%d=", tp->tp_dbindex));
switch(tp->tp_fund) {
/* simple types ... */
case VOID:
adds_db_str(sprint(buf, "%d", void_type->tp_dbindex));
break;
case INT:
case LONG:
case CHAR:
@ -128,14 +129,14 @@ stb_type(tp, assign_num)
/* constructed types ... */
case POINTER:
addc_db_str('*');
stb_type(tp->tp_up, 0);
stb_type(tp->tp_up);
break;
case ARRAY:
if (tp->tp_size > 0) {
adds_db_str("ar");
stb_type(int_type, 0);
stb_type(int_type);
adds_db_str(sprint(buf, ";0;%ld;", tp->tp_size / tp->tp_up->tp_size - 1));
stb_type(tp->tp_up, 0);
stb_type(tp->tp_up);
}
break;
case ENUM:
@ -143,6 +144,7 @@ stb_type(tp, assign_num)
adds_db_str(sprint(buf,
"xe%s:",
tp->tp_idf->id_text));
tp->tp_dbindex = -tp->tp_dbindex;
break;
}
addc_db_str('e');
@ -173,6 +175,7 @@ stb_type(tp, assign_num)
"x%c%s:",
tp->tp_fund == STRUCT ? 's' : 'u',
tp->tp_idf->id_text));
tp->tp_dbindex = -tp->tp_dbindex;
break;
}
adds_db_str(sprint(buf,
@ -186,14 +189,14 @@ stb_type(tp, assign_num)
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);
stb_type(sdef->sd_type->tp_up);
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);
stb_type(sdef->sd_type);
adds_db_str(sprint(buf,
",%ld,%ld;",
sdef->sd_offset*8,
@ -206,7 +209,7 @@ stb_type(tp, assign_num)
break;
case FUNCTION:
addc_db_str('f');
stb_type(tp->tp_up, 0);
stb_type(tp->tp_up);
}
}
@ -217,7 +220,7 @@ stb_tag(tg, str)
create_db_str();
adds_db_str(str);
adds_db_str(":T");
stb_type(tg->tg_type, 1);
stb_type(tg->tg_type);
addc_db_str(';');
C_ms_stb_cst(db_str.base,
N_LSYM,
@ -234,7 +237,7 @@ stb_typedef(tp, str)
create_db_str();
adds_db_str(str);
adds_db_str(":t");
stb_type(tp, 1);
stb_type(tp);
addc_db_str(';');
C_ms_stb_cst(db_str.base,
N_LSYM,
@ -256,7 +259,7 @@ stb_string(df, kind, str)
switch(kind) {
case FUNCTION:
addc_db_str(df->df_sc == STATIC ? 'f' : 'F');
stb_type(tp->tp_up, 0);
stb_type(tp->tp_up);
addc_db_str(';');
C_ms_stb_pnam(db_str.base, N_FUN, 1 /* proclevel */, str);
break;
@ -265,7 +268,7 @@ stb_string(df, kind, str)
(df->df_sc == REGISTER && df->df_address >= 0)) {
/* value parameter */
addc_db_str('p');
stb_type(tp, 0);
stb_type(tp);
addc_db_str(';');
C_ms_stb_cst(db_str.base, N_PSYM, 0, df->df_address);
}
@ -282,7 +285,7 @@ stb_string(df, kind, str)
else {
addc_db_str('G');
}
stb_type(tp, 0);
stb_type(tp);
addc_db_str(';');
if (df->df_sc == STATIC && df->df_level >= L_LOCAL) {
C_ms_stb_dlb(db_str.base, N_LCSYM, 0, (label) df->df_address, (arith) 0);
@ -292,7 +295,7 @@ stb_string(df, kind, str)
}
}
else { /* local variable */
stb_type(tp, 1); /* assign type num to avoid
stb_type(tp); /* 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);