1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2014, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6
7#include "DebugInfoEntries.h"
8
9#include <new>
10
11#include "AttributeValue.h"
12#include "Dwarf.h"
13#include "SourceLanguageInfo.h"
14
15
16// #pragma mark - DIECompileUnitBase
17
18
19DIECompileUnitBase::DIECompileUnitBase()
20	:
21	fName(NULL),
22	fCompilationDir(NULL),
23	fLowPC(0),
24	fHighPC(0),
25	fStatementListOffset(-1),
26	fMacroInfoOffset(-1),
27	fAddressRangesOffset(-1),
28	fBaseTypesUnit(NULL),
29	fLanguage(0),
30	fIdentifierCase(0),
31	fUseUTF8(true),
32	fContainsMainSubprogram(false)
33{
34}
35
36
37DIECompileUnitBase::~DIECompileUnitBase()
38{
39}
40
41
42status_t
43DIECompileUnitBase::InitAfterAttributes(DebugInfoEntryInitInfo& info)
44{
45	switch (fLanguage) {
46		case 0:
47			info.languageInfo = &kUnknownLanguageInfo;
48			return B_OK;
49		case DW_LANG_C89:
50			info.languageInfo = &kC89LanguageInfo;
51			return B_OK;
52		case DW_LANG_C:
53			info.languageInfo = &kCLanguageInfo;
54			return B_OK;
55		case DW_LANG_C_plus_plus:
56			info.languageInfo = &kCPlusPlusLanguageInfo;
57			return B_OK;
58		case DW_LANG_C99:
59			info.languageInfo = &kC99LanguageInfo;
60			return B_OK;
61		default:
62			info.languageInfo = &kUnsupportedLanguageInfo;
63			return B_OK;
64	}
65}
66
67
68const char*
69DIECompileUnitBase::Name() const
70{
71	return fName;
72}
73
74
75status_t
76DIECompileUnitBase::AddChild(DebugInfoEntry* child)
77{
78	if (child->IsType())
79		fTypes.Add(child);
80	else
81		fOtherChildren.Add(child);
82	return B_OK;
83}
84
85
86status_t
87DIECompileUnitBase::AddAttribute_name(uint16 attributeName,
88	const AttributeValue& value)
89{
90	fName = value.string;
91	return B_OK;
92}
93
94
95status_t
96DIECompileUnitBase::AddAttribute_comp_dir(uint16 attributeName,
97	const AttributeValue& value)
98{
99	fCompilationDir = value.string;
100	return B_OK;
101}
102
103
104status_t
105DIECompileUnitBase::AddAttribute_low_pc(uint16 attributeName,
106	const AttributeValue& value)
107{
108	fLowPC = value.address;
109	return B_OK;
110}
111
112
113status_t
114DIECompileUnitBase::AddAttribute_high_pc(uint16 attributeName,
115	const AttributeValue& value)
116{
117	fHighPC = value.address;
118	if (fLowPC != 0 && fHighPC < fLowPC)
119		fHighPC += fLowPC;
120
121	return B_OK;
122}
123
124
125status_t
126DIECompileUnitBase::AddAttribute_producer(uint16 attributeName,
127	const AttributeValue& value)
128{
129	// not interesting
130	return B_OK;
131}
132
133
134status_t
135DIECompileUnitBase::AddAttribute_stmt_list(uint16 attributeName,
136	const AttributeValue& value)
137{
138	fStatementListOffset = value.pointer;
139	return B_OK;
140}
141
142
143status_t
144DIECompileUnitBase::AddAttribute_macro_info(uint16 attributeName,
145	const AttributeValue& value)
146{
147	fMacroInfoOffset = value.pointer;
148	return B_OK;
149}
150
151
152status_t
153DIECompileUnitBase::AddAttribute_base_types(uint16 attributeName,
154	const AttributeValue& value)
155{
156	fBaseTypesUnit = dynamic_cast<DIECompileUnitBase*>(value.reference);
157	return fBaseTypesUnit != NULL ? B_OK : B_BAD_DATA;
158}
159
160
161status_t
162DIECompileUnitBase::AddAttribute_language(uint16 attributeName,
163	const AttributeValue& value)
164{
165	fLanguage = value.constant;
166	return B_OK;
167}
168
169
170status_t
171DIECompileUnitBase::AddAttribute_identifier_case(uint16 attributeName,
172	const AttributeValue& value)
173{
174	fIdentifierCase = value.constant;
175	return B_OK;
176}
177
178
179status_t
180DIECompileUnitBase::AddAttribute_use_UTF8(uint16 attributeName,
181	const AttributeValue& value)
182{
183	fUseUTF8 = value.flag;
184	return B_OK;
185}
186
187
188status_t
189DIECompileUnitBase::AddAttribute_ranges(uint16 attributeName,
190	const AttributeValue& value)
191{
192	fAddressRangesOffset = value.pointer;
193	return B_OK;
194}
195
196
197status_t
198DIECompileUnitBase::AddAttribute_main_subprogram(uint16 attributeName,
199	const AttributeValue& value)
200{
201	fContainsMainSubprogram = true;
202	return B_OK;
203}
204
205
206// #pragma mark - DIEType
207
208
209DIEType::DIEType()
210	:
211	fName(NULL)
212{
213	fAllocated.SetTo((uint64)0);
214	fAssociated.SetTo((uint64)0);
215}
216
217
218bool
219DIEType::IsType() const
220{
221	return true;
222}
223
224
225const char*
226DIEType::Name() const
227{
228	return fName;
229}
230
231
232bool
233DIEType::IsDeclaration() const
234{
235	return false;
236}
237
238
239const DynamicAttributeValue*
240DIEType::ByteSize() const
241{
242	return NULL;
243}
244
245
246status_t
247DIEType::AddAttribute_name(uint16 attributeName,
248	const AttributeValue& value)
249{
250	fName = value.string;
251	return B_OK;
252}
253
254
255status_t
256DIEType::AddAttribute_allocated(uint16 attributeName,
257	const AttributeValue& value)
258{
259	return SetDynamicAttributeValue(fAllocated, value);
260}
261
262
263status_t
264DIEType::AddAttribute_associated(uint16 attributeName,
265	const AttributeValue& value)
266{
267	return SetDynamicAttributeValue(fAssociated, value);
268}
269
270
271// #pragma mark - DIEModifiedType
272
273
274DIEModifiedType::DIEModifiedType()
275	:
276	fType(NULL)
277{
278}
279
280
281status_t
282DIEModifiedType::AddAttribute_type(uint16 attributeName,
283	const AttributeValue& value)
284{
285	fType = dynamic_cast<DIEType*>(value.reference);
286	return fType != NULL ? B_OK : B_BAD_DATA;
287}
288
289
290// #pragma mark - DIEAddressingType
291
292
293DIEAddressingType::DIEAddressingType()
294	:
295	fAddressClass(0)
296{
297}
298
299
300status_t
301DIEAddressingType::AddAttribute_address_class(uint16 attributeName,
302	const AttributeValue& value)
303{
304// TODO: How is the address class handled?
305	fAddressClass = value.constant;
306	return B_OK;
307}
308
309
310// #pragma mark - DIEDeclaredType
311
312
313DIEDeclaredType::DIEDeclaredType()
314	:
315	fDescription(NULL),
316	fAbstractOrigin(NULL),
317	fSignatureType(NULL),
318	fAccessibility(0),
319	fDeclaration(false)
320{
321}
322
323
324const char*
325DIEDeclaredType::Description() const
326{
327	return fDescription;
328}
329
330
331DebugInfoEntry*
332DIEDeclaredType::AbstractOrigin() const
333{
334	return fAbstractOrigin;
335}
336
337
338DebugInfoEntry*
339DIEDeclaredType::SignatureType() const
340{
341	return fSignatureType;
342}
343
344
345bool
346DIEDeclaredType::IsDeclaration() const
347{
348	return fDeclaration;
349}
350
351
352status_t
353DIEDeclaredType::AddAttribute_accessibility(uint16 attributeName,
354	const AttributeValue& value)
355{
356	fAccessibility = value.constant;
357	return B_OK;
358}
359
360
361status_t
362DIEDeclaredType::AddAttribute_declaration(uint16 attributeName,
363	const AttributeValue& value)
364{
365	fDeclaration = value.flag;
366	return B_OK;
367}
368
369
370status_t
371DIEDeclaredType::AddAttribute_description(uint16 attributeName,
372	const AttributeValue& value)
373{
374	fDescription = value.string;
375	return B_OK;
376}
377
378
379status_t
380DIEDeclaredType::AddAttribute_abstract_origin(uint16 attributeName,
381	const AttributeValue& value)
382{
383	fAbstractOrigin = value.reference;
384	return B_OK;
385}
386
387
388status_t
389DIEDeclaredType::AddAttribute_signature(uint16 attributeName,
390	const AttributeValue& value)
391{
392	fSignatureType = value.reference;
393	return B_OK;
394}
395
396
397DeclarationLocation*
398DIEDeclaredType::GetDeclarationLocation()
399{
400	return &fDeclarationLocation;
401}
402
403
404// #pragma mark - DIEDerivedType
405
406
407DIEDerivedType::DIEDerivedType()
408	:
409	fType(NULL)
410{
411}
412
413
414status_t
415DIEDerivedType::AddAttribute_type(uint16 attributeName,
416	const AttributeValue& value)
417{
418	fType = dynamic_cast<DIEType*>(value.reference);
419	return fType != NULL ? B_OK : B_BAD_DATA;
420}
421
422
423
424
425// #pragma mark - DIECompoundType
426
427
428DIECompoundType::DIECompoundType()
429	:
430	fSpecification(NULL)
431{
432}
433
434
435bool
436DIECompoundType::IsNamespace() const
437{
438	return true;
439}
440
441
442DebugInfoEntry*
443DIECompoundType::Specification() const
444{
445	return fSpecification;
446}
447
448
449const DynamicAttributeValue*
450DIECompoundType::ByteSize() const
451{
452	return &fByteSize;
453}
454
455
456status_t
457DIECompoundType::AddChild(DebugInfoEntry* child)
458{
459	if (child->Tag() == DW_TAG_member) {
460		// TODO: Not for interfaces!
461		fDataMembers.Add(child);
462		return B_OK;
463	}
464
465	return DIEDeclaredType::AddChild(child);
466}
467
468
469status_t
470DIECompoundType::AddAttribute_byte_size(uint16 attributeName,
471	const AttributeValue& value)
472{
473	return SetDynamicAttributeValue(fByteSize, value);
474}
475
476
477status_t
478DIECompoundType::AddAttribute_specification(uint16 attributeName,
479	const AttributeValue& value)
480{
481	fSpecification = dynamic_cast<DIECompoundType*>(value.reference);
482	return fSpecification != NULL ? B_OK : B_BAD_DATA;
483}
484
485
486// #pragma mark - DIEClassBaseType
487
488
489DIEClassBaseType::DIEClassBaseType()
490{
491}
492
493
494status_t
495DIEClassBaseType::AddChild(DebugInfoEntry* child)
496{
497	switch (child->Tag()) {
498		case DW_TAG_inheritance:
499			fBaseTypes.Add(child);
500			return B_OK;
501		case DW_TAG_friend:
502			fFriends.Add(child);
503			return B_OK;
504		case DW_TAG_access_declaration:
505			fAccessDeclarations.Add(child);
506			return B_OK;
507		case DW_TAG_subprogram:
508			fMemberFunctions.Add(child);
509			return B_OK;
510		case DW_TAG_template_type_parameter:
511		case DW_TAG_template_value_parameter:
512			fTemplateParameters.Add(child);
513			return B_OK;
514// TODO: Variants!
515		default:
516		{
517			if (child->IsType()) {
518				fInnerTypes.Add(child);
519				return B_OK;
520			}
521
522			return DIECompoundType::AddChild(child);
523		}
524	}
525}
526
527
528// #pragma mark - DIENamedBase
529
530
531DIENamedBase::DIENamedBase()
532	:
533	fName(NULL),
534	fDescription(NULL)
535{
536}
537
538
539const char*
540DIENamedBase::Name() const
541{
542	return fName;
543}
544
545
546const char*
547DIENamedBase::Description() const
548{
549	return fDescription;
550}
551
552
553status_t
554DIENamedBase::AddAttribute_name(uint16 attributeName,
555	const AttributeValue& value)
556{
557	fName = value.string;
558	return B_OK;
559}
560
561
562status_t
563DIENamedBase::AddAttribute_description(uint16 attributeName,
564	const AttributeValue& value)
565{
566	fDescription = value.string;
567	return B_OK;
568}
569
570
571// #pragma mark - DIEDeclaredBase
572
573
574DIEDeclaredBase::DIEDeclaredBase()
575{
576}
577
578
579DeclarationLocation*
580DIEDeclaredBase::GetDeclarationLocation()
581{
582	return &fDeclarationLocation;
583}
584
585
586// #pragma mark - DIEDeclaredNamedBase
587
588
589DIEDeclaredNamedBase::DIEDeclaredNamedBase()
590	:
591	fName(NULL),
592	fDescription(NULL),
593	fAccessibility(0),
594	fVisibility(0),
595	fDeclaration(false)
596{
597}
598
599
600const char*
601DIEDeclaredNamedBase::Name() const
602{
603	return fName;
604}
605
606
607const char*
608DIEDeclaredNamedBase::Description() const
609{
610	return fDescription;
611}
612
613
614bool
615DIEDeclaredNamedBase::IsDeclaration() const
616{
617	return fDeclaration;
618}
619
620
621status_t
622DIEDeclaredNamedBase::AddAttribute_name(uint16 attributeName,
623	const AttributeValue& value)
624{
625	fName = value.string;
626	return B_OK;
627}
628
629
630status_t
631DIEDeclaredNamedBase::AddAttribute_description(uint16 attributeName,
632	const AttributeValue& value)
633{
634	fDescription = value.string;
635	return B_OK;
636}
637
638
639status_t
640DIEDeclaredNamedBase::AddAttribute_accessibility(uint16 attributeName,
641	const AttributeValue& value)
642{
643	fAccessibility = value.constant;
644	return B_OK;
645}
646
647
648status_t
649DIEDeclaredNamedBase::AddAttribute_declaration(uint16 attributeName,
650	const AttributeValue& value)
651{
652	fDeclaration = value.flag;
653	return B_OK;
654}
655
656
657// #pragma mark - DIEArrayIndexType
658
659
660DIEArrayIndexType::DIEArrayIndexType()
661{
662}
663
664
665const DynamicAttributeValue*
666DIEArrayIndexType::ByteSize() const
667{
668	return &fByteSize;
669}
670
671
672status_t
673DIEArrayIndexType::AddAttribute_bit_stride(uint16 attributeName,
674	const AttributeValue& value)
675{
676	return SetDynamicAttributeValue(fBitStride, value);
677}
678
679
680status_t
681DIEArrayIndexType::AddAttribute_byte_size(uint16 attributeName,
682	const AttributeValue& value)
683{
684	return SetDynamicAttributeValue(fByteSize, value);
685}
686
687
688status_t
689DIEArrayIndexType::AddAttribute_byte_stride(uint16 attributeName,
690	const AttributeValue& value)
691{
692	return SetDynamicAttributeValue(fByteStride, value);
693}
694
695
696// #pragma mark - DIEArrayType
697
698
699DIEArrayType::DIEArrayType()
700	:
701	fSpecification(NULL),
702	fOrdering(DW_ORD_row_major)
703{
704}
705
706
707uint16
708DIEArrayType::Tag() const
709{
710	return DW_TAG_array_type;
711}
712
713
714status_t
715DIEArrayType::InitAfterHierarchy(DebugInfoEntryInitInfo& info)
716{
717	fOrdering = info.languageInfo->arrayOrdering;
718	return B_OK;
719}
720
721
722DebugInfoEntry*
723DIEArrayType::Specification() const
724{
725	return fSpecification;
726}
727
728
729const DynamicAttributeValue*
730DIEArrayType::ByteSize() const
731{
732	return &fByteSize;
733}
734
735
736status_t
737DIEArrayType::AddChild(DebugInfoEntry* child)
738{
739	// a dimension child must be of subrange or enumeration type
740	uint16 tag = child->Tag();
741	if (tag == DW_TAG_subrange_type || tag == DW_TAG_enumeration_type) {
742		fDimensions.Add(child);
743		return B_OK;
744	}
745
746	return DIEDerivedType::AddChild(child);
747}
748
749
750status_t
751DIEArrayType::AddAttribute_ordering(uint16 attributeName,
752	const AttributeValue& value)
753{
754	fOrdering = value.constant;
755	return B_OK;
756}
757
758
759status_t
760DIEArrayType::AddAttribute_bit_stride(uint16 attributeName,
761	const AttributeValue& value)
762{
763	return SetDynamicAttributeValue(fBitStride, value);
764}
765
766
767status_t
768DIEArrayType::AddAttribute_stride_size(uint16 attributeName,
769	const AttributeValue& value)
770{
771	return SetDynamicAttributeValue(fBitStride, value);
772}
773
774
775status_t
776DIEArrayType::AddAttribute_byte_size(uint16 attributeName,
777	const AttributeValue& value)
778{
779	return SetDynamicAttributeValue(fByteSize, value);
780}
781
782
783status_t
784DIEArrayType::AddAttribute_specification(uint16 attributeName,
785	const AttributeValue& value)
786{
787	fSpecification = dynamic_cast<DIEArrayType*>(value.reference);
788	return fSpecification != NULL ? B_OK : B_BAD_DATA;
789}
790
791
792// #pragma mark - DIEClassType
793
794
795DIEClassType::DIEClassType()
796{
797}
798
799
800uint16
801DIEClassType::Tag() const
802{
803	return DW_TAG_class_type;
804}
805
806
807// #pragma mark - DIEEntryPoint
808
809
810DIEEntryPoint::DIEEntryPoint()
811{
812}
813
814
815uint16
816DIEEntryPoint::Tag() const
817{
818	return DW_TAG_entry_point;
819}
820
821
822// #pragma mark - DIEEnumerationType
823
824
825DIEEnumerationType::DIEEnumerationType()
826	:
827	fSpecification(NULL)
828{
829}
830
831
832uint16
833DIEEnumerationType::Tag() const
834{
835	return DW_TAG_enumeration_type;
836}
837
838
839DebugInfoEntry*
840DIEEnumerationType::Specification() const
841{
842	return fSpecification;
843}
844
845
846status_t
847DIEEnumerationType::AddChild(DebugInfoEntry* child)
848{
849	if (child->Tag() == DW_TAG_enumerator) {
850		fEnumerators.Add(child);
851		return B_OK;
852	}
853
854	return DIEDerivedType::AddChild(child);
855}
856
857
858status_t
859DIEEnumerationType::AddAttribute_specification(uint16 attributeName,
860	const AttributeValue& value)
861{
862	fSpecification = dynamic_cast<DIEEnumerationType*>(value.reference);
863	return fSpecification != NULL ? B_OK : B_BAD_DATA;
864}
865
866
867// #pragma mark - DIEFormalParameter
868
869
870DIEFormalParameter::DIEFormalParameter()
871	:
872	fAbstractOrigin(NULL),
873	fType(NULL),
874	fArtificial(false)
875{
876}
877
878
879uint16
880DIEFormalParameter::Tag() const
881{
882	return DW_TAG_formal_parameter;
883}
884
885
886DebugInfoEntry*
887DIEFormalParameter::AbstractOrigin() const
888{
889	return fAbstractOrigin;
890}
891
892
893LocationDescription*
894DIEFormalParameter::GetLocationDescription()
895{
896	return &fLocationDescription;
897}
898
899
900status_t
901DIEFormalParameter::AddAttribute_abstract_origin(uint16 attributeName,
902	const AttributeValue& value)
903{
904	fAbstractOrigin = value.reference;
905	return B_OK;
906}
907
908
909status_t
910DIEFormalParameter::AddAttribute_artificial(uint16 attributeName,
911	const AttributeValue& value)
912{
913	fArtificial = value.flag;
914	return B_OK;
915}
916
917
918status_t
919DIEFormalParameter::AddAttribute_const_value(uint16 attributeName,
920	const AttributeValue& value)
921{
922	return SetConstantAttributeValue(fValue, value);
923}
924
925
926status_t
927DIEFormalParameter::AddAttribute_type(uint16 attributeName,
928	const AttributeValue& value)
929{
930	fType = dynamic_cast<DIEType*>(value.reference);
931	return fType != NULL ? B_OK : B_BAD_DATA;
932}
933
934
935// #pragma mark - DIEImportedDeclaration
936
937
938DIEImportedDeclaration::DIEImportedDeclaration()
939{
940}
941
942
943uint16
944DIEImportedDeclaration::Tag() const
945{
946	return DW_TAG_imported_declaration;
947}
948
949
950// #pragma mark - DIELabel
951
952
953DIELabel::DIELabel()
954{
955}
956
957
958uint16
959DIELabel::Tag() const
960{
961	return DW_TAG_label;
962}
963
964
965// #pragma mark - DIELexicalBlock
966
967
968DIELexicalBlock::DIELexicalBlock()
969	:
970	fLowPC(0),
971	fHighPC(0),
972	fAddressRangesOffset(-1),
973	fAbstractOrigin(NULL)
974{
975}
976
977
978uint16
979DIELexicalBlock::Tag() const
980{
981	return DW_TAG_lexical_block;
982}
983
984
985DebugInfoEntry*
986DIELexicalBlock::AbstractOrigin() const
987{
988	return fAbstractOrigin;
989}
990
991
992status_t
993DIELexicalBlock::AddChild(DebugInfoEntry* child)
994{
995	switch (child->Tag()) {
996		case DW_TAG_variable:
997			fVariables.Add(child);
998			return B_OK;
999		case DW_TAG_lexical_block:
1000			fBlocks.Add(child);
1001			return B_OK;
1002		default:
1003			return DIENamedBase::AddChild(child);
1004	}
1005}
1006
1007
1008status_t
1009DIELexicalBlock::AddAttribute_low_pc(uint16 attributeName,
1010	const AttributeValue& value)
1011{
1012	fLowPC = value.address;
1013	return B_OK;
1014}
1015
1016
1017status_t
1018DIELexicalBlock::AddAttribute_high_pc(uint16 attributeName,
1019	const AttributeValue& value)
1020{
1021	fHighPC = value.address;
1022	if (fLowPC != 0 && fHighPC < fLowPC)
1023		fHighPC += fLowPC;
1024
1025	return B_OK;
1026}
1027
1028
1029status_t
1030DIELexicalBlock::AddAttribute_ranges(uint16 attributeName,
1031	const AttributeValue& value)
1032{
1033	fAddressRangesOffset = value.pointer;
1034	return B_OK;
1035}
1036
1037
1038status_t
1039DIELexicalBlock::AddAttribute_abstract_origin(uint16 attributeName,
1040	const AttributeValue& value)
1041{
1042	fAbstractOrigin = dynamic_cast<DIELexicalBlock*>(value.reference);
1043	return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
1044}
1045
1046
1047// #pragma mark - DIEMember
1048
1049
1050DIEMember::DIEMember()
1051	:
1052	fType(NULL)
1053{
1054}
1055
1056
1057uint16
1058DIEMember::Tag() const
1059{
1060	return DW_TAG_member;
1061}
1062
1063
1064status_t
1065DIEMember::AddAttribute_type(uint16 attributeName,
1066	const AttributeValue& value)
1067{
1068	fType = dynamic_cast<DIEType*>(value.reference);
1069	return fType != NULL ? B_OK : B_BAD_DATA;
1070}
1071
1072
1073status_t
1074DIEMember::AddAttribute_byte_size(uint16 attributeName,
1075	const AttributeValue& value)
1076{
1077	return SetDynamicAttributeValue(fByteSize, value);
1078}
1079
1080
1081status_t
1082DIEMember::AddAttribute_bit_size(uint16 attributeName,
1083	const AttributeValue& value)
1084{
1085	return SetDynamicAttributeValue(fBitSize, value);
1086}
1087
1088
1089status_t
1090DIEMember::AddAttribute_data_member_location(uint16 attributeName,
1091	const AttributeValue& value)
1092{
1093	return SetMemberLocation(fLocation, value);
1094}
1095
1096
1097status_t
1098DIEMember::AddAttribute_bit_offset(uint16 attributeName,
1099	const AttributeValue& value)
1100{
1101	return SetDynamicAttributeValue(fBitOffset, value);
1102}
1103
1104
1105status_t
1106DIEMember::AddAttribute_data_bit_offset(uint16 attributeName,
1107	const AttributeValue& value)
1108{
1109	return SetDynamicAttributeValue(fDataBitOffset, value);
1110}
1111
1112
1113// #pragma mark - DIEPointerType
1114
1115
1116DIEPointerType::DIEPointerType()
1117	:
1118	fSpecification(NULL)
1119{
1120}
1121
1122
1123uint16
1124DIEPointerType::Tag() const
1125{
1126	return DW_TAG_pointer_type;
1127}
1128
1129
1130DebugInfoEntry*
1131DIEPointerType::Specification() const
1132{
1133	return fSpecification;
1134}
1135
1136
1137status_t
1138DIEPointerType::AddAttribute_specification(uint16 attributeName,
1139	const AttributeValue& value)
1140{
1141	fSpecification = dynamic_cast<DIEPointerType*>(value.reference);
1142	return fSpecification != NULL ? B_OK : B_BAD_DATA;
1143}
1144
1145
1146// #pragma mark - DIEReferenceType
1147
1148
1149DIEReferenceType::DIEReferenceType()
1150{
1151}
1152
1153
1154uint16
1155DIEReferenceType::Tag() const
1156{
1157	return DW_TAG_reference_type;
1158}
1159
1160
1161// #pragma mark - DIECompileUnit
1162
1163
1164DIECompileUnit::DIECompileUnit()
1165{
1166}
1167
1168
1169uint16
1170DIECompileUnit::Tag() const
1171{
1172	return DW_TAG_compile_unit;
1173}
1174
1175
1176// #pragma mark - DIEStringType
1177
1178
1179DIEStringType::DIEStringType()
1180{
1181}
1182
1183
1184uint16
1185DIEStringType::Tag() const
1186{
1187	return DW_TAG_string_type;
1188}
1189
1190
1191const DynamicAttributeValue*
1192DIEStringType::ByteSize() const
1193{
1194	return &fByteSize;
1195}
1196
1197
1198status_t
1199DIEStringType::AddAttribute_byte_size(uint16 attributeName,
1200	const AttributeValue& value)
1201{
1202	return SetDynamicAttributeValue(fByteSize, value);
1203}
1204
1205
1206// #pragma mark - DIEStructureType
1207
1208
1209DIEStructureType::DIEStructureType()
1210{
1211}
1212
1213
1214uint16
1215DIEStructureType::Tag() const
1216{
1217	return DW_TAG_structure_type;
1218}
1219
1220
1221// #pragma mark - DIESubroutineType
1222
1223
1224DIESubroutineType::DIESubroutineType()
1225	:
1226	fReturnType(NULL),
1227	fAddressClass(0),
1228	fPrototyped(false)
1229{
1230}
1231
1232
1233uint16
1234DIESubroutineType::Tag() const
1235{
1236	return DW_TAG_subroutine_type;
1237}
1238
1239
1240status_t
1241DIESubroutineType::AddChild(DebugInfoEntry* child)
1242{
1243	switch (child->Tag()) {
1244		case DW_TAG_formal_parameter:
1245		case DW_TAG_unspecified_parameters:
1246			fParameters.Add(child);
1247			return B_OK;
1248		default:
1249			return DIEDeclaredType::AddChild(child);
1250	}
1251}
1252
1253
1254status_t
1255DIESubroutineType::AddAttribute_address_class(uint16 attributeName,
1256	const AttributeValue& value)
1257{
1258// TODO: How is the address class handled?
1259	fAddressClass = value.constant;
1260	return B_OK;
1261}
1262
1263
1264status_t
1265DIESubroutineType::AddAttribute_prototyped(uint16 attributeName,
1266	const AttributeValue& value)
1267{
1268	fPrototyped = value.flag;
1269	return B_OK;
1270}
1271
1272
1273status_t
1274DIESubroutineType::AddAttribute_type(uint16 attributeName,
1275	const AttributeValue& value)
1276{
1277	fReturnType = dynamic_cast<DIEType*>(value.reference);
1278	return fReturnType != NULL ? B_OK : B_BAD_DATA;
1279}
1280
1281
1282// #pragma mark - DIETypedef
1283
1284
1285DIETypedef::DIETypedef()
1286{
1287}
1288
1289
1290uint16
1291DIETypedef::Tag() const
1292{
1293	return DW_TAG_typedef;
1294}
1295
1296
1297// #pragma mark - DIEUnionType
1298
1299
1300DIEUnionType::DIEUnionType()
1301{
1302}
1303
1304
1305uint16
1306DIEUnionType::Tag() const
1307{
1308	return DW_TAG_union_type;
1309}
1310
1311
1312// #pragma mark - DIEUnspecifiedParameters
1313
1314
1315DIEUnspecifiedParameters::DIEUnspecifiedParameters()
1316{
1317}
1318
1319
1320uint16
1321DIEUnspecifiedParameters::Tag() const
1322{
1323	return DW_TAG_unspecified_parameters;
1324}
1325
1326
1327// #pragma mark - DIEVariant
1328
1329
1330DIEVariant::DIEVariant()
1331{
1332}
1333
1334
1335uint16
1336DIEVariant::Tag() const
1337{
1338	return DW_TAG_variant;
1339}
1340
1341
1342// #pragma mark - DIECommonBlock
1343
1344
1345DIECommonBlock::DIECommonBlock()
1346{
1347}
1348
1349
1350uint16
1351DIECommonBlock::Tag() const
1352{
1353	return DW_TAG_common_block;
1354}
1355
1356
1357LocationDescription*
1358DIECommonBlock::GetLocationDescription()
1359{
1360	return &fLocationDescription;
1361}
1362
1363
1364// #pragma mark - DIECommonInclusion
1365
1366
1367DIECommonInclusion::DIECommonInclusion()
1368{
1369}
1370
1371
1372uint16
1373DIECommonInclusion::Tag() const
1374{
1375	return DW_TAG_common_inclusion;
1376}
1377
1378
1379// #pragma mark - DIEInheritance
1380
1381
1382DIEInheritance::DIEInheritance()
1383	:
1384	fType(NULL)
1385{
1386}
1387
1388
1389uint16
1390DIEInheritance::Tag() const
1391{
1392	return DW_TAG_inheritance;
1393}
1394
1395
1396status_t
1397DIEInheritance::AddAttribute_type(uint16 attributeName,
1398	const AttributeValue& value)
1399{
1400	fType = dynamic_cast<DIEType*>(value.reference);
1401	return fType != NULL ? B_OK : B_BAD_DATA;
1402}
1403
1404
1405status_t
1406DIEInheritance::AddAttribute_data_member_location(uint16 attributeName,
1407	const AttributeValue& value)
1408{
1409	return SetMemberLocation(fLocation, value);
1410}
1411
1412
1413// #pragma mark - DIEInlinedSubroutine
1414
1415
1416DIEInlinedSubroutine::DIEInlinedSubroutine()
1417{
1418}
1419
1420
1421uint16
1422DIEInlinedSubroutine::Tag() const
1423{
1424	return DW_TAG_inlined_subroutine;
1425}
1426
1427
1428// #pragma mark - DIEModule
1429
1430
1431DIEModule::DIEModule()
1432{
1433}
1434
1435
1436uint16
1437DIEModule::Tag() const
1438{
1439	return DW_TAG_module;
1440}
1441
1442
1443// #pragma mark - DIEPointerToMemberType
1444
1445
1446DIEPointerToMemberType::DIEPointerToMemberType()
1447	:
1448	fContainingType(NULL),
1449	fAddressClass(0)
1450{
1451}
1452
1453
1454uint16
1455DIEPointerToMemberType::Tag() const
1456{
1457	return DW_TAG_ptr_to_member_type;
1458}
1459
1460
1461status_t
1462DIEPointerToMemberType::AddAttribute_address_class(uint16 attributeName,
1463	const AttributeValue& value)
1464{
1465// TODO: How is the address class handled?
1466	fAddressClass = value.constant;
1467	return B_OK;
1468}
1469
1470
1471status_t
1472DIEPointerToMemberType::AddAttribute_containing_type(uint16 attributeName,
1473	const AttributeValue& value)
1474{
1475	DebugInfoEntry* type = value.reference;
1476	DIEModifiedType* modifiedType;
1477	while ((modifiedType = dynamic_cast<DIEModifiedType*>(type)) != NULL)
1478		type = modifiedType->GetType();
1479
1480	fContainingType = dynamic_cast<DIECompoundType*>(type);
1481	return fContainingType != NULL ? B_OK : B_BAD_DATA;
1482}
1483
1484
1485status_t
1486DIEPointerToMemberType::AddAttribute_use_location(uint16 attributeName,
1487	const AttributeValue& value)
1488{
1489	if (value.attributeClass == ATTRIBUTE_CLASS_LOCLISTPTR) {
1490		fUseLocation.SetToLocationList(value.pointer);
1491		return B_OK;
1492	}
1493
1494	if (value.attributeClass == ATTRIBUTE_CLASS_BLOCK) {
1495		fUseLocation.SetToExpression(value.block.data, value.block.length);
1496		return B_OK;
1497	}
1498
1499	return B_BAD_DATA;
1500}
1501
1502
1503// #pragma mark - DIESetType
1504
1505
1506DIESetType::DIESetType()
1507{
1508}
1509
1510
1511uint16
1512DIESetType::Tag() const
1513{
1514	return DW_TAG_set_type;
1515}
1516
1517
1518const DynamicAttributeValue*
1519DIESetType::ByteSize() const
1520{
1521	return &fByteSize;
1522}
1523
1524
1525status_t
1526DIESetType::AddAttribute_byte_size(uint16 attributeName,
1527	const AttributeValue& value)
1528{
1529	return SetDynamicAttributeValue(fByteSize, value);
1530}
1531
1532
1533// #pragma mark - DIESubrangeType
1534
1535
1536DIESubrangeType::DIESubrangeType()
1537	:
1538	fThreadsScaled(false)
1539{
1540}
1541
1542
1543uint16
1544DIESubrangeType::Tag() const
1545{
1546	return DW_TAG_subrange_type;
1547}
1548
1549
1550status_t
1551DIESubrangeType::AddAttribute_count(uint16 attributeName,
1552	const AttributeValue& value)
1553{
1554	return SetDynamicAttributeValue(fCount, value);
1555}
1556
1557
1558status_t
1559DIESubrangeType::AddAttribute_lower_bound(uint16 attributeName,
1560	const AttributeValue& value)
1561{
1562	return SetDynamicAttributeValue(fLowerBound, value);
1563}
1564
1565
1566status_t
1567DIESubrangeType::AddAttribute_upper_bound(uint16 attributeName,
1568	const AttributeValue& value)
1569{
1570	return SetDynamicAttributeValue(fUpperBound, value);
1571}
1572
1573
1574status_t
1575DIESubrangeType::AddAttribute_threads_scaled(uint16 attributeName,
1576	const AttributeValue& value)
1577{
1578	fThreadsScaled = value.flag;
1579	return B_OK;
1580}
1581
1582
1583// #pragma mark - DIEWithStatement
1584
1585
1586DIEWithStatement::DIEWithStatement()
1587	:
1588	fType(NULL)
1589{
1590}
1591
1592
1593uint16
1594DIEWithStatement::Tag() const
1595{
1596	return DW_TAG_with_stmt;
1597}
1598
1599
1600LocationDescription*
1601DIEWithStatement::GetLocationDescription()
1602{
1603	return &fLocationDescription;
1604}
1605
1606
1607status_t
1608DIEWithStatement::AddAttribute_type(uint16 attributeName,
1609	const AttributeValue& value)
1610{
1611	fType = dynamic_cast<DIEType*>(value.reference);
1612	return fType != NULL ? B_OK : B_BAD_DATA;
1613}
1614
1615
1616// #pragma mark - DIEAccessDeclaration
1617
1618
1619DIEAccessDeclaration::DIEAccessDeclaration()
1620{
1621}
1622
1623
1624uint16
1625DIEAccessDeclaration::Tag() const
1626{
1627	return DW_TAG_access_declaration;
1628}
1629
1630
1631// #pragma mark - DIEBaseType
1632
1633
1634DIEBaseType::DIEBaseType()
1635	:
1636	fEncoding(0),
1637	fEndianity(0)
1638{
1639}
1640
1641
1642uint16
1643DIEBaseType::Tag() const
1644{
1645	return DW_TAG_base_type;
1646}
1647
1648
1649const DynamicAttributeValue*
1650DIEBaseType::ByteSize() const
1651{
1652	return &fByteSize;
1653}
1654
1655
1656status_t
1657DIEBaseType::AddAttribute_encoding(uint16 attributeName,
1658	const AttributeValue& value)
1659{
1660	fEncoding = value.constant;
1661	return B_OK;
1662}
1663
1664
1665status_t
1666DIEBaseType::AddAttribute_byte_size(uint16 attributeName,
1667	const AttributeValue& value)
1668{
1669	return SetDynamicAttributeValue(fByteSize, value);
1670}
1671
1672
1673status_t
1674DIEBaseType::AddAttribute_bit_size(uint16 attributeName,
1675	const AttributeValue& value)
1676{
1677	return SetDynamicAttributeValue(fBitSize, value);
1678}
1679
1680
1681status_t
1682DIEBaseType::AddAttribute_bit_offset(uint16 attributeName,
1683	const AttributeValue& value)
1684{
1685	return SetDynamicAttributeValue(fBitOffset, value);
1686}
1687
1688
1689status_t
1690DIEBaseType::AddAttribute_data_bit_offset(uint16 attributeName,
1691	const AttributeValue& value)
1692{
1693	return SetDynamicAttributeValue(fDataBitOffset, value);
1694}
1695
1696
1697status_t
1698DIEBaseType::AddAttribute_endianity(uint16 attributeName,
1699	const AttributeValue& value)
1700{
1701	fEndianity = value.constant;
1702	return B_OK;
1703}
1704
1705
1706// #pragma mark - DIECatchBlock
1707
1708
1709DIECatchBlock::DIECatchBlock()
1710{
1711}
1712
1713
1714uint16
1715DIECatchBlock::Tag() const
1716{
1717	return DW_TAG_catch_block;
1718}
1719
1720
1721// #pragma mark - DIEConstType
1722
1723
1724DIEConstType::DIEConstType()
1725{
1726}
1727
1728
1729uint16
1730DIEConstType::Tag() const
1731{
1732	return DW_TAG_const_type;
1733}
1734
1735
1736// #pragma mark - DIEConstant
1737
1738
1739DIEConstant::DIEConstant()
1740	:
1741	fType(NULL)
1742{
1743}
1744
1745
1746uint16
1747DIEConstant::Tag() const
1748{
1749	return DW_TAG_constant;
1750}
1751
1752
1753status_t
1754DIEConstant::AddAttribute_const_value(uint16 attributeName,
1755	const AttributeValue& value)
1756{
1757	return SetConstantAttributeValue(fValue, value);
1758}
1759
1760
1761status_t
1762DIEConstant::AddAttribute_type(uint16 attributeName,
1763	const AttributeValue& value)
1764{
1765	fType = dynamic_cast<DIEType*>(value.reference);
1766	return fType != NULL ? B_OK : B_BAD_DATA;
1767}
1768
1769
1770// #pragma mark - DIEEnumerator
1771
1772
1773DIEEnumerator::DIEEnumerator()
1774{
1775}
1776
1777
1778uint16
1779DIEEnumerator::Tag() const
1780{
1781	return DW_TAG_enumerator;
1782}
1783
1784
1785status_t
1786DIEEnumerator::AddAttribute_const_value(uint16 attributeName,
1787	const AttributeValue& value)
1788{
1789	return SetConstantAttributeValue(fValue, value);
1790}
1791
1792
1793// #pragma mark - DIEFileType
1794
1795
1796DIEFileType::DIEFileType()
1797{
1798}
1799
1800
1801uint16
1802DIEFileType::Tag() const
1803{
1804	return DW_TAG_file_type;
1805}
1806
1807
1808const DynamicAttributeValue*
1809DIEFileType::ByteSize() const
1810{
1811	return &fByteSize;
1812}
1813
1814
1815status_t
1816DIEFileType::AddAttribute_byte_size(uint16 attributeName,
1817	const AttributeValue& value)
1818{
1819	return SetDynamicAttributeValue(fByteSize, value);
1820}
1821
1822
1823// #pragma mark - DIEFriend
1824
1825
1826DIEFriend::DIEFriend()
1827{
1828}
1829
1830
1831uint16
1832DIEFriend::Tag() const
1833{
1834	return DW_TAG_friend;
1835}
1836
1837
1838// #pragma mark - DIENameList
1839
1840
1841DIENameList::DIENameList()
1842{
1843}
1844
1845
1846uint16
1847DIENameList::Tag() const
1848{
1849	return DW_TAG_namelist;
1850}
1851
1852
1853// #pragma mark - DIENameListItem
1854
1855
1856DIENameListItem::DIENameListItem()
1857{
1858}
1859
1860
1861uint16
1862DIENameListItem::Tag() const
1863{
1864	return DW_TAG_namelist_item;
1865}
1866
1867
1868// #pragma mark - DIENamespace
1869
1870
1871DIENamespace::DIENamespace()
1872{
1873}
1874
1875
1876uint16
1877DIENamespace::Tag() const
1878{
1879	return DW_TAG_namespace;
1880}
1881
1882
1883bool
1884DIENamespace::IsNamespace() const
1885{
1886	return true;
1887}
1888
1889
1890status_t
1891DIENamespace::AddChild(DebugInfoEntry* child)
1892{
1893	fChildren.Add(child);
1894	return B_OK;
1895}
1896
1897
1898// #pragma mark - DIEPackedType
1899
1900
1901DIEPackedType::DIEPackedType()
1902{
1903}
1904
1905
1906uint16
1907DIEPackedType::Tag() const
1908{
1909	return DW_TAG_packed_type;
1910}
1911
1912
1913// #pragma mark - DIESubprogram
1914
1915
1916DIESubprogram::DIESubprogram()
1917	:
1918	fLowPC(0),
1919	fHighPC(0),
1920	fAddressRangesOffset(-1),
1921	fSpecification(NULL),
1922	fAbstractOrigin(NULL),
1923	fReturnType(NULL),
1924	fAddressClass(0),
1925	fPrototyped(false),
1926	fInline(DW_INL_not_inlined),
1927	fMain(false),
1928	fArtificial(false),
1929	fCallingConvention(DW_CC_normal)
1930{
1931}
1932
1933
1934DIESubprogram::~DIESubprogram()
1935{
1936}
1937
1938
1939uint16
1940DIESubprogram::Tag() const
1941{
1942	return DW_TAG_subprogram;
1943}
1944
1945
1946DebugInfoEntry*
1947DIESubprogram::Specification() const
1948{
1949	return fSpecification;
1950}
1951
1952
1953
1954DebugInfoEntry*
1955DIESubprogram::AbstractOrigin() const
1956{
1957	return fAbstractOrigin;
1958}
1959
1960
1961status_t
1962DIESubprogram::AddChild(DebugInfoEntry* child)
1963{
1964	switch (child->Tag()) {
1965		case DW_TAG_formal_parameter:
1966		case DW_TAG_unspecified_parameters:
1967			fParameters.Add(child);
1968			return B_OK;
1969		case DW_TAG_variable:
1970			fVariables.Add(child);
1971			return B_OK;
1972		case DW_TAG_lexical_block:
1973			fBlocks.Add(child);
1974			return B_OK;
1975		case DW_TAG_template_type_parameter:
1976			fTemplateTypeParameters.Add(child);
1977			return B_OK;
1978		case DW_TAG_template_value_parameter:
1979			fTemplateValueParameters.Add(child);
1980			return B_OK;
1981		case DW_TAG_GNU_call_site:
1982			fCallSites.Add(child);
1983			return B_OK;
1984		default:
1985			return DIENamespace::AddChild(child);
1986	}
1987}
1988
1989
1990
1991status_t
1992DIESubprogram::AddAttribute_low_pc(uint16 attributeName,
1993	const AttributeValue& value)
1994{
1995	fLowPC = value.address;
1996	return B_OK;
1997}
1998
1999
2000status_t
2001DIESubprogram::AddAttribute_high_pc(uint16 attributeName,
2002	const AttributeValue& value)
2003{
2004	fHighPC = value.address;
2005	if (fLowPC != 0 && fHighPC < fLowPC)
2006		fHighPC += fLowPC;
2007
2008	return B_OK;
2009}
2010
2011
2012status_t
2013DIESubprogram::AddAttribute_ranges(uint16 attributeName,
2014	const AttributeValue& value)
2015{
2016	fAddressRangesOffset = value.pointer;
2017	return B_OK;
2018}
2019
2020
2021status_t
2022DIESubprogram::AddAttribute_specification(uint16 attributeName,
2023	const AttributeValue& value)
2024{
2025	fSpecification = dynamic_cast<DIESubprogram*>(value.reference);
2026	return fSpecification != NULL ? B_OK : B_BAD_DATA;
2027}
2028
2029
2030status_t
2031DIESubprogram::AddAttribute_address_class(uint16 attributeName,
2032	const AttributeValue& value)
2033{
2034// TODO: How is the address class handled?
2035	fAddressClass = value.constant;
2036	return B_OK;
2037}
2038
2039
2040status_t
2041DIESubprogram::AddAttribute_prototyped(uint16 attributeName,
2042	const AttributeValue& value)
2043{
2044	fPrototyped = value.flag;
2045	return B_OK;
2046}
2047
2048
2049status_t
2050DIESubprogram::AddAttribute_type(uint16 attributeName,
2051	const AttributeValue& value)
2052{
2053	fReturnType = dynamic_cast<DIEType*>(value.reference);
2054	return fReturnType != NULL ? B_OK : B_BAD_DATA;
2055}
2056
2057
2058status_t
2059DIESubprogram::AddAttribute_inline(uint16 attributeName,
2060	const AttributeValue& value)
2061{
2062// TODO: How is the address class handled?
2063	fInline = value.constant;
2064	return B_OK;
2065}
2066
2067
2068status_t
2069DIESubprogram::AddAttribute_abstract_origin(uint16 attributeName,
2070	const AttributeValue& value)
2071{
2072	fAbstractOrigin = dynamic_cast<DIESubprogram*>(value.reference);
2073	return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
2074}
2075
2076
2077status_t
2078DIESubprogram::AddAttribute_frame_base(uint16 attributeName,
2079	const AttributeValue& value)
2080{
2081	if (value.attributeClass == ATTRIBUTE_CLASS_LOCLISTPTR) {
2082		fFrameBase.SetToLocationList(value.pointer);
2083		return B_OK;
2084	}
2085
2086	if (value.attributeClass == ATTRIBUTE_CLASS_BLOCK) {
2087		fFrameBase.SetToExpression(value.block.data, value.block.length);
2088		return B_OK;
2089	}
2090
2091	return B_BAD_DATA;
2092}
2093
2094
2095status_t
2096DIESubprogram::AddAttribute_artificial(uint16 attributeName,
2097	const AttributeValue& value)
2098{
2099	fArtificial = value.flag;
2100	return B_OK;
2101}
2102
2103
2104status_t
2105DIESubprogram::AddAttribute_calling_convention(uint16 attributeName,
2106	const AttributeValue& value)
2107{
2108	fCallingConvention = value.constant;
2109	return B_OK;
2110}
2111
2112
2113status_t
2114DIESubprogram::AddAttribute_main_subprogram(uint16 attributeName,
2115	const AttributeValue& value)
2116{
2117	fMain = true;
2118	return B_OK;
2119}
2120
2121
2122// #pragma mark - DIETemplateTypeParameter
2123
2124
2125DIETemplateTypeParameter::DIETemplateTypeParameter()
2126	:
2127	fType(NULL)
2128{
2129}
2130
2131
2132uint16
2133DIETemplateTypeParameter::Tag() const
2134{
2135	return DW_TAG_template_type_parameter;
2136}
2137
2138
2139status_t
2140DIETemplateTypeParameter::AddAttribute_type(uint16 attributeName,
2141	const AttributeValue& value)
2142{
2143	fType = dynamic_cast<DIEType*>(value.reference);
2144	return fType != NULL ? B_OK : B_BAD_DATA;
2145}
2146
2147
2148// #pragma mark - DIETemplateValueParameter
2149
2150
2151DIETemplateValueParameter::DIETemplateValueParameter()
2152	:
2153	fType(NULL)
2154{
2155}
2156
2157
2158uint16
2159DIETemplateValueParameter::Tag() const
2160{
2161	return DW_TAG_template_value_parameter;
2162}
2163
2164
2165status_t
2166DIETemplateValueParameter::AddAttribute_const_value(uint16 attributeName,
2167	const AttributeValue& value)
2168{
2169	return SetConstantAttributeValue(fValue, value);
2170}
2171
2172
2173status_t
2174DIETemplateValueParameter::AddAttribute_type(uint16 attributeName,
2175	const AttributeValue& value)
2176{
2177	fType = dynamic_cast<DIEType*>(value.reference);
2178	return fType != NULL ? B_OK : B_BAD_DATA;
2179}
2180
2181
2182// #pragma mark - DIEThrownType
2183
2184
2185DIEThrownType::DIEThrownType()
2186	:
2187	fType(NULL)
2188{
2189}
2190
2191
2192uint16
2193DIEThrownType::Tag() const
2194{
2195	return DW_TAG_thrown_type;
2196}
2197
2198
2199status_t
2200DIEThrownType::AddAttribute_type(uint16 attributeName,
2201	const AttributeValue& value)
2202{
2203	fType = dynamic_cast<DIEType*>(value.reference);
2204	return fType != NULL ? B_OK : B_BAD_DATA;
2205}
2206
2207
2208// #pragma mark - DIETryBlock
2209
2210
2211DIETryBlock::DIETryBlock()
2212{
2213}
2214
2215
2216uint16
2217DIETryBlock::Tag() const
2218{
2219	return DW_TAG_try_block;
2220}
2221
2222
2223// #pragma mark - DIEVariantPart
2224
2225
2226DIEVariantPart::DIEVariantPart()
2227	:
2228	fType(NULL)
2229{
2230}
2231
2232
2233uint16
2234DIEVariantPart::Tag() const
2235{
2236	return DW_TAG_variant_part;
2237}
2238
2239
2240status_t
2241DIEVariantPart::AddAttribute_type(uint16 attributeName,
2242	const AttributeValue& value)
2243{
2244	fType = dynamic_cast<DIEType*>(value.reference);
2245	return fType != NULL ? B_OK : B_BAD_DATA;
2246}
2247
2248
2249// #pragma mark - DIEVariable
2250
2251
2252DIEVariable::DIEVariable()
2253	:
2254	fType(NULL),
2255	fSpecification(NULL),
2256	fAbstractOrigin(NULL),
2257	fStartScope(0)
2258{
2259}
2260
2261
2262uint16
2263DIEVariable::Tag() const
2264{
2265	return DW_TAG_variable;
2266}
2267
2268
2269DebugInfoEntry*
2270DIEVariable::Specification() const
2271{
2272	return fSpecification;
2273}
2274
2275
2276
2277DebugInfoEntry*
2278DIEVariable::AbstractOrigin() const
2279{
2280	return fAbstractOrigin;
2281}
2282
2283
2284LocationDescription*
2285DIEVariable::GetLocationDescription()
2286{
2287	return &fLocationDescription;
2288}
2289
2290
2291status_t
2292DIEVariable::AddAttribute_const_value(uint16 attributeName,
2293	const AttributeValue& value)
2294{
2295	return SetConstantAttributeValue(fValue, value);
2296}
2297
2298
2299status_t
2300DIEVariable::AddAttribute_type(uint16 attributeName,
2301	const AttributeValue& value)
2302{
2303	fType = dynamic_cast<DIEType*>(value.reference);
2304	return fType != NULL ? B_OK : B_BAD_DATA;
2305}
2306
2307
2308status_t
2309DIEVariable::AddAttribute_specification(uint16 attributeName,
2310	const AttributeValue& value)
2311{
2312	fSpecification = dynamic_cast<DIEVariable*>(value.reference);
2313	// in the case of static variables declared within a compound type,
2314	// the specification may point to a member entry rather than
2315	// a variable entry
2316	if (fSpecification == NULL)
2317		fSpecification = dynamic_cast<DIEMember*>(value.reference);
2318
2319	return fSpecification != NULL ? B_OK : B_BAD_DATA;
2320}
2321
2322
2323status_t
2324DIEVariable::AddAttribute_abstract_origin(uint16 attributeName,
2325	const AttributeValue& value)
2326{
2327	fAbstractOrigin = dynamic_cast<DIEVariable*>(value.reference);
2328	return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
2329}
2330
2331
2332status_t
2333DIEVariable::AddAttribute_start_scope(uint16 attributeName,
2334	const AttributeValue& value)
2335{
2336	fStartScope = value.constant;
2337	return B_OK;
2338}
2339
2340
2341status_t
2342DIEVariable::AddAttribute_external(uint16 attributeName,
2343	const AttributeValue& value)
2344{
2345	fIsExternal = value.flag;
2346	return B_OK;
2347}
2348
2349
2350// #pragma mark - DIEVolatileType
2351
2352
2353DIEVolatileType::DIEVolatileType()
2354{
2355}
2356
2357
2358uint16
2359DIEVolatileType::Tag() const
2360{
2361	return DW_TAG_volatile_type;
2362}
2363
2364
2365status_t
2366DIEVolatileType::AddAttribute_decl_file(uint16 attributeName,
2367	const AttributeValue& value)
2368{
2369	fDeclarationLocation.SetFile(value.constant);
2370	return B_OK;
2371}
2372
2373
2374status_t
2375DIEVolatileType::AddAttribute_decl_line(uint16 attributeName,
2376	const AttributeValue& value)
2377{
2378	fDeclarationLocation.SetLine(value.constant);
2379	return B_OK;
2380}
2381
2382
2383status_t
2384DIEVolatileType::AddAttribute_decl_column(uint16 attributeName,
2385	const AttributeValue& value)
2386{
2387	fDeclarationLocation.SetColumn(value.constant);
2388	return B_OK;
2389}
2390
2391
2392// #pragma mark - DIEDwarfProcedure
2393
2394
2395DIEDwarfProcedure::DIEDwarfProcedure()
2396{
2397}
2398
2399
2400uint16
2401DIEDwarfProcedure::Tag() const
2402{
2403	return DW_TAG_dwarf_procedure;
2404}
2405
2406
2407LocationDescription*
2408DIEDwarfProcedure::GetLocationDescription()
2409{
2410	return &fLocationDescription;
2411}
2412
2413
2414// #pragma mark - DIERestrictType
2415
2416
2417DIERestrictType::DIERestrictType()
2418{
2419}
2420
2421
2422uint16
2423DIERestrictType::Tag() const
2424{
2425	return DW_TAG_restrict_type;
2426}
2427
2428
2429// #pragma mark - DIEInterfaceType
2430
2431
2432DIEInterfaceType::DIEInterfaceType()
2433{
2434}
2435
2436
2437uint16
2438DIEInterfaceType::Tag() const
2439{
2440	return DW_TAG_interface_type;
2441}
2442
2443
2444// #pragma mark - DIEImportedModule
2445
2446
2447DIEImportedModule::DIEImportedModule()
2448{
2449}
2450
2451
2452uint16
2453DIEImportedModule::Tag() const
2454{
2455	return DW_TAG_imported_module;
2456}
2457
2458
2459// #pragma mark - DIEUnspecifiedType
2460
2461
2462DIEUnspecifiedType::DIEUnspecifiedType()
2463{
2464}
2465
2466
2467uint16
2468DIEUnspecifiedType::Tag() const
2469{
2470	return DW_TAG_unspecified_type;
2471}
2472
2473
2474status_t
2475DIEUnspecifiedType::AddAttribute_decl_file(uint16 attributeName,
2476	const AttributeValue& value)
2477{
2478	fDeclarationLocation.SetFile(value.constant);
2479	return B_OK;
2480}
2481
2482
2483status_t
2484DIEUnspecifiedType::AddAttribute_decl_line(uint16 attributeName,
2485	const AttributeValue& value)
2486{
2487	fDeclarationLocation.SetLine(value.constant);
2488	return B_OK;
2489}
2490
2491
2492status_t
2493DIEUnspecifiedType::AddAttribute_decl_column(uint16 attributeName,
2494	const AttributeValue& value)
2495{
2496	fDeclarationLocation.SetColumn(value.constant);
2497	return B_OK;
2498}
2499
2500
2501// #pragma mark - DIEPartialUnit
2502
2503
2504DIEPartialUnit::DIEPartialUnit()
2505{
2506}
2507
2508
2509uint16
2510DIEPartialUnit::Tag() const
2511{
2512	return DW_TAG_partial_unit;
2513}
2514
2515
2516// #pragma mark - DIEImportedUnit
2517
2518
2519DIEImportedUnit::DIEImportedUnit()
2520{
2521}
2522
2523
2524uint16
2525DIEImportedUnit::Tag() const
2526{
2527	return DW_TAG_imported_unit;
2528}
2529
2530
2531// #pragma mark - DIECondition
2532
2533
2534DIECondition::DIECondition()
2535{
2536}
2537
2538
2539uint16
2540DIECondition::Tag() const
2541{
2542	return DW_TAG_condition;
2543}
2544
2545
2546// #pragma mark - DIESharedType
2547
2548
2549DIESharedType::DIESharedType()
2550{
2551	fBlockSize.SetTo(~(uint64)0);
2552}
2553
2554
2555uint16
2556DIESharedType::Tag() const
2557{
2558	return DW_TAG_shared_type;
2559}
2560
2561
2562status_t
2563DIESharedType::AddAttribute_count(uint16 attributeName,
2564	const AttributeValue& value)
2565{
2566	return SetDynamicAttributeValue(fBlockSize, value);
2567}
2568
2569
2570status_t
2571DIESharedType::AddAttribute_decl_file(uint16 attributeName,
2572	const AttributeValue& value)
2573{
2574	fDeclarationLocation.SetFile(value.constant);
2575	return B_OK;
2576}
2577
2578
2579status_t
2580DIESharedType::AddAttribute_decl_line(uint16 attributeName,
2581	const AttributeValue& value)
2582{
2583	fDeclarationLocation.SetLine(value.constant);
2584	return B_OK;
2585}
2586
2587
2588status_t
2589DIESharedType::AddAttribute_decl_column(uint16 attributeName,
2590	const AttributeValue& value)
2591{
2592	fDeclarationLocation.SetColumn(value.constant);
2593	return B_OK;
2594}
2595
2596
2597// #pragma mark - DIETypeUnit
2598
2599
2600DIETypeUnit::DIETypeUnit()
2601{
2602}
2603
2604
2605uint16
2606DIETypeUnit::Tag() const
2607{
2608	return DW_TAG_type_unit;
2609}
2610
2611
2612// #pragma mark - DIERValueReferenceType
2613
2614
2615DIERValueReferenceType::DIERValueReferenceType()
2616{
2617}
2618
2619
2620uint16
2621DIERValueReferenceType::Tag() const
2622{
2623	return DW_TAG_rvalue_reference_type;
2624}
2625
2626
2627// #pragma mark - DIETemplateTemplateParameter
2628
2629
2630DIETemplateTemplateParameter::DIETemplateTemplateParameter()
2631	:
2632	fName(NULL)
2633{
2634}
2635
2636
2637uint16
2638DIETemplateTemplateParameter::Tag() const
2639{
2640	return DW_TAG_GNU_template_template_param;
2641}
2642
2643
2644const char*
2645DIETemplateTemplateParameter::Name() const
2646{
2647	return fName;
2648}
2649
2650
2651status_t
2652DIETemplateTemplateParameter::AddAttribute_name(uint16 attributeName,
2653	const AttributeValue& value)
2654{
2655	fName = value.string;
2656	return B_OK;
2657}
2658
2659
2660// #pragma mark - DIETemplateTypeParameterPack
2661
2662
2663DIETemplateTypeParameterPack::DIETemplateTypeParameterPack()
2664	:
2665	fName(NULL)
2666{
2667}
2668
2669
2670uint16
2671DIETemplateTypeParameterPack::Tag() const
2672{
2673	return DW_TAG_GNU_template_parameter_pack;
2674}
2675
2676
2677const char*
2678DIETemplateTypeParameterPack::Name() const
2679{
2680	return fName;
2681}
2682
2683
2684status_t
2685DIETemplateTypeParameterPack::AddAttribute_name(uint16 attributeName,
2686	const AttributeValue& value)
2687{
2688	fName = value.string;
2689	return B_OK;
2690}
2691
2692
2693status_t
2694DIETemplateTypeParameterPack::AddChild(DebugInfoEntry* child)
2695{
2696	if (child->Tag() == DW_TAG_template_type_parameter) {
2697		fChildren.Add(child);
2698		return B_OK;
2699	}
2700
2701	return DIEDeclaredBase::AddChild(child);
2702}
2703
2704
2705// #pragma mark - DIETemplateValueParameterPack
2706
2707
2708DIETemplateValueParameterPack::DIETemplateValueParameterPack()
2709	:
2710	fName(NULL)
2711{
2712}
2713
2714
2715uint16
2716DIETemplateValueParameterPack::Tag() const
2717{
2718	return DW_TAG_GNU_formal_parameter_pack;
2719}
2720
2721
2722const char*
2723DIETemplateValueParameterPack::Name() const
2724{
2725	return fName;
2726}
2727
2728
2729status_t
2730DIETemplateValueParameterPack::AddAttribute_name(uint16 attributeName,
2731	const AttributeValue& value)
2732{
2733	fName = value.string;
2734	return B_OK;
2735}
2736
2737
2738status_t
2739DIETemplateValueParameterPack::AddChild(DebugInfoEntry* child)
2740{
2741	if (child->Tag() == DW_TAG_formal_parameter) {
2742		fChildren.Add(child);
2743		return B_OK;
2744	}
2745
2746	return DIEDeclaredBase::AddChild(child);
2747}
2748
2749
2750// #pragma mark - DIECallSite
2751
2752
2753DIECallSite::DIECallSite()
2754	:
2755	fName(NULL)
2756{
2757}
2758
2759
2760uint16
2761DIECallSite::Tag() const
2762{
2763	return DW_TAG_GNU_call_site;
2764}
2765
2766
2767const char*
2768DIECallSite::Name() const
2769{
2770	return fName;
2771}
2772
2773
2774status_t
2775DIECallSite::AddAttribute_name(uint16 attributeName,
2776	const AttributeValue& value)
2777{
2778	fName = value.string;
2779	return B_OK;
2780}
2781
2782
2783status_t
2784DIECallSite::AddChild(DebugInfoEntry* child)
2785{
2786	if (child->Tag() == DW_TAG_GNU_call_site_parameter) {
2787		fChildren.Add(child);
2788		return B_OK;
2789	}
2790
2791	return DIEDeclaredBase::AddChild(child);
2792}
2793
2794
2795// #pragma mark - DIECallSiteParameter
2796
2797
2798DIECallSiteParameter::DIECallSiteParameter()
2799	:
2800	fName(NULL)
2801{
2802}
2803
2804
2805uint16
2806DIECallSiteParameter::Tag() const
2807{
2808	return DW_TAG_GNU_call_site_parameter;
2809}
2810
2811
2812const char*
2813DIECallSiteParameter::Name() const
2814{
2815	return fName;
2816}
2817
2818
2819status_t
2820DIECallSiteParameter::AddAttribute_name(uint16 attributeName,
2821	const AttributeValue& value)
2822{
2823	fName = value.string;
2824	return B_OK;
2825}
2826
2827
2828status_t
2829DIECallSiteParameter::AddChild(DebugInfoEntry* child)
2830{
2831	return DIEDeclaredBase::AddChild(child);
2832}
2833
2834
2835// #pragma mark - DebugInfoEntryFactory
2836
2837
2838DebugInfoEntryFactory::DebugInfoEntryFactory()
2839{
2840}
2841
2842
2843status_t
2844DebugInfoEntryFactory::CreateDebugInfoEntry(uint16 tag, DebugInfoEntry*& _entry)
2845{
2846	DebugInfoEntry* entry = NULL;
2847
2848	switch (tag) {
2849		case DW_TAG_array_type:
2850			entry = new(std::nothrow) DIEArrayType;
2851			break;
2852		case DW_TAG_class_type:
2853			entry = new(std::nothrow) DIEClassType;
2854			break;
2855		case DW_TAG_entry_point:
2856			entry = new(std::nothrow) DIEEntryPoint;
2857			break;
2858		case DW_TAG_enumeration_type:
2859			entry = new(std::nothrow) DIEEnumerationType;
2860			break;
2861		case DW_TAG_formal_parameter:
2862			entry = new(std::nothrow) DIEFormalParameter;
2863			break;
2864		case DW_TAG_imported_declaration:
2865			entry = new(std::nothrow) DIEImportedDeclaration;
2866			break;
2867		case DW_TAG_label:
2868			entry = new(std::nothrow) DIELabel;
2869			break;
2870		case DW_TAG_lexical_block:
2871			entry = new(std::nothrow) DIELexicalBlock;
2872			break;
2873		case DW_TAG_member:
2874			entry = new(std::nothrow) DIEMember;
2875			break;
2876		case DW_TAG_pointer_type:
2877			entry = new(std::nothrow) DIEPointerType;
2878			break;
2879		case DW_TAG_reference_type:
2880			entry = new(std::nothrow) DIEReferenceType;
2881			break;
2882		case DW_TAG_compile_unit:
2883			entry = new(std::nothrow) DIECompileUnit;
2884			break;
2885		case DW_TAG_string_type:
2886			entry = new(std::nothrow) DIEStringType;
2887			break;
2888		case DW_TAG_structure_type:
2889			entry = new(std::nothrow) DIEStructureType;
2890			break;
2891		case DW_TAG_subroutine_type:
2892			entry = new(std::nothrow) DIESubroutineType;
2893			break;
2894		case DW_TAG_typedef:
2895			entry = new(std::nothrow) DIETypedef;
2896			break;
2897		case DW_TAG_union_type:
2898			entry = new(std::nothrow) DIEUnionType;
2899			break;
2900		case DW_TAG_unspecified_parameters:
2901			entry = new(std::nothrow) DIEUnspecifiedParameters;
2902			break;
2903		case DW_TAG_variant:
2904			entry = new(std::nothrow) DIEVariant;
2905			break;
2906		case DW_TAG_common_block:
2907			entry = new(std::nothrow) DIECommonBlock;
2908			break;
2909		case DW_TAG_common_inclusion:
2910			entry = new(std::nothrow) DIECommonInclusion;
2911			break;
2912		case DW_TAG_inheritance:
2913			entry = new(std::nothrow) DIEInheritance;
2914			break;
2915		case DW_TAG_inlined_subroutine:
2916			entry = new(std::nothrow) DIEInlinedSubroutine;
2917			break;
2918		case DW_TAG_module:
2919			entry = new(std::nothrow) DIEModule;
2920			break;
2921		case DW_TAG_ptr_to_member_type:
2922			entry = new(std::nothrow) DIEPointerToMemberType;
2923			break;
2924		case DW_TAG_set_type:
2925			entry = new(std::nothrow) DIESetType;
2926			break;
2927		case DW_TAG_subrange_type:
2928			entry = new(std::nothrow) DIESubrangeType;
2929			break;
2930		case DW_TAG_with_stmt:
2931			entry = new(std::nothrow) DIEWithStatement;
2932			break;
2933		case DW_TAG_access_declaration:
2934			entry = new(std::nothrow) DIEAccessDeclaration;
2935			break;
2936		case DW_TAG_base_type:
2937			entry = new(std::nothrow) DIEBaseType;
2938			break;
2939		case DW_TAG_catch_block:
2940			entry = new(std::nothrow) DIECatchBlock;
2941			break;
2942		case DW_TAG_const_type:
2943			entry = new(std::nothrow) DIEConstType;
2944			break;
2945		case DW_TAG_constant:
2946			entry = new(std::nothrow) DIEConstant;
2947			break;
2948		case DW_TAG_enumerator:
2949			entry = new(std::nothrow) DIEEnumerator;
2950			break;
2951		case DW_TAG_file_type:
2952			entry = new(std::nothrow) DIEFileType;
2953			break;
2954		case DW_TAG_friend:
2955			entry = new(std::nothrow) DIEFriend;
2956			break;
2957		case DW_TAG_namelist:
2958			entry = new(std::nothrow) DIENameList;
2959			break;
2960		case DW_TAG_namelist_item:
2961			entry = new(std::nothrow) DIENameListItem;
2962			break;
2963		case DW_TAG_packed_type:
2964			entry = new(std::nothrow) DIEPackedType;
2965			break;
2966		case DW_TAG_subprogram:
2967			entry = new(std::nothrow) DIESubprogram;
2968			break;
2969		case DW_TAG_template_type_parameter:
2970			entry = new(std::nothrow) DIETemplateTypeParameter;
2971			break;
2972		case DW_TAG_template_value_parameter:
2973			entry = new(std::nothrow) DIETemplateValueParameter;
2974			break;
2975		case DW_TAG_thrown_type:
2976			entry = new(std::nothrow) DIEThrownType;
2977			break;
2978		case DW_TAG_try_block:
2979			entry = new(std::nothrow) DIETryBlock;
2980			break;
2981		case DW_TAG_variant_part:
2982			entry = new(std::nothrow) DIEVariantPart;
2983			break;
2984		case DW_TAG_variable:
2985			entry = new(std::nothrow) DIEVariable;
2986			break;
2987		case DW_TAG_volatile_type:
2988			entry = new(std::nothrow) DIEVolatileType;
2989			break;
2990		case DW_TAG_dwarf_procedure:
2991			entry = new(std::nothrow) DIEDwarfProcedure;
2992			break;
2993		case DW_TAG_restrict_type:
2994			entry = new(std::nothrow) DIERestrictType;
2995			break;
2996		case DW_TAG_interface_type:
2997			entry = new(std::nothrow) DIEInterfaceType;
2998			break;
2999		case DW_TAG_namespace:
3000			entry = new(std::nothrow) DIENamespace;
3001			break;
3002		case DW_TAG_imported_module:
3003			entry = new(std::nothrow) DIEImportedModule;
3004			break;
3005		case DW_TAG_unspecified_type:
3006			entry = new(std::nothrow) DIEUnspecifiedType;
3007			break;
3008		case DW_TAG_partial_unit:
3009			entry = new(std::nothrow) DIEPartialUnit;
3010			break;
3011		case DW_TAG_imported_unit:
3012			entry = new(std::nothrow) DIEImportedUnit;
3013			break;
3014		case DW_TAG_condition:
3015			entry = new(std::nothrow) DIECondition;
3016			break;
3017		case DW_TAG_shared_type:
3018			entry = new(std::nothrow) DIESharedType;
3019			break;
3020		case DW_TAG_type_unit:
3021			entry = new(std::nothrow) DIETypeUnit;
3022			break;
3023		case DW_TAG_rvalue_reference_type:
3024			entry = new(std::nothrow) DIERValueReferenceType;
3025			break;
3026		case DW_TAG_GNU_template_template_param:
3027			entry = new(std::nothrow) DIETemplateTemplateParameter;
3028			break;
3029		case DW_TAG_GNU_template_parameter_pack:
3030			entry = new(std::nothrow) DIETemplateTypeParameterPack;
3031			break;
3032		case DW_TAG_GNU_formal_parameter_pack:
3033			entry = new(std::nothrow) DIETemplateValueParameterPack;
3034			break;
3035		case DW_TAG_GNU_call_site:
3036			entry = new(std::nothrow) DIECallSite;
3037			break;
3038		case DW_TAG_GNU_call_site_parameter:
3039			entry = new(std::nothrow) DIECallSiteParameter;
3040			break;
3041		default:
3042			return B_ENTRY_NOT_FOUND;
3043			break;
3044	}
3045
3046	_entry = entry;
3047	return B_OK;
3048}
3049