Added grind support
This commit is contained in:
parent
97a7fcbca3
commit
3015fc2542
|
@ -98,3 +98,4 @@ type.c
|
|||
type.str
|
||||
util.str
|
||||
util.c
|
||||
stab.c
|
||||
|
|
|
@ -143,4 +143,8 @@
|
|||
!File: regcount.h
|
||||
#undef REGCOUNT 1 /* count occurrences for register messages */
|
||||
|
||||
!File: dbsymtab.h
|
||||
#define DBSYMTAB 1 /* ability to produce symbol table for debugger
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -144,3 +144,8 @@
|
|||
#undef REGCOUNT 1 /* count occurrences for register messages */
|
||||
|
||||
|
||||
!File: dbsymtab.h
|
||||
#undef DBSYMTAB 1 /* ability to produce symbol table for debugger
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
/* C O D E - G E N E R A T I N G R O U T I N E S */
|
||||
|
||||
#include "lint.h"
|
||||
#include "dbsymtab.h"
|
||||
#ifndef LINT
|
||||
#include <em.h>
|
||||
#else
|
||||
|
@ -34,7 +35,10 @@
|
|||
#include "atw.h"
|
||||
#include "assert.h"
|
||||
#include "noRoption.h"
|
||||
#include "file_info.h"
|
||||
#include "LLlex.h"
|
||||
#ifdef DBSYMTAB
|
||||
#include <stb.h>
|
||||
#endif /* DBSYMTAB */
|
||||
|
||||
label lab_count = 1;
|
||||
label datlab_count = 1;
|
||||
|
@ -68,6 +72,24 @@ 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']) {
|
||||
extern char *source;
|
||||
|
||||
C_ms_std(source, N_SO, 0);
|
||||
stb_typedef(int_type, "int");
|
||||
stb_typedef(char_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(void_type, "void");
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
#ifdef USE_TMP
|
||||
#ifdef PREPEND_SCOPES
|
||||
C_insertpart(tmp_id = C_getid());
|
||||
|
@ -257,6 +279,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)
|
||||
|
@ -339,6 +369,9 @@ do_return()
|
|||
probably smarter than generating a direct return.
|
||||
Return sequences may be expensive.
|
||||
*/
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g']) db_line(dot.tk_file, dot.tk_line);
|
||||
#endif /* DBSYMTAB */
|
||||
C_bra(return2_label);
|
||||
}
|
||||
|
||||
|
@ -387,8 +420,14 @@ code_declaration(idf, expr, lvl, sc)
|
|||
register arith size = def->df_type->tp_size;
|
||||
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 (sc == EXTERN && expr && !is_anon_idf(idf))
|
||||
error("%s is extern; cannot initialize", idf->id_text);
|
||||
if (lvl == L_GLOBAL) { /* global variable */
|
||||
|
@ -418,6 +457,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'] && ! expr) {
|
||||
stb_string(def, sc, idf->id_text);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
C_df_dlb((label)def->df_address);
|
||||
if (expr) { /* there is an initialisation */
|
||||
}
|
||||
|
@ -436,6 +480,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);
|
||||
break;
|
||||
|
@ -511,6 +560,11 @@ bss(idf)
|
|||
#ifndef PREPEND_SCOPES
|
||||
code_scope(idf->id_text, idf->id_def);
|
||||
#endif PREPEND_SCOPES
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g']) {
|
||||
stb_string(idf->id_def, idf->id_def->df_sc, idf->id_text);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
/* Since bss() is only called if df_alloc is non-zero, and
|
||||
since df_alloc is only non-zero if size >= 0, we have:
|
||||
*/
|
||||
|
@ -558,6 +612,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, (unsigned int)expr->ex_line);
|
||||
#endif
|
||||
EVAL(expr, val, code, tlbl, flbl);
|
||||
#else LINT
|
||||
lint_expr(expr, code ? USED : IGNORED);
|
||||
|
@ -583,6 +640,9 @@ code_break()
|
|||
{
|
||||
register struct stmt_block *stmt_block = stmt_stack;
|
||||
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g']) db_line(dot.tk_file, dot.tk_line);
|
||||
#endif /* DBSYMTAB */
|
||||
if (stmt_block)
|
||||
C_bra(stmt_block->st_break);
|
||||
else
|
||||
|
@ -600,6 +660,9 @@ code_continue()
|
|||
|
||||
while (stmt_block) {
|
||||
if (stmt_block->st_continue) {
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g']) db_line(dot.tk_file, dot.tk_line);
|
||||
#endif /* DBSYMTAB */
|
||||
C_bra(stmt_block->st_continue);
|
||||
return;
|
||||
}
|
||||
|
@ -651,3 +714,19 @@ prc_exit()
|
|||
C_asp(pointer_size);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DBSYMTAB
|
||||
db_line(file, line)
|
||||
char *file;
|
||||
unsigned int line;
|
||||
{
|
||||
static unsigned oldline;
|
||||
static char *oldfile;
|
||||
|
||||
if (file != oldfile || line != oldline) {
|
||||
C_ms_std((char *) 0, N_SLINE, (int) line);
|
||||
oldline = line;
|
||||
oldfile = file;
|
||||
}
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
{
|
||||
#include "lint.h"
|
||||
#include "dbsymtab.h"
|
||||
#include <alloc.h>
|
||||
#include "nobitfield.h"
|
||||
#include "debug.h"
|
||||
|
@ -223,8 +224,19 @@ initializer(struct idf *idf; int sc;)
|
|||
#ifdef LINT
|
||||
change_state(idf, SET);
|
||||
#endif LINT
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g'] && level >= L_LOCAL && expr) {
|
||||
db_line(expr->ex_file, (unsigned) expr->ex_line)
|
||||
;
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
code_declaration(idf, expr, level, sc);
|
||||
}
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g'] && globalflag) {
|
||||
stb_string(idf->id_def, sc, idf->id_text);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
init_idf(idf);
|
||||
}
|
||||
;
|
||||
|
@ -318,6 +330,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
|
||||
|
@ -383,6 +402,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 */
|
||||
}
|
||||
|
|
||||
{apply_struct(fund, idf, tpp);}
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
#include <alloc.h>
|
||||
#include "class.h"
|
||||
#include "macro.h"
|
||||
#include "dbsymtab.h"
|
||||
#ifdef DBSYMTAB
|
||||
#include <stb.h>
|
||||
int IncludeLevel = 0;
|
||||
extern char options[];
|
||||
#endif
|
||||
|
||||
IMPORT char **inctable; /* list of include directories */
|
||||
IMPORT char *getwdir();
|
||||
|
@ -269,6 +275,12 @@ do_include()
|
|||
FileName = result;
|
||||
LineNumber = 0;
|
||||
nestlow = nestlevel;
|
||||
#ifdef DBSYMTAB
|
||||
IncludeLevel++;
|
||||
if (options['g']) {
|
||||
C_ms_std(FileName, N_BINCL, 0);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -638,11 +638,16 @@ declare_formals(fp)
|
|||
*/
|
||||
f_offset = align(f_offset + def->df_type->tp_size, (int) word_size);
|
||||
formal_cvt(def); /* cvt int to char or short, if necessary */
|
||||
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);
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g']) {
|
||||
stb_string(def, FORMAL, se->se_idf->id_text);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
se = se->next;
|
||||
}
|
||||
*fp = f_offset;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,13 @@ extern int nestlevel;
|
|||
#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;
|
||||
|
@ -64,6 +70,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
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -265,6 +265,10 @@ compile(argc, argv)
|
|||
init();
|
||||
LineNumber = 0;
|
||||
nestlow = -1;
|
||||
#ifndef LINT
|
||||
init_code(destination && strcmp(destination, "-") != 0 ?
|
||||
destination : 0);
|
||||
#endif
|
||||
#ifndef NOPP
|
||||
WorkingDir = getwdir(source);
|
||||
#endif NOPP
|
||||
|
@ -279,8 +283,6 @@ compile(argc, argv)
|
|||
#endif DEBUG
|
||||
{
|
||||
#ifndef LINT
|
||||
init_code(destination && strcmp(destination, "-") != 0 ?
|
||||
destination : 0);
|
||||
/* compile the source text */
|
||||
C_program();
|
||||
#ifdef PREPEND_SCOPES
|
||||
|
|
|
@ -4,12 +4,13 @@ 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
|
||||
L don't generate linenumbers and filename indications
|
||||
m generate file.o: file1.h format dependency lines
|
||||
M set identifier length
|
||||
n don't generate register messages
|
||||
L don't generate linenumbers and filename indications
|
||||
p trace
|
||||
P in running the preprocessor do not output '# line' lines
|
||||
R restricted C
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "use_tmp.h"
|
||||
#include "dataflow.h"
|
||||
#include "noRoption.h"
|
||||
#include "dbsymtab.h"
|
||||
|
||||
#ifndef NOPP
|
||||
extern char **inctable;
|
||||
|
@ -103,6 +104,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 */
|
||||
|
||||
case 'R': /* strict version */
|
||||
#ifndef NOROPTION
|
||||
|
|
|
@ -61,7 +61,9 @@ SRC_C = \
|
|||
$(SRC_DIR)/switch.c \
|
||||
$(SRC_DIR)/tokenname.c \
|
||||
$(SRC_DIR)/type.c \
|
||||
$(SRC_DIR)/util.c
|
||||
$(SRC_DIR)/util.c \
|
||||
$(SRC_DIR)/stab.c
|
||||
|
||||
GEN_C = tokenfile.c program.c declar.c expression.c statement.c ival.c \
|
||||
symbol2str.c char.c Lpars.c next.c
|
||||
CFILES= $(SRC_C) $(GEN_C)
|
||||
|
@ -96,7 +98,7 @@ GEN_H = botch_free.h dataflow.h debug.h density.h errout.h \
|
|||
regcount.h \
|
||||
code.h declar.h decspecs.h def.h expr.h field.h estack.h util.h \
|
||||
idf.h macro.h stmt.h struct.h switch.h type.h l_brace.h l_state.h \
|
||||
l_outdef.h stack.h lapbuf.h noRoption.h nofloat.h
|
||||
l_outdef.h stack.h lapbuf.h noRoption.h nofloat.h dbsymtab.h
|
||||
|
||||
HFILES= $(GEN_H) $(SRC_H)
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "debug.h"
|
||||
#include "botch_free.h"
|
||||
#include "dbsymtab.h"
|
||||
|
||||
#include "arith.h"
|
||||
#include "LLlex.h"
|
||||
|
@ -26,8 +27,12 @@
|
|||
#include "code.h"
|
||||
#include "stack.h"
|
||||
#include "def.h"
|
||||
#ifdef DBSYMTAB
|
||||
#include <stb.h>
|
||||
#endif /* DBSYMTAB */
|
||||
|
||||
extern int level;
|
||||
extern char options[];
|
||||
}
|
||||
|
||||
/* Each statement construction is stacked in order to trace a ???
|
||||
|
@ -451,7 +456,14 @@ jump
|
|||
}
|
||||
;
|
||||
|
||||
compound_statement:
|
||||
compound_statement
|
||||
{
|
||||
#ifdef DBSYMTAB
|
||||
static int brc_level = 1;
|
||||
int decl_seen = brc_level == 1;
|
||||
#endif /* DBSYMTAB */
|
||||
}
|
||||
:
|
||||
'{'
|
||||
{
|
||||
stack_level();
|
||||
|
@ -460,13 +472,32 @@ compound_statement:
|
|||
(DOT == IDENTIFIER && AHEAD == IDENTIFIER))
|
||||
/* >>> conflict on TYPE_IDENTIFIER, IDENTIFIER */
|
||||
declaration
|
||||
{
|
||||
#ifdef DBSYMTAB
|
||||
decl_seen++;
|
||||
#endif /* DBSYMTAB */
|
||||
}
|
||||
]*
|
||||
{
|
||||
#ifdef DBSYMTAB
|
||||
++brc_level;
|
||||
if (options['g'] && decl_seen) {
|
||||
C_ms_std((char *) 0, N_LBRAC, brc_level);
|
||||
}
|
||||
#endif /* DBSYMTAB */
|
||||
}
|
||||
[%persistent
|
||||
statement
|
||||
]*
|
||||
'}'
|
||||
{
|
||||
unstack_level();
|
||||
#ifdef DBSYMTAB
|
||||
if (options['g'] && decl_seen) {
|
||||
C_ms_std((char *) 0, N_RBRAC, brc_level);
|
||||
}
|
||||
brc_level--;
|
||||
#endif /* DBSYMTAB */
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "nofloat.h"
|
||||
#include "nobitfield.h"
|
||||
#include "dbsymtab.h"
|
||||
|
||||
struct type {
|
||||
struct type *next; /* used only with ARRAY */
|
||||
|
@ -22,6 +23,9 @@ struct type {
|
|||
struct type *tp_pointer;/* to POINTER */
|
||||
struct type *tp_array; /* to ARRAY */
|
||||
struct type *tp_function;/* to FUNCTION */
|
||||
#ifdef DBSYMTAB
|
||||
int tp_dbindex;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern struct type
|
||||
|
|
Loading…
Reference in a new issue