Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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