2 * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
8 /* D E B U G G E R S Y M B O L T A B L E */
10 /* $Id: stab.c,v 1.10 1994/06/24 12:36:09 ceriel Exp $ */
35 extern char *sprint();
37 static struct db_str {
47 db_str.base = Malloc(INCR_SIZE);
48 db_str.sz = INCR_SIZE;
50 db_str.currpos = db_str.base;
57 int df = db_str.currpos - db_str.base;
58 if (df >= db_str.sz-1) {
59 db_str.sz += INCR_SIZE;
60 db_str.base = Realloc(db_str.base, db_str.sz);
61 db_str.currpos = db_str.base + df;
63 *db_str.currpos++ = c;
64 *db_str.currpos = '\0';
71 while (*s) addc_db_str(*s++);
75 stb_type(tp, assign_num)
76 register struct type *tp;
81 if (tp->tp_dbindex > 0) {
82 adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
85 if (tp->tp_dbindex < 0) {
87 adds_db_str(sprint(buf, "%d", -tp->tp_dbindex));
90 tp->tp_dbindex = -tp->tp_dbindex;
92 if (tp->tp_dbindex == 0 && assign_num) {
93 tp->tp_dbindex = ++stb_count;
95 if (tp->tp_dbindex > 0) {
96 adds_db_str(sprint(buf, "%d=", tp->tp_dbindex));
98 if (tp == void_type) {
99 adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
102 switch(tp->tp_fund) {
103 /* simple types ... */
106 arith l = full_mask[(int)tp->tp_size] & ~(1L << (tp->tp_size*8-1));
107 adds_db_str(sprint(buf,
115 adds_db_str(sprint(buf,
121 adds_db_str(sprint(buf,
126 /* constructed types ... */
128 adds_db_str(sprint(buf,
130 tp->next->tp_dbindex,
137 stb_type(tp->next, 0);
138 if (tp->tp_dbindex < 0) tp->tp_dbindex = -tp->tp_dbindex;
141 tp->tp_dbindex = - ++stb_count;
142 adds_db_str(sprint(buf, "%d", -tp->tp_dbindex));
147 stb_type(tp->next, 0);
148 adds_db_str(sprint(buf, ";%ld;%ld;", (long) tp->tp_size, 0L));
152 if (IsConformantArray(tp)) {
154 stb_type(tp->next, 0);
155 adds_db_str(sprint(buf, ";A%ld;Z%ld", (long) tp->arr_cfdescr, (long) tp->arr_cfdescr));
158 stb_type(tp->next, 0);
161 stb_type(tp->arr_elem, 0);
166 register struct def *edef = tp->enm_enums;
169 adds_db_str(sprint(buf, "%s:%ld,",
170 edef->df_idf->id_text,
171 (long) edef->enm_val));
172 edef = edef->enm_next;
178 adds_db_str(sprint(buf, "s%ld", (long) tp->tp_size));
180 register struct def *sdef = tp->rec_scope->sc_def;
183 adds_db_str(sdef->df_idf->id_text);
185 stb_type(sdef->df_type, 0);
186 adds_db_str(sprint(buf,
189 sdef->df_type->tp_size*8L));
190 sdef = sdef->df_nextinscope;
198 stb_type(tp->next ? tp->next : void_type, 0);
200 register struct paramlist *p = tp->prc_params;
207 adds_db_str(sprint(buf, ",%d;", paramcount));
210 addc_db_str(IsVarParam(p)
212 : IsConformantArray(TypeOfParam(p))
215 stb_type(TypeOfParam(p), 0);
223 stb_type(tp->next, 0);
227 stb_type(char_type, 0);
242 C_ms_stb_cst(db_str.base,
244 tp == void_type || tp->tp_size > 32767
246 : (IsPacked(tp) ? (int) tp->tp_psize : (int)tp->tp_size),
251 register struct def *df;
254 register struct type *tp = df->df_type;
258 adds_db_str(df->df_idf->id_text);
260 if (kind == D_MODULE) {
261 adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count));
262 C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "_m_a_i_n");
268 adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count));
269 stb_type(tp->next ? tp->next : void_type, 0);
271 C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->df_idf->id_text);
273 register struct paramlist *p = tp->prc_params;
275 stb_string(p->par_def, D_VARIABLE);
279 for (df = df->prc_vis->sc_scope->sc_def; df; df = df->df_nextinscope) {
280 if (df->df_kind == D_LBOUND ||
281 df->df_kind == D_UBOUND) {
282 stb_string(df, df->df_kind);
288 adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count));
289 C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0);
292 if (df->df_flags & D_VARPAR) { /* VAR parameter */
296 C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off);
298 else if (df->df_flags & D_VALPAR) { /* value parameter */
299 addc_db_str(IsConformantArray(tp)
304 C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off);
306 else if (!proclevel) {
310 C_ms_stb_dnam(db_str.base, N_LCSYM, 0, df->var_name, (arith) 0);
312 else { /* local variable */
313 stb_type(tp, 1); /* assign type num to avoid
314 difficult to parse string */
316 C_ms_stb_cst(db_str.base, N_LSYM, 0, df->var_off);
321 addc_db_str(kind == D_LBOUND ? 'A' : 'Z');
325 C_ms_stb_cst(db_str.base, N_PSYM, 0, df->bnd_type->arr_cfdescr);
331 C_ms_stb_cst(db_str.base,
333 tp == void_type || tp->tp_size > 32767
335 : (IsPacked(tp) ? (int) tp->tp_psize : (int)tp->tp_size),
342 switch(tp->tp_fund) {
347 adds_db_str(sprint(buf, "i%ld;", (long) df->con_const->nd_INT));
350 adds_db_str(sprint(buf, "c%ld;", (long) df->con_const->nd_INT));
354 adds_db_str(df->con_const->nd_REL);
357 case T_STRINGCONST: {
358 register char *p = df->con_const->nd_STR;
362 if (*p == '\'' || *p == '\\') {
373 adds_db_str(sprint(buf, ",%ld;", (long) df->con_const->nd_INT));
380 for (i = 0; i < tp->tp_size; i++) {
381 adds_db_str(sprint(buf, ",%ld",
382 (long) (df->con_const->nd_set[i/(int) word_size] >> (8*(i%(int)word_size)))&0377));
388 C_ms_stb_cst(db_str.base,
390 tp->tp_size <= 32767 ? (int)tp->tp_size : 0,
396 #endif /* DBSYMTAB */