Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /trunk/src/installers/common/dwarf/dwarf_type.c – Rev 2 and 7

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) 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 88... Line 118...
88
#include <dwarf.h>
118
#include <dwarf.h>
89
#else
119
#else
90
#include CROSS_INCLUDE/dwarf.h>
120
#include CROSS_INCLUDE/dwarf.h>
91
#endif
121
#endif
92
 
122
 
93
#define NOT_YET(x) fprintf(stderr,"%s not yet implemented\n",x)
123
#define NOT_YET(x)	fprintf(stderr, "%s not yet implemented\n", x)
94
 
124
 
95
#define BEEN_PUT_OUT(x) ((x)->been_outed != NULL)
125
#define BEEN_PUT_OUT(x)	((x)->been_outed != NULL)
96
 
126
 
97
#define gcc_FT_long_long		0x8008
127
#define gcc_FT_long_long		0x8008
312
 
345
 
313
static void out_user_attr
346
static void
314
    PROTO_N ( (t) )
-
 
315
    PROTO_T ( diag_type t )
347
out_user_attr(diag_type t)
316
{
348
{
317
  if (is_qualified(t))
349
	if (is_qualified(t)) {
318
  {
-
 
319
    OUT_DWARF_ATTR(AT_mod_u_d_type);
350
		OUT_DWARF_ATTR(AT_mod_u_d_type);
320
    new_dwarf_blk2();
351
		new_dwarf_blk2();
321
    out_plain_user_attr(dequalify(t));
352
		out_plain_user_attr(dequalify(t));
322
    leave_dwarf_blk2();
353
		leave_dwarf_blk2();
323
  }
-
 
324
  else
354
	} else {
325
  {
-
 
326
    OUT_DWARF_ATTR(AT_user_def_type);
355
		OUT_DWARF_ATTR(AT_user_def_type);
327
    out_plain_user_attr((t->key == DIAG_TYPE_LOC) ? t->data.loc.object : t);
356
		out_plain_user_attr((t->key == DIAG_TYPE_LOC) ?
-
 
357
				    t->data.loc.object : t);
328
  }
358
	}
329
}
359
}
-
 
360
 
330
 
361
 
331
static void queue_up_type_out
362
static void
332
    PROTO_N ( (t) )
-
 
333
    PROTO_T ( diag_type t )
363
queue_up_type_out(diag_type t)
334
{
364
{
335
  if (BEEN_PUT_OUT(t))
365
	if (BEEN_PUT_OUT(t)) {
336
  {
-
 
337
    failer("Whhops, queueing twice");
366
		failer("Whhops, queueing twice");
338
    return;
367
		return;
339
  }
368
	}
340
  t->been_outed = next_dwarf_type_lab();
369
	t->been_outed = next_dwarf_type_lab();
341
  add_type_q(t);
370
	add_type_q(t);
342
}
371
}
343
 
372
 
-
 
373
 
344
void out_dwarf_type_attr
374
void
345
    PROTO_N ( (t) )
-
 
346
    PROTO_T ( diag_type t )
375
out_dwarf_type_attr(diag_type t)
347
{
376
{
348
				/* output a dwarf type as an attribute
377
	/* output a dwarf type as an attribute if done once already then just
349
				 if done once already then just the attr,
-
 
350
				 else queue the type, then the attr */
378
	 * the attr, else queue the type, then the attr */
351
  if (is_fund_dwarf(t))
379
	if (is_fund_dwarf(t)) {
352
  {
-
 
353
    out_fund_attr(t);
380
		out_fund_attr(t);
354
    return;
381
		return;
355
  }
382
	}
356
  {
383
	{
357
    diag_type b = base_type(t);
384
		diag_type b = base_type(t);
358
    if (!BEEN_PUT_OUT(b))
385
		if (!BEEN_PUT_OUT(b)) {
359
      queue_up_type_out(b);		/* this will assign the label value */
386
			/* this will assign the label value */
-
 
387
			queue_up_type_out(b);
-
 
388
		}
360
 
389
 
361
    out_user_attr(t);
390
		out_user_attr(t);
362
    return;
391
		return;
363
  }
392
	}
364
}
393
}
365
 
394
 
-
 
395
 
366
void out_dwarf_user_type
396
void
367
    PROTO_N ( (t) )
-
 
368
    PROTO_T ( diag_type t )
397
out_dwarf_user_type(diag_type t)
369
{
398
{
-
 
399
	if (!BEEN_PUT_OUT(t)) {
370
  if (!BEEN_PUT_OUT(t))		/* if so then no external refs */
400
		/* if so then no external refs */
371
  {
-
 
372
    t->been_outed = next_dwarf_type_lab();
401
		t->been_outed = next_dwarf_type_lab();
373
  }
402
	}
374
  switch(t->key)
403
	switch (t->key) {
375
  {
-
 
376
   case DIAG_TYPE_ARRAY:
404
	case DIAG_TYPE_ARRAY:
377
    cont_sib_chain(TAG_array_type);
405
		cont_sib_chain(TAG_array_type);
378
 
406
 
379
    OUT_DWARF_ATTR(AT_stride_size);
407
		OUT_DWARF_ATTR(AT_stride_size);
380
    out_dwarf_const_by8(t->data.array.stride);
408
		out_dwarf_const_by8(t->data.array.stride);
381
/*    out_dwarf_name_attr(t->data.array.name); */
409
		/* out_dwarf_name_attr(t->data.array.name); */
382
    {
-
 
383
      OUT_DWARF_ATTR(AT_subscr_data);
410
		OUT_DWARF_ATTR(AT_subscr_data);
384
      new_dwarf_blk2();
411
		new_dwarf_blk2();
385
      dwarf1((int)FMT_FT_C_C);
412
		dwarf1((int)FMT_FT_C_C);
386
      OUT_DWARF_TAG(FT_signed_integer);
413
		OUT_DWARF_TAG(FT_signed_integer);
387
      out_dwarf_const4(t->data.array.lower_b);
414
		out_dwarf_const4(t->data.array.lower_b);
-
 
415
		/* FOR C this is one too big */
388
      out_dwarf_const4(t->data.array.upper_b); /* FOR C this is one too big */
416
		out_dwarf_const4(t->data.array.upper_b);
389
      dwarf1((int)FMT_ET);
417
		dwarf1((int)FMT_ET);
390
      out_dwarf_type_attr(t->data.array.element_type);
418
		out_dwarf_type_attr(t->data.array.element_type);
391
      leave_dwarf_blk2();
419
		leave_dwarf_blk2();
392
    }
-
 
393
    break;
420
		break;
394
   case DIAG_TYPE_ENUM:
421
	case DIAG_TYPE_ENUM:
395
    cont_sib_chain(TAG_enumeration_type);
422
		cont_sib_chain(TAG_enumeration_type);
396
    out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_enum.nme));
423
		out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_enum.nme));
397
    if (t->data.t_enum.base_type->key != DIAG_TYPE_VARIETY)
424
		if (t->data.t_enum.base_type->key != DIAG_TYPE_VARIETY) {
398
      failer("non integral enum type");
425
			failer("non integral enum type");
-
 
426
		}
399
    out_dwarf_bytesize_attr(t->data.t_enum.base_type->data.var);
427
		out_dwarf_bytesize_attr(t->data.t_enum.base_type->data.var);
400
    OUT_DWARF_ATTR(AT_element_list);
428
		OUT_DWARF_ATTR(AT_element_list);
401
    new_dwarf_blk4();
429
		new_dwarf_blk4();
402
    {
430
		{
403
      int i;
431
			int i;
404
      enum_values * a = t->data.t_enum.values->array;
432
			enum_values *a = t->data.t_enum.values->array;
405
 
433
 
406
      for (i=0; i<t->data.t_enum.values->lastused; i++)
434
			for (i=0; i<t->data.t_enum.values->lastused; i++) {
407
      {
-
 
408
	out_dwarf_const4(a[i]->val);
435
				out_dwarf_const4(a[i]->val);
409
	out_dwarf_string(TDFSTRING2CHAR(a[i]->nme));
436
				out_dwarf_string(TDFSTRING2CHAR(a[i]->nme));
410
      }
437
			}
411
    }
438
		}
412
    leave_dwarf_blk4();
439
		leave_dwarf_blk4();
413
    break;
440
		break;
414
   case DIAG_TYPE_PROC:
441
	case DIAG_TYPE_PROC:
415
    cont_sib_chain(TAG_subroutine_type);
442
		cont_sib_chain(TAG_subroutine_type);
416
    out_dwarf_type_attr(t->data.proc.result_type);
443
		out_dwarf_type_attr(t->data.proc.result_type);
417
    break;
444
		break;
418
   case DIAG_TYPE_STRUCT:
445
	case DIAG_TYPE_STRUCT:
419
    cont_sib_chain(TAG_structure_type);
446
		cont_sib_chain(TAG_structure_type);
420
    out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_struct.nme));
447
		out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_struct.nme));
421
    out_dwarf_bytesize_attr(t->data.t_struct.tdf_shape);
448
		out_dwarf_bytesize_attr(t->data.t_struct.tdf_shape);
422
    break;
449
		break;
423
   case DIAG_TYPE_UNION:
450
	case DIAG_TYPE_UNION:
424
    cont_sib_chain(TAG_union_type);
451
		cont_sib_chain(TAG_union_type);
425
    out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_union.nme));
452
		out_dwarf_name_attr(TDFSTRING2CHAR(t->data.t_union.nme));
426
    out_dwarf_bytesize_attr(t->data.t_union.tdf_shape);
453
		out_dwarf_bytesize_attr(t->data.t_union.tdf_shape);
427
    break;
454
		break;
428
   default:
455
	default:
429
    failer("Illegal diag type in out_dwarf_user_type");
456
		failer("Illegal diag type in out_dwarf_user_type");
430
  }
457
	}
431
				/* now we must set the dwarf type label
458
	/* now we must set the dwarf type label
432
				 to be the dwarf label of this block */
459
	   to be the dwarf label of this block */
433
  {
460
	{
434
    char expr_buf[100];
461
		char expr_buf[100];
435
#if (is80x86)
462
#if (is80x86)
436
#define DOT_SET 	".set"
463
#define DOT_SET	".set"
437
#else
464
#else
438
#if (issparc)
465
#if (issparc)
439
#else
466
#else
440
error need the .set directive
467
		error need the .set directive
441
#endif
468
#endif
442
#endif
469
#endif
443
 
470
 
444
#if FS_CONCAT_STRING
471
#if FS_CONCAT_STRING
445
#if (is80x86)
472
#if (is80x86)
446
#define SET_F "\t"DOT_SET"\t%s , %s"
473
#define SET_F	"\t"DOT_SET"\t%s , %s"
447
#else
474
#else
448
#if (issparc)
475
#if (issparc)
449
#define SET_F "\t%s = %s"
476
#define SET_F	"\t%s = %s"
450
#else
477
#else
451
error need set format str
478
		error need set format str
452
#endif
479
#endif
453
#endif
480
#endif
454
#else
481
#else
455
#if (issparc)
482
#if (issparc)
456
/* KEEP this in step..... */
483
/* KEEP this in step..... */
457
#define SET_F "\t%s = %s"
484
#define SET_F	"\t%s = %s"
458
#else
485
#else
459
#if (is80x86)
486
#if (is80x86)
460
#define SET_F "\t.set\t %s , %s"
487
#define SET_F	"\t.set\t %s , %s"
461
#else
488
#else
462
error write this
489
		error write this
-
 
490
#endif
-
 
491
#endif
463
#endif
492
#endif
-
 
493
 
-
 
494
#ifdef mips
-
 
495
		sprintf(expr_buf, SET_F, (char *)t->been_outed,
-
 
496
#else
-
 
497
		sprintf(expr_buf, SET_F, (char *)&((t->been_outed)[0]),
464
#endif
498
#endif
465
#endif
-
 
466
 
-
 
467
#ifdef mips
-
 
468
    sprintf(expr_buf,SET_F,(char *)t->been_outed,
-
 
469
#else
-
 
470
    sprintf(expr_buf,SET_F,(char *)&((t->been_outed)[0]),
-
 
471
#endif
-
 
472
	    current_label_name());
499
			current_label_name());
473
    outs(expr_buf);
500
		outs(expr_buf);
474
    outnl();
501
		outnl();
475
  }
502
		}
476
  leave_dwarf_blk();
503
		leave_dwarf_blk();
477
 
504
 
478
  switch(t->key)
505
		switch (t->key) {
479
  {
-
 
480
   case DIAG_TYPE_PROC:
506
		case DIAG_TYPE_PROC: {
481
    {
-
 
482
      int i;
507
			int i;
483
      diag_type_list pars = t->data.proc.params;
508
			diag_type_list pars = t->data.proc.params;
484
 
509
 
485
      make_next_new_chain();
510
			make_next_new_chain();
486
      for (i=0; i< pars->lastused; i++)
511
			for (i = 0; i< pars->lastused; i++) {
487
      {
-
 
488
	cont_sib_chain(TAG_formal_parameter);
512
				cont_sib_chain(TAG_formal_parameter);
489
	out_dwarf_type_attr(pars->array[i]);
513
				out_dwarf_type_attr(pars->array[i]);
490
	leave_dwarf_blk();
514
				leave_dwarf_blk();
491
      }
515
			}
492
      if (t->data.proc.opt_args)
516
			if (t->data.proc.opt_args) {
493
      {
-
 
494
	cont_sib_chain(TAG_unspecified_parameters);
517
				cont_sib_chain(TAG_unspecified_parameters);
495
	leave_dwarf_blk();
518
				leave_dwarf_blk();
496
      }
519
			}
497
      end_sib_chain();
520
			end_sib_chain();
498
    }
521
		}
499
    break;
522
			break;
500
   case DIAG_TYPE_STRUCT:
523
		case DIAG_TYPE_STRUCT: {
501
    {
-
 
502
      diag_field_list f = t->data.t_struct.fields;
524
			diag_field_list f = t->data.t_struct.fields;
503
      int i;
525
			int i;
504
 
526
 
505
      make_next_new_chain();
527
			make_next_new_chain();
506
      for ( i = f->lastused-1 ;i>=0; i--)
528
			for (i = f->lastused-1 ;i>=0; i--) {
507
      {
-
 
508
	diag_field m = f->array[i];
529
				diag_field m = f->array[i];
509
 
530
 
510
	cont_sib_chain(TAG_member);
531
				cont_sib_chain(TAG_member);
511
	out_dwarf_name_attr(TDFSTRING2CHAR(m->field_name));
532
				out_dwarf_name_attr(TDFSTRING2CHAR(m->field_name));
512
	out_dwarf_type_attr(m->field_type);
533
				out_dwarf_type_attr(m->field_type);
513
	if (m->field_type->key == DIAG_TYPE_BITFIELD)
534
				if (m->field_type->key == DIAG_TYPE_BITFIELD) {
514
	{
-
 
515
				/* dwarf describes bitfields wrt an anonymous
535
					/* dwarf describes bitfields wrt an
-
 
536
					 * anonymous object, whose size is that
516
				 object, whose size is that of the base type */
537
					 * of the base type */
517
	  int base_type_in_bits =
538
					int base_type_in_bits =
518
	    shape_size(m->field_type->data.bitfield.result_type->data.var);
539
					    shape_size(m->field_type->data.bitfield.result_type->data.var);
519
	  int bit_size =
540
					int bit_size =
520
	    m->field_type->data.bitfield.no_of_bits.nat_val.small_nat;
541
					    m->field_type->data.bitfield.no_of_bits.nat_val.small_nat;
521
	  int bit_offset_from_base =
542
					int bit_offset_from_base =
522
	    (int)no(m->where);
543
					    (int)no(m->where);
523
	  int bit_offset_in_anon_obj =
544
					int bit_offset_in_anon_obj =
524
	    bit_offset_from_base % base_type_in_bits;
545
					    bit_offset_from_base %
-
 
546
					    base_type_in_bits;
525
	  int bit_offset_to_anon_obj =
547
					int bit_offset_to_anon_obj =
-
 
548
					    bit_offset_from_base -
526
	    bit_offset_from_base - bit_offset_in_anon_obj;
549
					    bit_offset_in_anon_obj;
527
 
550
 
528
	  OUT_DWARF_ATTR(AT_bit_offset);
551
					OUT_DWARF_ATTR(AT_bit_offset);
529
	  out_dwarf_thing((int)
552
					out_dwarf_thing((int)
530
#if (little_end)
553
#if (little_end)
531
			  ((base_type_in_bits - /* count from other end  */
554
					  /* count from other end  */
-
 
555
					((base_type_in_bits -
532
			   bit_offset_in_anon_obj) - bit_size)
556
					  bit_offset_in_anon_obj) - bit_size)
533
#else
557
#else
534
			  bit_offset_in_anon_obj
558
					bit_offset_in_anon_obj
535
#endif
559
#endif
536
			  ," bits");
560
					," bits");
537
	  out_dwarf_bit_member_loc_attr(bit_offset_to_anon_obj);
561
					out_dwarf_bit_member_loc_attr(bit_offset_to_anon_obj);
538
	}
-
 
539
	else
562
				} else {
540
	  out_dwarf_member_loc_attr(m->where);
563
					out_dwarf_member_loc_attr(m->where);
-
 
564
				}
541
	leave_dwarf_blk();
565
				leave_dwarf_blk();
542
      }
566
			}
543
      end_sib_chain();
567
			end_sib_chain();
544
    }
568
		}
545
    break;
569
			break;
546
   case DIAG_TYPE_UNION:
570
		case DIAG_TYPE_UNION: {
547
    {
-
 
548
      diag_field_list f = t->data.t_union.fields;
571
			diag_field_list f = t->data.t_union.fields;
549
      int i;
572
			int i;
550
 
573
 
551
      make_next_new_chain();
574
			make_next_new_chain();
552
      for ( i = f->lastused-1 ;i>=0; i--)
575
			for (i = f->lastused - 1; i >= 0; i--) {
553
      {
-
 
554
	diag_field m = f->array[i];
576
				diag_field m = f->array[i];
555
 
577
 
556
	cont_sib_chain(TAG_member);
578
				cont_sib_chain(TAG_member);
557
	out_dwarf_name_attr(TDFSTRING2CHAR(m->field_name));
579
				out_dwarf_name_attr(TDFSTRING2CHAR(m->field_name));
558
	out_dwarf_type_attr(m->field_type);
580
				out_dwarf_type_attr(m->field_type);
559
	out_dwarf_member_loc_attr(m->where);
581
				out_dwarf_member_loc_attr(m->where);
560
	leave_dwarf_blk();
582
				leave_dwarf_blk();
561
      }
583
			}
562
      end_sib_chain();
584
			end_sib_chain();
563
    }
585
		}
564
    break;
586
			    break;
565
   default:
587
		default:
566
    break;
588
			    break;
567
  }
589
		}
568
}
590
}
569
 
-
 
570
 
-
 
571
 
-