Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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) 1997
32
    		 Crown Copyright (c) 1997
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 78... Line 108...
78
 
108
 
79
/* machine dependant */
109
/* machine dependant */
80
#include "expmacs.h"
110
#include "expmacs.h"
81
 
111
 
82
#include "shapemacs.h"
112
#include "shapemacs.h"
83
 
113
 
84
#include "xalloc.h"
114
#include "xalloc.h"
85
#include "dwarf_types.h"
115
#include "dwarf_types.h"
86
#include "dwarf_loc.h"
116
#include "dwarf_loc.h"
87
#include "dwarf_mc.h"
117
#include "dwarf_mc.h"
88
#include "dwarf_out.h"
118
#include "dwarf_out.h"
89
#include "cross_config.h"
119
#include "cross_config.h"
90
#ifdef NEWDIAGS
120
#ifdef NEWDIAGS
91
#include "tags.h"
121
#include "tags.h"
92
#endif
122
#endif
93
 
123
 
94
#ifndef CROSS_INCLUDE
124
#ifndef CROSS_INCLUDE
95
#include <dwarf.h>
125
#include <dwarf.h>
96
#else
126
#else
97
#include CROSS_INCLUDE/dwarf.h>
127
#include CROSS_INCLUDE/dwarf.h>
98
#endif
128
#endif
99
 
129
 
100
#define WHOLE_LINE ( 0xffff)	/* this should be in dwarf.h */
130
#define WHOLE_LINE (0xffff)	/* this should be in dwarf.h */
101
#define WHOLE_SECT ( 0)		/* this should be in dwarf.h */
131
#define WHOLE_SECT (0)		/* this should be in dwarf.h */
102
 
132
 
103
#if issparc
133
#if issparc
104
#define DWARF_NAME "D"
134
#define DWARF_NAME "D"
105
#else
135
#else
106
#define DWARF_NAME "dwf"
136
#define DWARF_NAME "dwf"
107
#endif
137
#endif
108
 
138
 
109
#if (is80x86)
139
#if (is80x86)
110
static char * nl80x86 = "\n";
140
static char *nl80x86 = "\n";
111
#define outnl()	outs(nl80x86)	/* avoid side effects of 80x86 outnl */
141
#define outnl()	outs(nl80x86)	/* avoid side effects of 80x86 outnl */
112
#endif
142
#endif
113
 
143
 
114
void out_dwarf_lab
144
void
115
    PROTO_N ( (l) )
-
 
116
    PROTO_T ( H_dwarf_lab *l )
145
out_dwarf_lab(H_dwarf_lab *l)
117
{
146
{
118
  if (OUT_FLAG(*l) !=0)
147
	if (OUT_FLAG(*l) != 0) {
119
  {
-
 
120
    failer("attempt to re_output dwarf label");
148
		failer("attempt to re_output dwarf label");
121
    exit(EXIT_FAILURE);
149
		exit(EXIT_FAILURE);
122
  }
150
	}
123
  OUT_FLAG(*l) = (char)1;
151
	OUT_FLAG(*l) = (char)1;
124
  outs(LAB2CHAR(*l));
152
	outs(LAB2CHAR(*l));
125
  outc(':');
153
	outc(':');
126
  outnl();
154
	outnl();
127
}
155
}
-
 
156
 
128
 
157
 
129
static void mk_dwarf_label
158
static void
130
    PROTO_N ( (p,x) )
-
 
131
    PROTO_T ( dwarf_label *p X CONST char *x )
159
mk_dwarf_label(dwarf_label *p, CONST char *x)
132
{
160
{
133
  sprintf(LAB2CHAR(p->beg),"%s%s%s",local_prefix,DWARF_NAME,x);
161
	sprintf(LAB2CHAR(p->beg), "%s%s%s", local_prefix, DWARF_NAME, x);
134
  OUT_FLAG(p->beg) = 0;
162
	OUT_FLAG(p->beg) = 0;
135
  sprintf(LAB2CHAR(p->end),"%s%s%s.e",local_prefix,DWARF_NAME,x);
163
	sprintf(LAB2CHAR(p->end), "%s%s%s.e", local_prefix, DWARF_NAME, x);
136
  OUT_FLAG(p->end) = 0;
164
	OUT_FLAG(p->end) = 0;
137
}
165
}
-
 
166
 
138
 
167
 
139
void next_dwarf_lab
168
void
140
    PROTO_N ( (p) )
-
 
141
    PROTO_T ( dwarf_label *p )
169
next_dwarf_lab(dwarf_label *p)
142
{
170
{
143
  static unsigned long next_dwarf_lab_no = 0;
171
	static unsigned long next_dwarf_lab_no = 0;
144
  char num_buf[DWARF_LAB_LEN];
172
	char num_buf[DWARF_LAB_LEN];
145
 
173
 
146
  sprintf(num_buf,"%ld",next_dwarf_lab_no++);
174
	sprintf(num_buf, "%ld", next_dwarf_lab_no++);
147
  mk_dwarf_label(p,num_buf);
175
	mk_dwarf_label(p, num_buf);
148
}
176
}
-
 
177
 
149
 
178
 
150
dwarf_type_label * next_dwarf_type_lab
179
dwarf_type_label *
151
    PROTO_Z ()
180
next_dwarf_type_lab(void)
152
{
181
{
153
  dwarf_type_label * ptr = (dwarf_type_label *)
182
	dwarf_type_label *ptr =
154
    xcalloc(1,sizeof (dwarf_type_label));
183
	    (dwarf_type_label *)xcalloc(1, sizeof(dwarf_type_label));
155
 
184
 
156
  static unsigned long next_dwarf_type_lab_no = 0;
185
	static unsigned long next_dwarf_type_lab_no = 0;
157
 
186
 
158
  sprintf(LAB2CHAR(*ptr),"%s%sT%ld",local_prefix,DWARF_NAME,
187
	sprintf(LAB2CHAR(*ptr), "%s%sT%ld", local_prefix, DWARF_NAME,
159
	  next_dwarf_type_lab_no++);
188
		next_dwarf_type_lab_no++);
160
  return ptr;
189
	return ptr;
161
}
190
}
-
 
191
 
162
 
192
 
163
#if (is80x86)
193
#if (is80x86)
164
#define GO_DWARF	outs("\t.section\t.debug");outnl()
194
#define GO_DWARF	outs("\t.section\t.debug");outnl()
165
#define GO_LINE		outs("\t.section\t.line");outnl()
195
#define GO_LINE		outs("\t.section\t.line");outnl()
166
#define LEAVE_DWARF	outs("\t.previous");outnl()
196
#define LEAVE_DWARF	outs("\t.previous");outnl()
Line 170... Line 200...
170
#define BYTE		".byte"
200
#define BYTE		".byte"
171
#define STRING		".string"
201
#define STRING		".string"
172
#define TEXT_SEG 	".text"
202
#define TEXT_SEG 	".text"
173
#define END_UNIT_ALIGN  ".align 4"
203
#define END_UNIT_ALIGN  ".align 4"
174
#define SUB3_F		"[ %s - %s] - %s\t"
204
#define SUB3_F		"[ %s - %s] - %s\t"
175
#else
-
 
176
#if (issparc)
-
 
177
 
205
 
-
 
206
#else
-
 
207
 
-
 
208
#if (issparc)
178
#define GO_DWARF	outs("\t.pushsection\t\".debug\"");outnl()
209
#define GO_DWARF	outs("\t.pushsection\t\".debug\"");outnl()
179
#define GO_LINE		outs("\t.pushsection\t\".line\"");outnl()
210
#define GO_LINE		outs("\t.pushsection\t\".line\"");outnl()
180
#define LEAVE_DWARF	outs("\t.popsection");outnl()
211
#define LEAVE_DWARF	outs("\t.popsection");outnl()
181
#define LEAVE_LINE	LEAVE_DWARF
212
#define LEAVE_LINE	LEAVE_DWARF
182
#define BYTE4S		".uaword"
213
#define BYTE4S		".uaword"
Line 192... Line 223...
192
#endif
223
#endif
193
#endif
224
#endif
194
 
225
 
195
#if FS_CONCAT_STRING
226
#if FS_CONCAT_STRING
196
 
227
 
197
#define BYTE4_F "\t"BYTE4S"\t%s"
228
#define BYTE4_F		"\t"BYTE4S"\t%s"
198
#define BYTE2_CMT_F "\t"BYTE2S COMMENT_2("\t%#x\t","%s")
229
#define BYTE2_CMT_F	"\t"BYTE2S COMMENT_2("\t%#x\t", "%s")
199
#define BYTE2_F "\t"BYTE2S"\t%s"
230
#define BYTE2_F		"\t"BYTE2S"\t%s"
200
#define BYTE_CMT_F "\t"BYTE COMMENT_2("\t%#x\t","%s")
231
#define BYTE_CMT_F	"\t"BYTE COMMENT_2("\t%#x\t", "%s")
201
#define STRING_M "\t"STRING"\t"
232
#define STRING_M	"\t"STRING"\t"
202
#define STRING_F STRING_M"\"%s\""
233
#define STRING_F	STRING_M"\"%s\""
203
#define END_UNIT "\t"END_UNIT_ALIGN
234
#define END_UNIT	"\t"END_UNIT_ALIGN
204
 
235
 
205
#else
236
#else
-
 
237
 
206
#if (issparc)
238
#if (issparc)
207
/* KEEP these in step.......... */
239
/* KEEP these in step.......... */
208
#define BYTE4_F "\t.uaword\t%s"
240
#define BYTE4_F		"\t.uaword\t%s"
209
#define BYTE2_CMT_F "\t.uahalf\t%#x\t!%s"
241
#define BYTE2_CMT_F	"\t.uahalf\t%#x\t!%s"
210
#define BYTE2_F "\t.uahalf\t%s"
242
#define BYTE2_F		"\t.uahalf\t%s"
211
#define BYTE_CMT_F "\t.byte\t%#x\t!%s"
243
#define BYTE_CMT_F	"\t.byte\t%#x\t!%s"
212
#define STRING_M "\t.asciz\t"
244
#define STRING_M	"\t.asciz\t"
213
#define STRING_F "\t.asciz\t\"%s\""
245
#define STRING_F	"\t.asciz\t\"%s\""
214
#define END_UNIT "\t.align 4"
246
#define END_UNIT	"\t.align 4"
-
 
247
 
215
#else
248
#else
-
 
249
 
216
#if (is80x86)
250
#if (is80x86)
217
#define BYTE4_F "\t.4byte\t%s"
251
#define BYTE4_F		"\t.4byte\t%s"
218
#define BYTE2_CMT_F "\t.2byte\t%#x\t!%s"
252
#define BYTE2_CMT_F	"\t.2byte\t%#x\t!%s"
219
#define BYTE2_F "\t.2byte\t%s"
253
#define BYTE2_F		"\t.2byte\t%s"
220
#define BYTE_CMT_F "\t.byte\t%#x\t!%s"
254
#define BYTE_CMT_F	"\t.byte\t%#x\t!%s"
221
#define STRING_M "\t.string\t"
255
#define STRING_M	"\t.string\t"
222
#define STRING_F "\t.string\t\"%s\""
256
#define STRING_F	"\t.string\t\"%s\""
223
#define END_UNIT "\t.align 4"
257
#define END_UNIT	"\t.align 4"
224
#else
258
#else
225
error not yet written
259
error not yet written
226
#endif
260
#endif
227
#endif
261
#endif
228
#endif
262
#endif
229
 
263
 
-
 
264
 
230
void dwarf4
265
void
231
    PROTO_N ( (t) )
266
dwarf4(CONST char *t)
-
 
267
{
-
 
268
	char outbuf[100];
-
 
269
 
232
    PROTO_T ( CONST char *t )
270
	sprintf(outbuf, BYTE4_F, t);
-
 
271
 
-
 
272
	outs(outbuf);
-
 
273
	outnl();
-
 
274
}
-
 
275
 
-
 
276
 
-
 
277
void
-
 
278
dwarf4n(int x)
233
{
279
{
234
  char outbuf[100];
280
	char outbuf[100];
235
 
281
 
236
  sprintf(outbuf,BYTE4_F,t);
282
	sprintf(outbuf, "%#x", x);
-
 
283
	dwarf4(outbuf);
-
 
284
}
-
 
285
 
-
 
286
 
-
 
287
void
-
 
288
out_dwarf_thing(int t, char *cmt)
-
 
289
{
-
 
290
	char outbuf[100];
-
 
291
 
-
 
292
	if (t > 0xffff) {
-
 
293
		failer("value too big for .2byte constant in out_dwarf_thing");
-
 
294
	}
237
 
295
 
-
 
296
	sprintf(outbuf, BYTE2_CMT_F, t, cmt);
238
  outs(outbuf);
297
	outs(outbuf);
239
  outnl();
298
	outnl();
240
}
299
}
-
 
300
 
241
 
301
 
242
void dwarf4n
302
void
-
 
303
out_dwarf_string(CONST char * CONST s)
-
 
304
{
-
 
305
	/* s = null term'ed in core and to be in asm file */
243
    PROTO_N ( (x) )
306
	char outbuf[100];
-
 
307
 
-
 
308
	sprintf(outbuf, STRING_F, s);
-
 
309
	outs(outbuf);
-
 
310
	outnl();
-
 
311
}
-
 
312
 
-
 
313
 
-
 
314
void
244
    PROTO_T ( int x )
315
dwarf2(char *c)
245
{
316
{
246
  char outbuf[100];
317
	char outbuf[100];
247
 
318
 
248
  sprintf(outbuf,"%#x",x);
319
	sprintf(outbuf, BYTE2_F, c);
249
  dwarf4(outbuf);
320
	outs(outbuf);
-
 
321
	outnl();
250
}
322
}
251
 
323
 
252
void out_dwarf_thing
-
 
253
    PROTO_N ( (t,cmt) )
-
 
254
    PROTO_T ( int t X char *cmt )
-
 
255
{
-
 
256
  char outbuf[100];
-
 
257
 
-
 
258
  if (t > 0xffff)
-
 
259
    failer("value too big for .2byte constant in out_dwarf_thing");
-
 
260
 
324
 
261
  sprintf(outbuf,BYTE2_CMT_F,t,cmt);
-
 
262
  outs(outbuf);
-
 
263
  outnl();
-
 
264
}
325
void
265
 
-
 
266
void out_dwarf_string
-
 
267
    PROTO_N ( (s) )
-
 
268
    PROTO_T ( CONST char * CONST s )
326
out_dwarfone(int t, char *cmt)
269
{
327
{
270
  /* s = null term'ed in core and to be in asm file */
-
 
271
  char outbuf[100];
328
	char outbuf[100];
272
 
-
 
273
  sprintf(outbuf,STRING_F,s);
-
 
274
  outs(outbuf);
-
 
275
  outnl();
-
 
276
}
-
 
277
 
-
 
278
void dwarf2
-
 
279
    PROTO_N ( (c) )
-
 
280
    PROTO_T ( char *c )
-
 
281
{
-
 
282
  char outbuf[100];
-
 
283
 
329
 
284
  sprintf(outbuf,BYTE2_F,c);
330
	sprintf(outbuf, BYTE_CMT_F, t, cmt);
285
  outs(outbuf);
331
	outs(outbuf);
286
  outnl();
332
	outnl();
287
}
333
}
288
 
334
 
289
void out_dwarfone
-
 
290
    PROTO_N ( (t,cmt) )
-
 
291
    PROTO_T ( int t X char *cmt )
-
 
292
{
-
 
293
  char outbuf[100];
-
 
294
 
-
 
295
  sprintf(outbuf,BYTE_CMT_F,t,cmt);
-
 
296
  outs(outbuf);
-
 
297
  outnl();
-
 
298
}
-
 
299
 
335
 
300
static dwarf_label 	dwarf_blk_stk[100];
336
static dwarf_label 	dwarf_blk_stk[100];
301
static unsigned int 	dwarf_blk_stk_ptr=0;
337
static unsigned int 	dwarf_blk_stk_ptr=0;
302
 
338
 
303
void enter_dwarf_blk
339
void
304
    PROTO_N ( (four,exclusive,lb) )
-
 
305
    PROTO_T ( int four X int exclusive X dwarf_label *lb )
340
enter_dwarf_blk(int four, int exclusive, dwarf_label *lb)
306
{
341
{
307
				/* switch to debug section, put out begin
342
	/* switch to debug section, put out begin label and length expr */
308
				 label and length expr */
-
 
309
  char exprbuf[100];
343
	char exprbuf[100];
310
 
344
 
311
  dwarf_blk_stk[dwarf_blk_stk_ptr++] = *lb;
345
	dwarf_blk_stk[dwarf_blk_stk_ptr++] = *lb;
312
				/* the block stack is used for nested
346
	/* the block stack is used for nested dwarf blocks, not for sibling
313
				 dwarf blocks, not for sibling structure */
347
	 * structure */
314
 
348
 
315
  if (four)			/* two byte block are already in debug */
349
	/* two byte block are already in debug */
-
 
350
	if (four) {
316
    GO_DWARF;
351
		GO_DWARF;
-
 
352
	}
317
 
353
 
318
  OUT_DWARF_BEG(lb);
354
	OUT_DWARF_BEG(lb);
319
  if (exclusive)
355
	if (exclusive) {
320
    sprintf(exprbuf,COMMENT_2(SUB3_F," excl. entry len")
356
		sprintf(exprbuf, COMMENT_2(SUB3_F, " excl. entry len"),
321
	    ,lb->end,lb->beg,
-
 
322
	    four ? "4":"2");
357
			lb->end, lb->beg, four ? "4" : "2");
323
  else
358
	} else {
324
    sprintf(exprbuf,COMMENT_2("%s-%s\t"," entry len"),lb->end,lb->beg);
359
		sprintf(exprbuf, COMMENT_2("%s-%s\t", " entry len"), lb->end,
325
  if (four)
360
			lb->beg);
326
    dwarf4(exprbuf);
-
 
327
  else
-
 
328
    dwarf2(exprbuf);
-
 
329
}
361
	}
330
 
-
 
331
void leave_dwarf_blk1
-
 
332
    PROTO_N ( (leave) )
-
 
333
    PROTO_T ( int leave )
-
 
334
{
-
 
335
  if (dwarf_blk_stk_ptr == 0)
-
 
336
    failer("dwarf stack underflow");
-
 
337
  {
-
 
338
    dwarf_label *lb = &dwarf_blk_stk[--dwarf_blk_stk_ptr];
-
 
339
 
-
 
340
    OUT_DWARF_END(lb);
-
 
341
    if (leave)
362
	if (four) {
342
      LEAVE_DWARF;
-
 
343
  }
-
 
344
}
-
 
345
 
-
 
346
char * current_label_name
-
 
347
    PROTO_Z ()
-
 
348
{
-
 
349
  return LAB2CHAR(dwarf_blk_stk[dwarf_blk_stk_ptr - 1].beg);
-
 
350
}
-
 
351
 
-
 
352
 
-
 
353
void new_dwarf_blk2
-
 
354
    PROTO_Z ()
-
 
355
{
-
 
356
  dwarf_label lb;
-
 
357
  next_dwarf_lab(&lb);
-
 
358
 
-
 
359
  enter_dwarf_blk(0,1,&lb);
-
 
360
}
-
 
361
 
-
 
362
void new_dwarf_blk4
-
 
363
    PROTO_Z ()
-
 
364
{
-
 
365
  dwarf_label lb;
-
 
366
  next_dwarf_lab(&lb);
-
 
367
 
-
 
368
  enter_dwarf_blk(1,1,&lb);
-
 
369
}
-
 
370
 
-
 
371
static dwarf_label text_range;
-
 
372
static dwarf_label line_range;
-
 
373
 
-
 
374
void out_diagnose_prelude
-
 
375
    PROTO_Z ()
-
 
376
{
-
 
377
 
-
 
378
  char exprbuf[100];
-
 
379
 
-
 
380
  mk_dwarf_label(&text_range,"text");
-
 
381
  mk_dwarf_label(&line_range,"line");
-
 
382
 
-
 
383
  outs(TEXT_SEG);
-
 
384
  outnl();
-
 
385
  OUT_DWARF_BEG(&text_range);
-
 
386
  GO_DWARF;
-
 
387
  LEAVE_DWARF;
-
 
388
  GO_LINE;
-
 
389
  LEAVE_LINE;
-
 
390
 
-
 
391
  GO_LINE;
-
 
392
  OUT_DWARF_BEG(&line_range);
-
 
393
  sprintf(exprbuf,"%s-%s",line_range.end,line_range.beg);
-
 
394
  dwarf4(exprbuf);
363
		dwarf4(exprbuf);
395
  dwarf4(text_range.beg);
-
 
396
  LEAVE_LINE;
-
 
397
  enter_dwarf_comp_unit();
-
 
398
 
-
 
399
}
-
 
400
 
-
 
401
void out_diagnose_postlude
-
 
402
    PROTO_Z ()
-
 
403
{
-
 
404
  char exprbuf[100];
-
 
405
 
-
 
406
  leave_dwarf_comp_unit();
-
 
407
 
-
 
408
  outs(TEXT_SEG);
-
 
409
  outnl();
-
 
410
  OUT_DWARF_END(&text_range);
-
 
411
  GO_LINE;
364
	} else {
412
  dwarf4n(WHOLE_SECT);			/* line 0 means whole section */
-
 
413
  dwarf2c(WHOLE_LINE);
-
 
414
  sprintf(exprbuf,"%s-%s",text_range.end,text_range.beg);
-
 
415
  dwarf4(exprbuf);
365
		dwarf2(exprbuf);
416
  OUT_DWARF_END(&line_range);
-
 
417
  LEAVE_LINE;
-
 
418
}
366
	}
419
 
367
}
420
static filename main_filename;
-
 
421
 
368
 
422
void out_dwarf_sourcemark
-
 
423
    PROTO_N ( (x) )
-
 
424
    PROTO_T ( CONST sourcemark * CONST x )
-
 
425
{
-
 
426
  dwarf_label lb;
-
 
427
 
369
 
-
 
370
void
428
  if (x->file != main_filename)
371
leave_dwarf_blk1(int leave)
429
  {
372
{
430
/*    fprintf(stderr,"Sourcemark for file %s cannot be used\n",
373
	if (dwarf_blk_stk_ptr == 0) {
431
	    TDFSTRING2CHAR(x->file->file));*/
374
		failer("dwarf stack underflow");
432
    return;
375
	}
433
  }
376
	{
-
 
377
		dwarf_label *lb = &dwarf_blk_stk[--dwarf_blk_stk_ptr];
434
 
378
 
435
  next_dwarf_lab(&lb);
379
		OUT_DWARF_END(lb);
436
  OUT_DWARF_BEG(&lb);		/* note this label is in TEXT space */
380
		if (leave) {
-
 
381
			LEAVE_DWARF;
-
 
382
		}
-
 
383
	}
-
 
384
}
-
 
385
 
437
 
386
 
438
  GO_LINE;
387
char *
439
  dwarf4n((int)x->line_no.nat_val.small_nat);
-
 
440
  if ((x->char_off.nat_val.small_nat) == 0)
388
current_label_name(void)
-
 
389
{
441
    out_dwarf_thing(WHOLE_LINE,"no source pos");
390
	return LAB2CHAR(dwarf_blk_stk[dwarf_blk_stk_ptr - 1].beg);
-
 
391
}
-
 
392
 
-
 
393
 
442
  else
394
void
443
    out_dwarf_thing((int)x->char_off.nat_val.small_nat,"source pos");
395
new_dwarf_blk2(void)
444
  {
396
{
-
 
397
	dwarf_label lb;
445
    char expr_buf[100];
398
	next_dwarf_lab(&lb);
446
 
399
 
447
    sprintf(expr_buf,"%s - %s",LAB2CHAR(lb.beg),LAB2CHAR(text_range.beg));
400
	enter_dwarf_blk(0, 1, &lb);
-
 
401
}
-
 
402
 
-
 
403
 
-
 
404
void
448
    dwarf4(expr_buf);
405
new_dwarf_blk4(void)
449
  }
406
{
450
  LEAVE_LINE;
407
	dwarf_label lb;
-
 
408
	next_dwarf_lab(&lb);
-
 
409
 
-
 
410
	enter_dwarf_blk(1, 1, &lb);
451
}
411
}
-
 
412
 
-
 
413
 
-
 
414
static dwarf_label text_range;
-
 
415
static dwarf_label line_range;
-
 
416
 
-
 
417
void
-
 
418
out_diagnose_prelude(void)
-
 
419
{
-
 
420
	char exprbuf[100];
-
 
421
 
-
 
422
	mk_dwarf_label(&text_range, "text");
-
 
423
	mk_dwarf_label(&line_range, "line");
-
 
424
 
-
 
425
	outs(TEXT_SEG);
-
 
426
	outnl();
-
 
427
	OUT_DWARF_BEG(&text_range);
-
 
428
	GO_DWARF;
-
 
429
	LEAVE_DWARF;
-
 
430
	GO_LINE;
-
 
431
	LEAVE_LINE;
-
 
432
 
-
 
433
	GO_LINE;
-
 
434
	OUT_DWARF_BEG(&line_range);
-
 
435
	sprintf(exprbuf, "%s-%s", line_range.end, line_range.beg);
-
 
436
	dwarf4(exprbuf);
-
 
437
	dwarf4(text_range.beg);
-
 
438
	LEAVE_LINE;
-
 
439
	enter_dwarf_comp_unit();
-
 
440
 
-
 
441
}
-
 
442
 
-
 
443
 
-
 
444
void
-
 
445
out_diagnose_postlude(void)
-
 
446
{
-
 
447
	char exprbuf[100];
-
 
448
 
-
 
449
	leave_dwarf_comp_unit();
-
 
450
 
-
 
451
	outs(TEXT_SEG);
-
 
452
	outnl();
-
 
453
	OUT_DWARF_END(&text_range);
-
 
454
	GO_LINE;
-
 
455
	dwarf4n(WHOLE_SECT);	/* line 0 means whole section */
-
 
456
	dwarf2c(WHOLE_LINE);
-
 
457
	sprintf(exprbuf, "%s-%s", text_range.end, text_range.beg);
-
 
458
	dwarf4(exprbuf);
-
 
459
	OUT_DWARF_END(&line_range);
-
 
460
	LEAVE_LINE;
-
 
461
}
-
 
462
 
-
 
463
 
-
 
464
static filename main_filename;
-
 
465
 
-
 
466
void
-
 
467
out_dwarf_sourcemark(CONST sourcemark * CONST x)
-
 
468
{
-
 
469
	dwarf_label lb;
-
 
470
 
-
 
471
	if (x->file != main_filename) {
-
 
472
		/*    fprintf(stderr, "Sourcemark for file %s cannot be used\n",
-
 
473
		      TDFSTRING2CHAR(x->file->file));*/
-
 
474
		return;
-
 
475
	}
-
 
476
 
-
 
477
	next_dwarf_lab(&lb);
-
 
478
	OUT_DWARF_BEG(&lb);		/* note this label is in TEXT space */
-
 
479
 
-
 
480
	GO_LINE;
-
 
481
	dwarf4n((int)x->line_no.nat_val.small_nat);
-
 
482
	if ((x->char_off.nat_val.small_nat) == 0) {
-
 
483
		out_dwarf_thing(WHOLE_LINE, "no source pos");
-
 
484
	} else {
-
 
485
		out_dwarf_thing((int)x->char_off.nat_val.small_nat,
-
 
486
				"source pos");
-
 
487
	}
-
 
488
	{
-
 
489
		char expr_buf[100];
-
 
490
 
-
 
491
		sprintf(expr_buf, "%s - %s", LAB2CHAR(lb.beg),
-
 
492
			LAB2CHAR(text_range.beg));
-
 
493
		dwarf4(expr_buf);
-
 
494
	}
-
 
495
	LEAVE_LINE;
-
 
496
}
-
 
497
 
452
 
498
 
453
static dwarf_label 	dwarf_sib_stk[100];
499
static dwarf_label 	dwarf_sib_stk[100];
454
static int	 	dwarf_sib_stk_ptr= -1;
500
static int	 	dwarf_sib_stk_ptr= -1;
455
/* static dwarf_label	underflow_lab = {"underflow","undeflow.e"};*/
501
/* static dwarf_label	underflow_lab = {"underflow", "undeflow.e"};*/
456
 
502
 
457
#define SIB_TOS	        (dwarf_sib_stk[dwarf_sib_stk_ptr])
503
#define SIB_TOS	       (dwarf_sib_stk[dwarf_sib_stk_ptr])
458
#define SIB_PUSH	(dwarf_sib_stk[++dwarf_sib_stk_ptr])
504
#define SIB_PUSH	(dwarf_sib_stk[++dwarf_sib_stk_ptr])
459
#define SIB_POP		(--dwarf_sib_stk_ptr)
505
#define SIB_POP		(--dwarf_sib_stk_ptr)
460
 
506
 
461
/* ((dwarf_sib_stk_ptr) ==0 ? failer("sib stack underflow"), underflow_lab */
507
/* ((dwarf_sib_stk_ptr) == 0 ? failer("sib stack underflow"), underflow_lab */
462
 
508
 
463
void start_sib_chain1
509
void
464
    PROTO_N ( (d_tag,tag_name) )
-
 
465
    PROTO_T ( int d_tag X char *tag_name )
510
start_sib_chain1(int d_tag, char *tag_name)
466
{
511
{
467
				/* generate new label
512
	/* generate new label
468
				 enter blk for new label
513
	   enter blk for new label
469
				 gen sib label
514
	   gen sib label
470
				 push sib label
515
	   push sib label
471
				 gen sib chain */
516
	   gen sib chain */
472
  dwarf_label chain_head;
517
	dwarf_label chain_head;
473
  next_dwarf_lab(&chain_head);
518
	next_dwarf_lab(&chain_head);
474
 
519
 
475
  enter_dwarf_entry(&chain_head);
520
	enter_dwarf_entry(&chain_head);
476
  next_dwarf_lab(&SIB_PUSH);
521
	next_dwarf_lab(&SIB_PUSH);
477
 
522
 
478
  OUT_DWARF_TAG_NAMED(d_tag,tag_name);
523
	OUT_DWARF_TAG_NAMED(d_tag, tag_name);
479
  outs(COMMENT_2("\t"," new sibling chain level "));
524
	outs(COMMENT_2("\t", " new sibling chain level "));
480
  outn((long)dwarf_sib_stk_ptr);
525
	outn((long)dwarf_sib_stk_ptr);
481
  outnl();
526
	outnl();
482
  OUT_DWARF_ATTR(AT_sibling);
527
	OUT_DWARF_ATTR(AT_sibling);
483
  dwarf4(SIB_TOS.beg);
528
	dwarf4(SIB_TOS.beg);
484
}
529
}
-
 
530
 
485
 
531
 
-
 
532
void
486
void make_next_new_chain
533
make_next_new_chain(void)
-
 
534
{
-
 
535
	/* simulate entering next level */
487
    PROTO_Z ()
536
	next_dwarf_lab(&SIB_PUSH);
-
 
537
}
-
 
538
 
-
 
539
 
-
 
540
void
-
 
541
cont_sib_chain1(int d_tag, char *tag_name)
488
{
542
{
-
 
543
	/* enter blk for TOS
-
 
544
	   gen sib label
489
  /* simulate entering next level */
545
	   setq TOS sib label
-
 
546
	   gen sib chain */
-
 
547
	enter_dwarf_entry(&SIB_TOS);
490
  next_dwarf_lab(&SIB_PUSH);
548
	next_dwarf_lab(&SIB_TOS);
-
 
549
	outs(COMMENT_2("\t", " sibling chain level "));
-
 
550
	outn((long)dwarf_sib_stk_ptr);
-
 
551
	outnl();
-
 
552
 
-
 
553
	OUT_DWARF_TAG_NAMED(d_tag, tag_name);
-
 
554
	OUT_DWARF_ATTR(AT_sibling);
-
 
555
	dwarf4(SIB_TOS.beg);
491
}
556
}
492
 
557
 
-
 
558
 
493
void cont_sib_chain1
559
void
494
    PROTO_N ( (d_tag,tag_name) )
560
end_sib_chain(void)
495
    PROTO_T ( int d_tag X char *tag_name )
-
 
496
{
561
{
497
				/* enter blk for TOS
562
	/* enter blk for TOS
498
				 gen sib label
563
	   gen dummy blk
499
				 setq TOS sib label
564
	   pop stack
500
				 gen sib chain */
565
	   leave blk */
501
  enter_dwarf_entry(&SIB_TOS);
566
	enter_dwarf_entry(&SIB_TOS);
502
  next_dwarf_lab(&SIB_TOS);
-
 
503
  outs(COMMENT_2("\t"," sibling chain level "));
567
	outs(COMMENT_2("\t", " end sibling chain level "));
504
  outn((long)dwarf_sib_stk_ptr);
568
	outn((long)dwarf_sib_stk_ptr);
505
  outnl();
569
	outnl();
506
 
-
 
507
  OUT_DWARF_TAG_NAMED(d_tag,tag_name);
-
 
508
  OUT_DWARF_ATTR(AT_sibling);
570
	leave_dwarf_blk();
509
  dwarf4(SIB_TOS.beg);
571
	SIB_POP;
510
}
572
}
511
 
573
 
-
 
574
 
512
void end_sib_chain
575
static void
513
    PROTO_Z ()
576
end_toplevel_chain(void)
514
{
577
{
515
				/* enter blk for TOS
-
 
516
				   gen dummy blk
578
	/* just put out the label */
517
				   pop stack
579
	GO_DWARF;
518
				   leave blk */
-
 
519
  enter_dwarf_entry(&SIB_TOS);
580
	OUT_DWARF_BEG(&SIB_TOS);
520
  outs(COMMENT_2("\t"," end sibling chain level "));
581
	outs(COMMENT_2("\t", " end toplevel chain"));
521
  outn((long)dwarf_sib_stk_ptr);
-
 
522
  outnl();
582
	outnl();
523
  leave_dwarf_blk();
583
	LEAVE_DWARF;
524
  SIB_POP;
584
	SIB_POP;
525
}
585
}
526
 
586
 
527
static void end_toplevel_chain
-
 
528
    PROTO_Z ()
-
 
529
{
-
 
530
				/* just put out the label */
-
 
531
  GO_DWARF;
-
 
532
  OUT_DWARF_BEG(&SIB_TOS);
-
 
533
  outs(COMMENT_2("\t"," end toplevel chain"));
-
 
534
  outnl();
-
 
535
  LEAVE_DWARF;
-
 
536
  SIB_POP;
-
 
537
}
-
 
538
 
-
 
539
				/* HACK to get a filename */
587
/* HACK to get a filename */
540
static long name_space;
588
static long name_space;
541
 
589
 
542
static char *first_filename = (char *) 0;
590
static char *first_filename = (char *)0;
543
 
-
 
544
void dwarf_inspect_filename
-
 
545
    PROTO_N ( (f) )
-
 
546
    PROTO_T ( filename f )
-
 
547
{
-
 
548
  if (first_filename)
-
 
549
    return;
-
 
550
  {
-
 
551
    char * str = TDFSTRING2CHAR(f->file);
-
 
552
    char *lastdot = strrchr(str,'.');
-
 
553
 
-
 
554
    if (!lastdot)
-
 
555
      return;			/* no dot in name */
-
 
556
 
-
 
557
    if (lastdot[1] != 'h')
-
 
558
    {
-
 
559
      first_filename = (char *) xcalloc(1,strlen(str) + 1);
-
 
560
				/* +1 for null ending */
-
 
561
      strcpy(first_filename,str);
-
 
562
 
-
 
563
      main_filename = f;	/* note this to validate sourcemarks */
-
 
564
 
-
 
565
      fflush(fpout);
-
 
566
      {
-
 
567
	long old_tell = ftell(fpout);
-
 
568
 
-
 
569
	fseek(fpout,name_space,SEEK_SET);
-
 
570
	outc('"'); outs(str); outc('"');
-
 
571
	fseek(fpout,old_tell,SEEK_SET);
-
 
572
      }
-
 
573
    }
-
 
574
  }
-
 
575
}
-
 
576
 
-
 
577
extern char *crt_filename;
-
 
578
 
-
 
579
static void maybe_fix_filename
-
 
580
    PROTO_Z ()
-
 
581
{
-
 
582
  char name_buf[100];
-
 
583
  char * last_dot;
-
 
584
 
-
 
585
  if (first_filename)		/* seen a .c already */
-
 
586
    return;
-
 
587
 
-
 
588
  if (crt_filename == NULL)
-
 
589
    name_buf[0] = '\0';
-
 
590
  else
-
 
591
    strcpy(name_buf,crt_filename);
-
 
592
 
-
 
593
  if (strlen(name_buf) > 0)
-
 
594
  {
-
 
595
    last_dot = strrchr(name_buf,'.');
-
 
596
 
591
 
-
 
592
void
-
 
593
dwarf_inspect_filename(filename f)
-
 
594
{
-
 
595
	if (first_filename) {
-
 
596
		return;
-
 
597
	}
-
 
598
	{
-
 
599
		char *str = TDFSTRING2CHAR(f->file);
-
 
600
		char *lastdot = strrchr(str, '.');
-
 
601
 
-
 
602
		if (!lastdot) {
-
 
603
			/* no dot in name */
-
 
604
			return;
-
 
605
		}
-
 
606
 
-
 
607
		if (lastdot[1] != 'h') {
-
 
608
			first_filename = (char *)xcalloc(1, strlen(str) + 1);
-
 
609
			/* +1 for null ending */
-
 
610
			strcpy(first_filename, str);
-
 
611
 
-
 
612
			/* note this to validate sourcemarks */
-
 
613
			main_filename = f;
-
 
614
 
-
 
615
			fflush(fpout);
-
 
616
			{
-
 
617
				long old_tell = ftell(fpout);
-
 
618
 
-
 
619
				fseek(fpout, name_space, SEEK_SET);
-
 
620
				outc('"'); outs(str); outc('"');
-
 
621
				fseek(fpout, old_tell, SEEK_SET);
-
 
622
			}
-
 
623
		}
-
 
624
	}
-
 
625
}
-
 
626
 
-
 
627
 
-
 
628
extern char *crt_filename;
-
 
629
 
-
 
630
static void
-
 
631
maybe_fix_filename(void)
-
 
632
{
-
 
633
	char name_buf[100];
-
 
634
	char *last_dot;
-
 
635
 
-
 
636
	/* seen a .c already */
-
 
637
	if (first_filename) {
-
 
638
		return;
-
 
639
	}
-
 
640
 
-
 
641
	if (crt_filename == NULL) {
-
 
642
		name_buf[0] = '\0';
-
 
643
	} else {
-
 
644
		strcpy(name_buf, crt_filename);
-
 
645
	}
-
 
646
 
-
 
647
	if (strlen(name_buf) > 0) {
-
 
648
		last_dot = strrchr(name_buf, '.');
-
 
649
 
597
    if (last_dot)
650
		if (last_dot) {
598
      last_dot[1] = 'c';
651
			last_dot[1] = 'c';
599
    else
652
		} else {
600
      strcpy(name_buf,"UNKNOWN_SUFFIX.c");
653
			strcpy(name_buf, "UNKNOWN_SUFFIX.c");
601
  }
654
		}
602
  else
655
	} else {
603
    strcpy(name_buf,"UNKNOWN_FILE.c");
656
		strcpy(name_buf, "UNKNOWN_FILE.c");
-
 
657
	}
604
 
658
 
605
  fflush(fpout);
659
	fflush(fpout);
606
  {
660
	{
607
    long old_tell = ftell(fpout);
661
		long old_tell = ftell(fpout);
608
 
662
 
609
    fseek(fpout,name_space,SEEK_SET);
663
		fseek(fpout, name_space, SEEK_SET);
610
    outc('"'); outs(name_buf); outc('"');
664
		outc('"'); outs(name_buf); outc('"');
611
    fseek(fpout,old_tell,SEEK_SET);
665
		fseek(fpout, old_tell, SEEK_SET);
612
  }
666
	}
613
}
667
}
-
 
668
 
614
 
669
 
-
 
670
void
615
void enter_dwarf_comp_unit
671
enter_dwarf_comp_unit(void)
616
    PROTO_Z ()
-
 
617
{
672
{
618
 start_sib_chain(TAG_compile_unit);
673
	start_sib_chain(TAG_compile_unit);
619
  OUT_DWARF_ATTR(AT_name);
674
	OUT_DWARF_ATTR(AT_name);
620
  outs(STRING_M);
675
	outs(STRING_M);
621
  fflush(fpout);
676
	fflush(fpout);
622
  name_space = ftell(fpout);
677
	name_space = ftell(fpout);
623
  outs("                                                                    ");
678
	outs("                                                                    ");
624
  outs("                                                                    ");
679
	outs("                                                                    ");
625
  outnl();
680
	outnl();
626
  OUT_DWARF_ATTR(AT_language);
681
	OUT_DWARF_ATTR(AT_language);
627
  dwarf4n((int)LANG_C89);
682
	dwarf4n((int)LANG_C89);
628
  OUT_DWARF_ATTR(AT_low_pc);
683
	OUT_DWARF_ATTR(AT_low_pc);
629
  dwarf4(LAB2CHAR(text_range.beg));
684
	dwarf4(LAB2CHAR(text_range.beg));
630
  OUT_DWARF_ATTR(AT_high_pc);
685
	OUT_DWARF_ATTR(AT_high_pc);
631
  dwarf4(LAB2CHAR(text_range.end));
686
	dwarf4(LAB2CHAR(text_range.end));
632
  OUT_DWARF_ATTR(AT_stmt_list);
687
	OUT_DWARF_ATTR(AT_stmt_list);
633
  dwarf4(LAB2CHAR(line_range.beg));
688
	dwarf4(LAB2CHAR(line_range.beg));
634
  leave_dwarf_blk();
689
	leave_dwarf_blk();
635
 
690
 
636
  make_next_new_chain();
691
	make_next_new_chain();
637
}
692
}
638
 
693
 
639
 
694
 
640
#include "dwarf_type.h"
695
#include "dwarf_type.h"
641
#include "dwarf_queue.h"
696
#include "dwarf_queue.h"
642
 
697
 
643
 
698
void
644
void leave_dwarf_comp_unit
699
leave_dwarf_comp_unit(void)
645
    PROTO_Z ()
-
 
646
{
700
{
647
  dump_type_q();
701
	dump_type_q();
648
  end_sib_chain();		/* end sib chain below comp unit */
702
	/* end sib chain below comp unit */
-
 
703
	end_sib_chain();
649
 
704
 
650
  {
705
	{
651
    dwarf_label lb;
706
		dwarf_label lb;
652
    next_dwarf_lab(&lb);
707
		next_dwarf_lab(&lb);
653
 
708
 
654
    enter_dwarf_blk(1,0,&lb);
709
		enter_dwarf_blk(1, 0, &lb);
655
    outs(END_UNIT);
710
		outs(END_UNIT);
656
    outnl();
711
		outnl();
657
    leave_dwarf_blk();
712
		leave_dwarf_blk();
658
  }
713
	}
659
 
714
 
660
  end_toplevel_chain();		/* sib of comp unit */
715
	/* sib of comp unit */
-
 
716
	end_toplevel_chain();
661
  maybe_fix_filename();
717
	maybe_fix_filename();
662
}
718
}
-
 
719
 
663
 
720
 
664
void out_dwarf_name_attr
721
void
665
    PROTO_N ( (s) )
-
 
666
    PROTO_T ( CONST char * CONST s )
722
out_dwarf_name_attr(CONST char * CONST s)
667
{
723
{
668
  if (*s == 0)
724
	if (*s == 0) {
669
  {
-
 
670
    outs(COMMENT_2("\t"," no source name"));
725
		outs(COMMENT_2("\t", " no source name"));
671
    outnl();
726
		outnl();
672
    return;
727
		return;
673
  }
728
	}
674
  OUT_DWARF_ATTR(AT_name);
729
	OUT_DWARF_ATTR(AT_name);
675
  out_dwarf_string(s);
730
	out_dwarf_string(s);
676
}
731
}
-
 
732
 
677
 
733
 
-
 
734
void
678
void out_dwarf_bytesize_attr
735
out_dwarf_bytesize_attr(shape t)
679
    PROTO_N ( (t) )
-
 
680
    PROTO_T ( shape t )
-
 
681
{
736
{
682
  OUT_DWARF_ATTR(AT_byte_size);
737
	OUT_DWARF_ATTR(AT_byte_size);
683
  dwarf4n((int)(shape_size(t)/8));
738
	dwarf4n((int)(shape_size(t) / 8));
684
}
739
}
685
 
740
 
686
 
741
 
687
static void dwarf_out_descriptor
742
static void
688
    PROTO_N ( (x) )
-
 
689
    PROTO_T ( diag_descriptor *x )
743
dwarf_out_descriptor(diag_descriptor *x)
690
{
744
{
691
  switch(x->key)
745
	switch (x->key) {
692
  {
-
 
693
   case DIAG_ID_KEY:
746
	case DIAG_ID_KEY: {
694
    {
-
 
695
      exp acc = x->data.id.access;
747
		exp acc = x->data.id.access;
696
      exp t = son(acc);
748
		exp t = son(acc);
697
#ifdef NEWDIAGS
749
#ifdef NEWDIAGS
698
      if (name(acc) != hold_tag) {
750
		if (name(acc) != hold_tag) {
699
	failer("access should be in hold");
751
			failer("access should be in hold");
700
	break;
752
			break;
701
      };
753
		}
702
      acc = son(acc);
754
		acc = son(acc);
703
      if (name(acc) == cont_tag && name(son(acc)) == name_tag && isvar(son(son(acc))))
755
		if (name(acc) == cont_tag && name(son(acc)) == name_tag &&
-
 
756
		    isvar(son(son(acc)))) {
704
	acc = son(acc);
757
			acc = son(acc);
-
 
758
		}
705
      if (name(acc) != name_tag) {
759
		if (name(acc) != name_tag) {
706
	failer("not name_tag");
760
			failer("not name_tag");
707
	break;
761
			break;
708
      };
762
		}
709
      t = son(acc);
763
		t = son(acc);
710
#endif
764
#endif
711
 
765
 
712
      if (!isvar(brog(t)->dec_u.dec_val.dec_exp)
766
		if (!isvar(brog(t)->dec_u.dec_val.dec_exp) &&
713
	  && (name(brog(t)->dec_u.dec_val.dec_shape) == prokhd))
767
		    (name(brog(t)->dec_u.dec_val.dec_shape) == prokhd)) {
-
 
768
			/*	fprintf(stderr, "%s was a proc\n",
714
/*	fprintf(stderr,"%s was a proc\n",TDFSTRING2CHAR(x->data.id.nme));*/
769
			 *	TDFSTRING2CHAR(x->data.id.nme));*/
715
	break;
770
			break;
716
      else
771
		} else {
717
      {
-
 
718
	if (isparam(t))
772
			if (isparam(t)) {
719
	  failer("out descriptor for parameter variable");
773
				failer("out descriptor for parameter variable");
-
 
774
			}
720
	if (!brog(t)->dec_u.dec_val.extnamed)
775
			if (!brog(t) ->dec_u.dec_val.extnamed) {
721
	  cont_sib_chain(TAG_local_variable);
776
				cont_sib_chain(TAG_local_variable);
722
	else
777
			} else {
723
	  cont_sib_chain(TAG_global_variable);
778
				cont_sib_chain(TAG_global_variable);
-
 
779
			}
724
 
780
 
725
	out_dwarf_name_attr(TDFSTRING2CHAR(x->data.id.nme));
781
			out_dwarf_name_attr(TDFSTRING2CHAR(x->data.id.nme));
726
	out_dwarf_type_attr(x->data.id.new_type);
782
			out_dwarf_type_attr(x->data.id.new_type);
727
	out_dwarf_loc_attr(acc,-1);
783
			out_dwarf_loc_attr(acc, -1);
728
	/* -1 for proc_no, since outside any proc */
784
			/* -1 for proc_no, since outside any proc */
729
	leave_dwarf_blk();
785
			leave_dwarf_blk();
730
      }
786
		}
731
      break;
787
		break;
732
    }
788
	}
733
   case DIAG_STRUCT_KEY:
789
	case DIAG_STRUCT_KEY:
734
    fprintf(stderr,"Not yet doing desc key %d name %s\n",x->key,
790
		fprintf(stderr, "Not yet doing desc key %d name %s\n", x->key,
735
	    TDFSTRING2CHAR(x->data.id.nme));
791
			TDFSTRING2CHAR(x->data.id.nme));
736
    break;
792
		break;
737
   case DIAG_TYPEDEF_KEY:
793
	case DIAG_TYPEDEF_KEY:
738
    if ((base_type(x->data.typ.new_type))->key == DIAG_TYPE_INITED)
794
		if ((base_type(x->data.typ.new_type))->key ==
739
    {
795
		    DIAG_TYPE_INITED) {
740
/*      fprintf(stderr,"No diagtype defn provided for %s... omitting typedef\n",
796
			/*      fprintf(stderr, "No diagtype defn provided for %s... omitting typedef\n",
741
	      TDFSTRING2CHAR(x->data.typ.nme)); */
797
				TDFSTRING2CHAR(x->data.typ.nme)); */
742
      break;
798
			break;
743
    }
799
		}
744
    cont_sib_chain(TAG_typedef);
800
		cont_sib_chain(TAG_typedef);
745
    out_dwarf_name_attr(TDFSTRING2CHAR(x->data.typ.nme));
801
		out_dwarf_name_attr(TDFSTRING2CHAR(x->data.typ.nme));
746
    out_dwarf_type_attr(x->data.typ.new_type);
802
		out_dwarf_type_attr(x->data.typ.new_type);
747
    leave_dwarf_blk();
803
		leave_dwarf_blk();
748
    break;
804
		break;
749
   default:
805
	default:
750
    failer("Unknown descriptor");
806
		failer("Unknown descriptor");
751
  }
807
	}
752
}
808
}
753
 
809
 
754
 
810
 
-
 
811
void
755
void out_dwarf_global_list
812
out_dwarf_global_list(void)
756
    PROTO_Z ()
-
 
757
{
813
{
758
  int i;
814
	int i;
759
 
815
 
760
/*  fprintf(stderr,"diagvartab len %d used %d\n",unit_diagvar_tab.len,
816
	/*  fprintf(stderr, "diagvartab len %d used %d\n", unit_diagvar_tab.len,
761
	  unit_diagvar_tab.lastused); */
817
	    unit_diagvar_tab.lastused); */
762
  outs(COMMENT_2("\t","\tdumping global list"));
818
	outs(COMMENT_2("\t", "\tdumping global list"));
763
  outnl();
819
	outnl();
764
  for(i=0;i<unit_diagvar_tab.lastused;i++)
820
	for (i = 0; i < unit_diagvar_tab.lastused; i++) {
765
    dwarf_out_descriptor(&(unit_diagvar_tab.array[i]));
821
		dwarf_out_descriptor(& (unit_diagvar_tab.array[i]));
-
 
822
	}
766
  dump_type_q();
823
	dump_type_q();
767
}
824
}
768
 
825
 
-
 
826
 
-
 
827
void
769
void out_dwarf_diag_tags
828
out_dwarf_diag_tags(void)
770
    PROTO_Z ()	/* maybe put out unused ones later */
-
 
771
{
829
{
-
 
830
	/* maybe put out unused ones later */
772
  return;
831
	return;
773
}
832
}
774
 
833
 
775
 
834
 
776
dwarf_global *new_dwarf_global
835
dwarf_global *
777
    PROTO_N ( (d) )
-
 
778
    PROTO_T ( diag_descriptor * d )
836
new_dwarf_global(diag_descriptor *d)
779
{
837
{
780
  dwarf_global * new = (dwarf_global *) xcalloc(1,sizeof(dwarf_global));
838
	dwarf_global *new = (dwarf_global *)xcalloc(1, sizeof(dwarf_global));
781
 
839
 
782
  new->desc = d;
840
	new->desc = d;
783
 
841
 
784
  return new;
842
	return new;
785
}
843
}