Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/installers/680x0/common/xdb_output.c – Rev 6

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1996
33
 
34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
42
 
43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
45
 
46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
49
 
50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
53
 
54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
/*
60
			    VERSION INFORMATION
61
			    ===================
62
 
63
--------------------------------------------------------------------------
64
$Header: /u/g/release/CVSROOT/Source/src/installers/680x0/common/xdb_output.c,v 1.1.1.1 1998/01/17 15:55:50 release Exp $
65
--------------------------------------------------------------------------
66
$Log: xdb_output.c,v $
67
 * Revision 1.1.1.1  1998/01/17  15:55:50  release
68
 * First version to be checked into rolling release.
69
 *
70
Revision 1.1.1.1  1997/10/13 12:43:02  ma
71
First version.
72
 
73
Revision 1.1.1.1  1997/03/14 07:50:23  ma
74
Imported from DRA
75
 
76
 * Revision 1.1.1.1  1996/09/20  10:57:01  john
77
 *
78
 * Revision 1.2  1996/07/05  14:35:40  john
79
 * Fix to diagnostics
80
 *
81
 * Revision 1.1  95/03/08  16:46:25  ra
82
 * Added missing files.
83
 *
84
 * Revision 1.3  94/02/21  16:09:13  16:09:13  ra (Robert Andrews)
85
 * Put in a number of explicit casts.
86
 *
87
 * Revision 1.2  93/04/19  13:39:31  13:39:31  ra (Robert Andrews)
88
 * crt_fname and crt_line_num are no longer static.
89
 *
90
 * Revision 1.1  93/02/22  17:17:25  17:17:25  ra (Robert Andrews)
91
 * Initial revision
92
 *
93
--------------------------------------------------------------------------
94
*/
95
 
96
 
97
#include "config.h"
98
#include "common_types.h"
99
#include "assembler.h"
100
#include "codex.h"
101
#include "exp.h"
102
#include "expmacs.h"
103
#include "instrs.h"
104
#include "mach.h"
105
#include "mach_ins.h"
106
#include "mach_op.h"
107
#include "output.h"
108
#include "tags.h"
109
#include "utility.h"
110
#include "xdb_types.h"
111
#include "xdb_output.h"
112
#include "stab_types.h"
6 7u83 113
extern int diag_override;
2 7u83 114
 
115
 
116
/*
117
    WORK OUT WHETHER TO DO A DYNAMIC TEST FOR DIAGNOSTIC FORMAT
118
*/
119
 
6 7u83 120
#if (default_diag == DIAG_UNKNOWN)
2 7u83 121
#define dynamic_test
6 7u83 122
extern double atof(CONST char *);
2 7u83 123
#include <sys/utsname.h>
124
#else
125
#undef dynamic_test
126
#endif
127
 
128
 
129
/*
130
    WHICH DIAGNOSTIC FORMAT SHOULD BE USED?
131
*/
132
 
6 7u83 133
bool diag_format = default_diag;
2 7u83 134
 
135
 
136
/*
137
    ARRAY OF DIAGNOSTIC DIRECTIVES
138
 
139
    This array gives information on all the available diagnostic directives,
140
    included those which are unused.
141
*/
142
 
6 7u83 143
diag_directive dd[] = {
2 7u83 144
    { m_dd_array, 2, 2 },
145
    { m_dd_begin, 1, 1 },
146
    { m_dd_const, 0, 0 },	/* unknown */
147
    { m_dd_dvar, 2, 2 },
148
    { m_dd_end, 1, 1 },
149
    { m_dd_entry, 0, 0 },	/* unknown */
150
    { m_dd_enum, 1, 1 },
151
    { m_dd_field, 2, 2 },
152
    { m_dd_file, 0, 0 },	/* unknown */
153
    { m_dd_fparam, 2, 2 },
154
    { m_dd_function, 3, 3 },
155
    { m_dd_functype, 2, 2 },
156
    { m_dd_import, 0, 0 },	/* unknown */
157
    { m_dd_label, 0, 0 },	/* unknown */
158
    { m_dd_memenum, 2, 2 },
159
    { m_dd_module, 1, 2 },
160
    { m_dd_pointer, 1, 1 },
161
    { m_dd_set, 0, 0 },		/* unknown */
162
    { m_dd_srcfile, 1, 1 },
163
    { m_dd_struct, 2, 2 },
164
    { m_dd_subrange, 2, 2 },
165
    { m_dd_svar, 2, 2 },
166
    { m_dd_tagdef, 1, 1 },
167
    { m_dd_typedef, 1, 1 },
168
    { m_dd_union, 1, 1 },
169
    { m_dd_variant, 0, 0 }	/* unknown */
6 7u83 170
};
2 7u83 171
 
172
 
173
/*
174
    DIAGNOSTICS FILES
175
 
176
    There are three sections of diagnostic information in the new
177
    diagnostics mode (the vt, lntt and gntt sections).  One temporary
178
    file is used for each.  In the old diagnosics mode there is
179
    only one section (the dntt section), and only one file, diagfp2,
180
    is used.
181
*/
182
 
6 7u83 183
static FILE *diagfp1;
184
static FILE *diagfp2;
185
static FILE *diagfp3;
2 7u83 186
 
187
 
188
/*
189
    INITIALIZE DIAGNOSTICS FILES
190
 
191
    The temporary files are opened, and the headings of the various
192
    sections are printed.
193
*/
194
 
195
void init_diag
6 7u83 196
(void)
2 7u83 197
{
6 7u83 198
    double vs = (diag_format == DIAG_XDB_NEW ? 7.40 : 7.05);
2 7u83 199
 
200
#ifdef dynamic_test
6 7u83 201
    struct utsname u;
202
    char *os = "HP-UX";
203
    uname(&u);
204
    os = u.sysname;
205
    vs = atof(u.release);
206
    if (strcmp(os, "HP-UX") == 0) {
207
	diag_format = (vs >= 7.40 ? DIAG_XDB_NEW : DIAG_XDB_OLD);
2 7u83 208
    } else {
6 7u83 209
	diag_format = DIAG_UNKNOWN;
2 7u83 210
   }
211
#endif
212
 
6 7u83 213
    if (diag_override != DIAG_UNKNOWN) {
214
	diag_format = diag_override;
215
	vs = (diag_format == DIAG_XDB_NEW ? 7.40 : 7.05);
2 7u83 216
    }
6 7u83 217
    switch (diag_format) {
2 7u83 218
 
6 7u83 219
	case DIAG_STAB: {
2 7u83 220
	    /* Temporary files not used */
6 7u83 221
	    break;
2 7u83 222
	}
223
 
6 7u83 224
	case DIAG_UNKNOWN: {
225
	    warning("Unknown diagnostics format");
226
	    diag_format = DIAG_XDB_NEW;
2 7u83 227
	    /* Fall through */
228
	}
229
 
6 7u83 230
	case DIAG_XDB_NEW: {
231
	    diagfp1 = tmpfile();
232
	    diagfp2 = tmpfile();
233
	    diagfp3 = tmpfile();
234
	    if (diagfp1 == null || diagfp2 == null || diagfp3 == null) {
235
		error("Can't open temporary diagnostics file");
236
		exit(EXIT_FAILURE);
2 7u83 237
	    }
6 7u83 238
	    fprintf(diagfp1, "%s\n", instr_names[m_as_data]);
239
	    fprintf(diagfp1, "%s\n", instr_names[m_dd_vt]);
240
	    fprintf(diagfp2, "%s\n", instr_names[m_dd_lntt]);
241
	    fprintf(diagfp3, "%s\n", instr_names[m_dd_gntt]);
242
	    break;
2 7u83 243
	}
244
 
6 7u83 245
	case DIAG_XDB_OLD: {
246
	    diagfp2 = tmpfile();
247
	    if (diagfp2 == null) {
248
		error("Can't open temporary diagnostics file");
249
		exit(EXIT_FAILURE);
2 7u83 250
	    }
6 7u83 251
	    fprintf(diagfp2, "%s\n", instr_names[m_as_data]);
252
	    fprintf(diagfp2, "%s\n", instr_names[m_dd_start]);
253
	    break;
2 7u83 254
	}
255
    }
6 7u83 256
    return;
2 7u83 257
}
258
 
259
 
260
/*
261
    COPY A FILE
262
 
263
    The the file is copied to the main output file, fpout.
264
*/
265
 
266
static void copy_diag_file
6 7u83 267
(FILE *file)
2 7u83 268
{
6 7u83 269
    int c;
270
    rewind(file);
271
    while (c = getc(file), c != EOF)putc(c, fpout);
272
    fclose(file);
273
    return;
2 7u83 274
}
275
 
276
 
277
/*
278
    VT AREA NEWLINE FLAG
279
 
280
    This flag is true if a newline has just been output in the vt area.
281
*/
282
 
6 7u83 283
static int vt_newline = 1;
2 7u83 284
 
285
 
286
/*
287
    COPY DIAGNOSTICS FILES
288
 
289
    All the diagnostic files are copied to the main output file.
290
*/
291
 
292
void copy_diag
6 7u83 293
(void)
2 7u83 294
{
6 7u83 295
    if (diag_format == DIAG_XDB_NEW) {
296
	if (vt_newline) {
297
	    fprintf(diagfp1, "%s0\n", instr_names[m_dd_vtbytes]);
2 7u83 298
	} else {
6 7u83 299
	    fprintf(diagfp1, ",0\n");
2 7u83 300
	}
6 7u83 301
	copy_diag_file(diagfp1);
302
	copy_diag_file(diagfp2);
303
	copy_diag_file(diagfp3);
304
    } else if (diag_format == DIAG_XDB_OLD) {
305
	copy_diag_file(diagfp2);
2 7u83 306
    }
6 7u83 307
    return;
2 7u83 308
}
309
 
310
 
311
/*
312
    OUTPUT A DIAGNOSTICS STRING
313
 
314
    Diagnostic strings (eg. procedure and variable names) are dealt with
315
    differently in the two formats.  In the old format they are output
316
    direct, in the new they are added to the vt table and the offset
317
    from the start of the table is used.
318
*/
319
 
320
void diag_string
6 7u83 321
(FILE *file, char *s)
2 7u83 322
{
6 7u83 323
    if (diag_format == DIAG_XDB_NEW) {
324
	static int vtposn = 0;
325
	static int vtwidth = 0;
326
	if (vt_newline) {
327
	    fprintf(diagfp1, "%s0", instr_names[m_dd_vtbytes]);
328
	    vt_newline = 0;
2 7u83 329
	} else {
6 7u83 330
	    fprintf(diagfp1, ",0");
2 7u83 331
	}
6 7u83 332
	vtposn++;
333
	vtwidth++;
334
	fprintf(file, "%d", vtposn);
335
	for (; *s; s++) {
336
	    if (vt_newline) {
337
		fprintf(diagfp1, "%s%d", instr_names[m_dd_vtbytes], *s);
338
		vt_newline = 0;
2 7u83 339
	    } else {
6 7u83 340
		fprintf(diagfp1, ",%d", *s);
2 7u83 341
	    }
6 7u83 342
	    vtposn++;
343
	    vtwidth++;
344
	    if (vtwidth > 12) {
345
		fprintf(diagfp1, "\n");
346
		vt_newline = 1;
347
		vtwidth = 0;
2 7u83 348
	    }
349
	}
350
    } else {
6 7u83 351
	fprintf(file,    }
352
    return;
2 7u83 353
}
354
 
355
 
356
/*
357
    CURRENT FILE INDEX AND LINE NUMBER
358
 
359
    These variables record the current position in the source file.
360
*/
361
 
6 7u83 362
char *crt_fname = "";
363
long crt_line_num = -1;
2 7u83 364
 
365
 
366
/*
367
    NUMBER OF SLT INSTRUCTIONS
368
 
369
    A count of the number of slt instructions is maintained.
370
*/
371
 
6 7u83 372
static int slt_num = 0;
2 7u83 373
 
374
 
375
/*
376
    PRINT AN SLT SPECIAL INSTRUCTION
377
 
378
    An sltspecial instruction is output.  This goes straight into the
379
    main output file.
380
*/
381
 
382
static void slt_special
6 7u83 383
(int t, posn_t p)
2 7u83 384
{
6 7u83 385
    mach_op *op1, *op2, *op3;
386
    area(ptext);
387
    op1 = make_int_data(t);
388
    op2 = make_int_data(crt_line_num);
389
    op3 = make_hex_data(p);
390
    op1->of = op2;
391
    op2->of = op3;
392
    make_instr(m_dd_special, op1, null, 0);
393
    area(plast);
394
    slt_num++;
395
    return;
2 7u83 396
}
397
 
398
 
399
/*
400
    OUTPUT A SLT NORMAL INSTRUCTION
401
 
402
    An sltnormal instruction is output.  This goes straight into the
403
    main output file.
404
*/
405
 
406
static void slt_normal
6 7u83 407
(void)
2 7u83 408
{
6 7u83 409
    mach_op *op;
410
    area(ptext);
411
    op = make_int_data(crt_line_num);
412
    if (diag_format == DIAG_STAB) {
413
	mach_op *op1 = make_int_data(68);
414
	op1->of = make_int_data(0);
415
	op1->of->of = op;
416
	make_instr(m_stabd, op1, null, 0);
2 7u83 417
    } else {
6 7u83 418
	make_instr(m_dd_normal, op, null, 0);
2 7u83 419
    }
6 7u83 420
    area(plast);
421
    slt_num++;
422
    return;
2 7u83 423
}
424
 
425
 
426
/*
427
    OUTPUT A SLT EXIT INSTRUCTION
428
 
429
    An sltexit instruction is output (new format only).
430
*/
431
 
432
void slt_exit
6 7u83 433
(void)
2 7u83 434
{
6 7u83 435
    mach_op *op;
436
    area(ptext);
437
    op = make_int_data(crt_line_num);
438
    make_instr(m_dd_exit, op, null, 0);
439
    area(plast);
440
    slt_num++;
441
    return;
2 7u83 442
}
443
 
444
 
445
/*
446
    OUTPUT A DNT BEGIN INSTRUCTION
447
*/
448
 
449
void dnt_begin
6 7u83 450
(void)
2 7u83 451
{
6 7u83 452
    if (diag_format == DIAG_STAB) {
453
	long lab = next_lab();
454
	make_label(lab);
455
	push_dscope((posn_t)lab, 0);
2 7u83 456
    } else {
6 7u83 457
	posn_t p = out_dd(diagfp2, xdb_begin, 1);
458
	push_dscope(p, 4);
459
	if (diag_format == DIAG_XDB_NEW)fprintf(diagfp2, "0,");
460
	fprintf(diagfp2, "%d\n", slt_num);
461
	slt_special(5, p);
2 7u83 462
    }
6 7u83 463
    return;
2 7u83 464
}
465
 
466
 
467
/*
468
    OUTPUT A DNT END INSTRUCTION
469
*/
470
 
471
int dnt_end
6 7u83 472
(void)
2 7u83 473
{
6 7u83 474
    dscope *d = pop_dscope();
475
    if (d == null) return(0);
476
    if (diag_format == DIAG_STAB) {
477
	long lab1 = (long)d->posn;
478
	long lab2 = next_lab();
479
	make_label(lab2);
480
	make_stabn(192, lab1);
481
	make_stabn(224, lab2);
2 7u83 482
    } else {
6 7u83 483
	posn_t p = out_dd(diagfp2, xdb_end, 1);
484
	if (diag_format == DIAG_XDB_NEW) {
485
	    fprintf(diagfp2, "%d,0,", d->dscope_type);
2 7u83 486
	}
6 7u83 487
	fprintf(diagfp2, "%d,0x%x\n", slt_num,
488
		 (unsigned int)d->posn);
489
	slt_special(6, p);
2 7u83 490
    }
6 7u83 491
    return(1);
2 7u83 492
}
493
 
494
 
495
/*
496
    FLAG FOR MODULE NAME
497
*/
498
 
6 7u83 499
static bool have_module = 0;
2 7u83 500
 
501
 
502
/*
503
    DIAGNOSTICS FOR FILE NAME
504
 
505
    This routine output the necessary instructions to indicate a change
506
    of source file.
507
*/
508
 
509
void diag_source_file
6 7u83 510
(char *nm, long ln)
2 7u83 511
{
6 7u83 512
    if (diag_format == DIAG_STAB) {
513
	int n = strlen(nm) + 3;
514
	char *qnm = alloc_nof(char, n);
515
	mach_op *op = make_extern_data("Ltext", 0);
516
	sprintf(qnm,	make_stabs(qnm,(have_module ? 132 : 100), L0, op);
517
	if (!have_module) {
518
	    make_external_label("Ltext");
519
	    init_stab_types();
520
	    have_module = 1;
2 7u83 521
	}
6 7u83 522
	crt_fname = nm;
523
	crt_line_num = ln;
2 7u83 524
    } else {
6 7u83 525
	posn_t x = out_dd(diagfp2, xdb_srcfile, 1);
526
	fprintf(diagfp2, "1,");
527
	diag_string(diagfp2, nm);
528
	fprintf(diagfp2, ",%d\n", slt_num);
529
	crt_fname = nm;
530
	crt_line_num = ln;
531
	make_instr(m_dd_align, null, null, 0);
532
	slt_special(1, x);
533
	if (!have_module) {
534
	    x = out_dd(diagfp2, xdb_module, 1);
535
	    if (diag_format == DIAG_XDB_NEW) {
536
		fprintf(diagfp2, "0,0");
2 7u83 537
	    } else {
6 7u83 538
		diag_string(diagfp2, nm);
2 7u83 539
	    }
6 7u83 540
	    fprintf(diagfp2, ",%d\n", slt_num);
541
	    push_dscope(x, 1);
542
	    slt_special(2, x);
543
	    have_module = 1;
2 7u83 544
	}
545
    }
6 7u83 546
    return;
2 7u83 547
}
548
 
549
 
550
/*
551
    DIAGNOSTICS FOR LINE NUMBER
552
 
553
    This routine outputs an instruction indicating the position within
554
    the source file.
555
*/
556
 
557
void diag_source
6 7u83 558
(char *nm, long ln, int d)
2 7u83 559
{
6 7u83 560
    if (have_module && d == 0) return;
561
    if (!eq(nm, crt_fname))diag_source_file(nm, ln);
562
    crt_line_num = ln;
563
    if (d)slt_normal();
564
    return;
2 7u83 565
}
566
 
567
 
568
/*
569
    CURRENT DIAGNOSTICS PROCEDURE LABEL
570
*/
571
 
6 7u83 572
long crt_diag_proc_lab;
2 7u83 573
 
574
 
575
/*
576
    DIAGNOSTICS FOR A PROCEDURE
577
*/
578
 
579
void diag_proc_main
6 7u83 580
(diag_type dt, exp e, char *id, int is_glob, char *val)
2 7u83 581
{
6 7u83 582
    exp a;
583
    posn_t t;
584
    long fp;
585
    table_posn *p;
586
    diag_type dtl;
2 7u83 587
 
588
    /* Analyse result sort */
6 7u83 589
    if (dt->key != DIAG_TYPE_PROC) {
590
	error("Illegal procedure type");
591
	return;
2 7u83 592
    }
6 7u83 593
    dtl = dt->data.proc.result_type;
2 7u83 594
 
6 7u83 595
    if (diag_format == DIAG_STAB) {
596
	mach_op *op = make_extern_data(val, 0);
597
	char *st = analyse_stab_type(dtl, id,(is_glob ? "F" : "f"));
598
	make_stabs(st, 36, crt_line_num, op);
599
	dnt_begin();
2 7u83 600
    } else {
6 7u83 601
	p = analyse_diag_type(diagfp2, dtl, 1);
2 7u83 602
 
603
	/* Create diagnostics procedure label */
6 7u83 604
	crt_diag_proc_lab = next_lab();
2 7u83 605
 
606
	/* Output function diagnostic directive */
6 7u83 607
	t = out_dd(diagfp2, xdb_function, 1);
608
	fprintf(diagfp2, "%d,1,", is_glob);
609
	if (diag_format == DIAG_XDB_NEW)fprintf(diagfp2, "0,0,0,0,0,");
610
	diag_string(diagfp2, id);
611
	if (strcmp(id, "main") == 0) {
612
	    fputc(',', diagfp2);
613
	    diag_string(diagfp2, "_MAIN_");
614
	    fputc(',', diagfp2);
2 7u83 615
	} else {
6 7u83 616
	    fprintf(diagfp2, ",0,");
2 7u83 617
	}
6 7u83 618
	fp = ftell(diagfp2);
619
	fprintf(diagfp2, "%s,%d,%s,", NULL_POSN_STR, slt_num, val);
620
	out_posn(diagfp2, p, 1);
621
	if (diag_format == DIAG_XDB_NEW)fprintf(diagfp2, "%s,", val);
622
	fprintf(diagfp2, "L%ld\n", crt_diag_proc_lab);
2 7u83 623
 
624
	/* Start new diagnostic scope */
6 7u83 625
	push_dscope(t, 2);
626
	slt_special(3, t);
2 7u83 627
    }
628
 
629
    /* Step over actual procedure arguments */
6 7u83 630
    a = son(e);
2 7u83 631
    while ( name ( a ) == ident_tag /* && isparam ( a ) */ ) {
6 7u83 632
	a = bro(son(a));
2 7u83 633
    }
634
 
635
    /* Read procedure argument definitions */
6 7u83 636
    while (name(a) == diagnose_tag) {
637
	diag_info *di = dno(a);
638
	if (di->key == DIAG_INFO_ID) {
639
	    exp ps = di->data.id_scope.access;
640
	    if (isparam(son(ps))) {
641
		diag_type pdt = di->data.id_scope.typ;
642
		char *pnm = di->data.id_scope.nme.ints.chars;
643
		long off = 8 + (no(ps) + no(son(ps))) / 8;
644
		if (diag_format == DIAG_STAB) {
645
		    mach_op *op = make_int_data(off);
646
		    char *st = analyse_stab_type(pdt, pnm, "p");
647
		    make_stabs(st, 160, L0, op);
2 7u83 648
		} else {
6 7u83 649
		    p = analyse_diag_type(diagfp2, pdt, 1);
650
		    t = out_dd(diagfp2, xdb_fparam, 1);
651
		    fill_gap(diagfp2, fp, t);
652
		    if (diag_format == DIAG_XDB_NEW) {
653
			fprintf(diagfp2, "0,0,0,0,0,");
2 7u83 654
		    } else {
6 7u83 655
			fprintf(diagfp2, "0,0,");
2 7u83 656
		    }
6 7u83 657
		    if (*pnm) {
658
			diag_string(diagfp2, pnm);
2 7u83 659
		    } else {
6 7u83 660
			diag_string(diagfp2, "__unknown");
2 7u83 661
		    }
6 7u83 662
		    fprintf(diagfp2, ",%ld,", off);
663
		    out_posn(diagfp2, p, 1);
664
		    fp = ftell(diagfp2);
665
		    if (diag_format == DIAG_XDB_NEW) {
666
			fprintf(diagfp2, "%s,0\n", NULL_POSN_STR);
2 7u83 667
		    } else {
6 7u83 668
			fprintf(diagfp2, "%s\n", NULL_POSN_STR);
2 7u83 669
		    }
670
		}
671
	    }
672
	}
6 7u83 673
	a = son(a);
2 7u83 674
    }
6 7u83 675
    return;
2 7u83 676
}
677
 
678
 
679
/*
680
    DIAGNOSTICS FOR A GLOBAL IDENTIFIER
681
*/
682
 
683
void diag_globl_variable
6 7u83 684
(diag_type dt, char *id, int is_glob, char *val, int has_def)
2 7u83 685
{
6 7u83 686
    if (diag_format == DIAG_STAB) {
687
	if (is_glob) {
688
	    char *st = analyse_stab_type(dt, id, "G");
689
	    make_stabs(st, 32, crt_line_num, null);
2 7u83 690
	} else {
6 7u83 691
	    mach_op *op = make_extern_data(val, 0);
692
	    char *st = analyse_stab_type(dt, id, "S");
693
	    make_stabs(st, 38, crt_line_num, op);
2 7u83 694
	}
695
    } else {
6 7u83 696
	int loc;
697
	FILE *file;
698
	table_posn *x;
699
	if (diag_format == DIAG_XDB_NEW) {
700
	    loc = (is_glob ? 0 : 1);
701
	    file = (is_glob ? diagfp3 : diagfp2);
2 7u83 702
	} else {
6 7u83 703
	    loc = 1;
704
	    file = diagfp2;
2 7u83 705
	}
6 7u83 706
	x = analyse_diag_type(file, dt, loc);
707
	(void)out_dd(file, xdb_svar, loc);
708
	if (diag_format == DIAG_XDB_NEW) {
709
	    fprintf(file, "%d,0,0,0,0,", is_glob);
2 7u83 710
	} else {
6 7u83 711
	    fprintf(file, "%d,0,", is_glob);
2 7u83 712
	}
6 7u83 713
	diag_string(file, id);
714
	if (has_def) {
715
	    fprintf(file, ",%s,", val);
2 7u83 716
	} else {
6 7u83 717
	    fprintf(file, ",-1,");
2 7u83 718
	}
6 7u83 719
	out_posn(file, x, 1);
720
	fprintf(file, "0,0\n");
2 7u83 721
    }
6 7u83 722
    return;
2 7u83 723
}
724
 
725
 
726
/*
727
    DIAGNOSTICS FOR A LOCAL IDENTIFIER
728
*/
729
 
730
void diag_local_variable
6 7u83 731
(diag_type dt, char *id, long fp)
2 7u83 732
{
6 7u83 733
    if (diag_format == DIAG_STAB) {
734
	mach_op *op = make_int_data(-fp);
735
	char *st = analyse_stab_type(dt, id, "l");
736
	make_stabs(st, 128, crt_line_num, op);
2 7u83 737
    } else {
6 7u83 738
	table_posn *x = analyse_diag_type(diagfp2, dt, 1);
739
	(void)out_dd(diagfp2, xdb_dvar, 1);
740
	if (diag_format == DIAG_XDB_NEW) {
741
	    fprintf(diagfp2, "0,0,0,0,");
2 7u83 742
	} else {
6 7u83 743
	    fprintf(diagfp2, "0,0,0,");
2 7u83 744
	}
6 7u83 745
	diag_string(diagfp2, id);
746
	fprintf(diagfp2, ",%ld,", -fp);
747
	if (diag_format == DIAG_XDB_NEW) {
748
	    out_posn(diagfp2, x, 1);
749
	    fprintf(diagfp2, "0\n");
2 7u83 750
	} else {
6 7u83 751
	    out_posn(diagfp2, x, 0);
2 7u83 752
	}
753
    }
6 7u83 754
    return;
2 7u83 755
}
756
 
757
 
758
/*
759
    DIAGNOSTICS FOR A TYPE DEFINITION
760
*/
761
 
762
void diag_type_defn
6 7u83 763
(char *nm, diag_type dt)
2 7u83 764
{
6 7u83 765
    switch (dt->key) {
2 7u83 766
 
6 7u83 767
	case DIAG_TYPE_UNINIT:
768
	case DIAG_TYPE_INITED: {
2 7u83 769
	    /* Ignore unused types */
6 7u83 770
	    break;
2 7u83 771
	}
772
 
773
	default : {
6 7u83 774
	    if (diag_format == DIAG_STAB) {
775
		char *st = analyse_stab_type(dt, nm, "t");
776
		make_stabs(st, 128, L1, null);
2 7u83 777
	    } else {
6 7u83 778
		int loc = (diag_format == DIAG_XDB_NEW ? 0 : 1);
779
		FILE *file = (loc ? diagfp2 : diagfp3);
780
		table_posn *p = analyse_diag_type(file, dt, loc);
781
		(void)out_dd(file, xdb_typedef, loc);
782
		fprintf(file, "0,");
783
		diag_string(file, nm);
784
		fprintf(file, ",");
785
		out_posn(file, p, 0);
2 7u83 786
	    }
6 7u83 787
	    break;
2 7u83 788
	}
789
    }
6 7u83 790
    return;
2 7u83 791
}