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_LOCLIST) {
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_call_site:
1982		case DW_TAG_GNU_call_site:
1983			fCallSites.Add(child);
1984			return B_OK;
1985		default:
1986			return DIENamespace::AddChild(child);
1987	}
1988}
1989
1990
1991
1992status_t
1993DIESubprogram::AddAttribute_low_pc(uint16 attributeName,
1994	const AttributeValue& value)
1995{
1996	fLowPC = value.address;
1997	return B_OK;
1998}
1999
2000
2001status_t
2002DIESubprogram::AddAttribute_high_pc(uint16 attributeName,
2003	const AttributeValue& value)
2004{
2005	fHighPC = value.address;
2006	if (fLowPC != 0 && fHighPC < fLowPC)
2007		fHighPC += fLowPC;
2008
2009	return B_OK;
2010}
2011
2012
2013status_t
2014DIESubprogram::AddAttribute_ranges(uint16 attributeName,
2015	const AttributeValue& value)
2016{
2017	fAddressRangesOffset = value.pointer;
2018	return B_OK;
2019}
2020
2021
2022status_t
2023DIESubprogram::AddAttribute_specification(uint16 attributeName,
2024	const AttributeValue& value)
2025{
2026	fSpecification = dynamic_cast<DIESubprogram*>(value.reference);
2027	return fSpecification != NULL ? B_OK : B_BAD_DATA;
2028}
2029
2030
2031status_t
2032DIESubprogram::AddAttribute_address_class(uint16 attributeName,
2033	const AttributeValue& value)
2034{
2035// TODO: How is the address class handled?
2036	fAddressClass = value.constant;
2037	return B_OK;
2038}
2039
2040
2041status_t
2042DIESubprogram::AddAttribute_prototyped(uint16 attributeName,
2043	const AttributeValue& value)
2044{
2045	fPrototyped = value.flag;
2046	return B_OK;
2047}
2048
2049
2050status_t
2051DIESubprogram::AddAttribute_type(uint16 attributeName,
2052	const AttributeValue& value)
2053{
2054	fReturnType = dynamic_cast<DIEType*>(value.reference);
2055	return fReturnType != NULL ? B_OK : B_BAD_DATA;
2056}
2057
2058
2059status_t
2060DIESubprogram::AddAttribute_inline(uint16 attributeName,
2061	const AttributeValue& value)
2062{
2063// TODO: How is the address class handled?
2064	fInline = value.constant;
2065	return B_OK;
2066}
2067
2068
2069status_t
2070DIESubprogram::AddAttribute_abstract_origin(uint16 attributeName,
2071	const AttributeValue& value)
2072{
2073	fAbstractOrigin = dynamic_cast<DIESubprogram*>(value.reference);
2074	return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
2075}
2076
2077
2078status_t
2079DIESubprogram::AddAttribute_frame_base(uint16 attributeName,
2080	const AttributeValue& value)
2081{
2082	if (value.attributeClass == ATTRIBUTE_CLASS_LOCLIST) {
2083		fFrameBase.SetToLocationList(value.pointer);
2084		return B_OK;
2085	}
2086
2087	if (value.attributeClass == ATTRIBUTE_CLASS_BLOCK) {
2088		fFrameBase.SetToExpression(value.block.data, value.block.length);
2089		return B_OK;
2090	}
2091
2092	return B_BAD_DATA;
2093}
2094
2095
2096status_t
2097DIESubprogram::AddAttribute_artificial(uint16 attributeName,
2098	const AttributeValue& value)
2099{
2100	fArtificial = value.flag;
2101	return B_OK;
2102}
2103
2104
2105status_t
2106DIESubprogram::AddAttribute_calling_convention(uint16 attributeName,
2107	const AttributeValue& value)
2108{
2109	fCallingConvention = value.constant;
2110	return B_OK;
2111}
2112
2113
2114status_t
2115DIESubprogram::AddAttribute_main_subprogram(uint16 attributeName,
2116	const AttributeValue& value)
2117{
2118	fMain = true;
2119	return B_OK;
2120}
2121
2122
2123// #pragma mark - DIETemplateTypeParameter
2124
2125
2126DIETemplateTypeParameter::DIETemplateTypeParameter()
2127	:
2128	fType(NULL)
2129{
2130}
2131
2132
2133uint16
2134DIETemplateTypeParameter::Tag() const
2135{
2136	return DW_TAG_template_type_parameter;
2137}
2138
2139
2140status_t
2141DIETemplateTypeParameter::AddAttribute_type(uint16 attributeName,
2142	const AttributeValue& value)
2143{
2144	fType = dynamic_cast<DIEType*>(value.reference);
2145	return fType != NULL ? B_OK : B_BAD_DATA;
2146}
2147
2148
2149// #pragma mark - DIETemplateValueParameter
2150
2151
2152DIETemplateValueParameter::DIETemplateValueParameter()
2153	:
2154	fType(NULL)
2155{
2156}
2157
2158
2159uint16
2160DIETemplateValueParameter::Tag() const
2161{
2162	return DW_TAG_template_value_parameter;
2163}
2164
2165
2166status_t
2167DIETemplateValueParameter::AddAttribute_const_value(uint16 attributeName,
2168	const AttributeValue& value)
2169{
2170	return SetConstantAttributeValue(fValue, value);
2171}
2172
2173
2174status_t
2175DIETemplateValueParameter::AddAttribute_type(uint16 attributeName,
2176	const AttributeValue& value)
2177{
2178	fType = dynamic_cast<DIEType*>(value.reference);
2179	return fType != NULL ? B_OK : B_BAD_DATA;
2180}
2181
2182
2183// #pragma mark - DIEThrownType
2184
2185
2186DIEThrownType::DIEThrownType()
2187	:
2188	fType(NULL)
2189{
2190}
2191
2192
2193uint16
2194DIEThrownType::Tag() const
2195{
2196	return DW_TAG_thrown_type;
2197}
2198
2199
2200status_t
2201DIEThrownType::AddAttribute_type(uint16 attributeName,
2202	const AttributeValue& value)
2203{
2204	fType = dynamic_cast<DIEType*>(value.reference);
2205	return fType != NULL ? B_OK : B_BAD_DATA;
2206}
2207
2208
2209// #pragma mark - DIETryBlock
2210
2211
2212DIETryBlock::DIETryBlock()
2213{
2214}
2215
2216
2217uint16
2218DIETryBlock::Tag() const
2219{
2220	return DW_TAG_try_block;
2221}
2222
2223
2224// #pragma mark - DIEVariantPart
2225
2226
2227DIEVariantPart::DIEVariantPart()
2228	:
2229	fType(NULL)
2230{
2231}
2232
2233
2234uint16
2235DIEVariantPart::Tag() const
2236{
2237	return DW_TAG_variant_part;
2238}
2239
2240
2241status_t
2242DIEVariantPart::AddAttribute_type(uint16 attributeName,
2243	const AttributeValue& value)
2244{
2245	fType = dynamic_cast<DIEType*>(value.reference);
2246	return fType != NULL ? B_OK : B_BAD_DATA;
2247}
2248
2249
2250// #pragma mark - DIEVariable
2251
2252
2253DIEVariable::DIEVariable()
2254	:
2255	fType(NULL),
2256	fSpecification(NULL),
2257	fAbstractOrigin(NULL),
2258	fStartScope(0)
2259{
2260}
2261
2262
2263uint16
2264DIEVariable::Tag() const
2265{
2266	return DW_TAG_variable;
2267}
2268
2269
2270DebugInfoEntry*
2271DIEVariable::Specification() const
2272{
2273	return fSpecification;
2274}
2275
2276
2277
2278DebugInfoEntry*
2279DIEVariable::AbstractOrigin() const
2280{
2281	return fAbstractOrigin;
2282}
2283
2284
2285LocationDescription*
2286DIEVariable::GetLocationDescription()
2287{
2288	return &fLocationDescription;
2289}
2290
2291
2292status_t
2293DIEVariable::AddAttribute_const_value(uint16 attributeName,
2294	const AttributeValue& value)
2295{
2296	return SetConstantAttributeValue(fValue, value);
2297}
2298
2299
2300status_t
2301DIEVariable::AddAttribute_type(uint16 attributeName,
2302	const AttributeValue& value)
2303{
2304	fType = dynamic_cast<DIEType*>(value.reference);
2305	return fType != NULL ? B_OK : B_BAD_DATA;
2306}
2307
2308
2309status_t
2310DIEVariable::AddAttribute_specification(uint16 attributeName,
2311	const AttributeValue& value)
2312{
2313	fSpecification = dynamic_cast<DIEVariable*>(value.reference);
2314	// in the case of static variables declared within a compound type,
2315	// the specification may point to a member entry rather than
2316	// a variable entry
2317	if (fSpecification == NULL)
2318		fSpecification = dynamic_cast<DIEMember*>(value.reference);
2319
2320	return fSpecification != NULL ? B_OK : B_BAD_DATA;
2321}
2322
2323
2324status_t
2325DIEVariable::AddAttribute_abstract_origin(uint16 attributeName,
2326	const AttributeValue& value)
2327{
2328	fAbstractOrigin = dynamic_cast<DIEVariable*>(value.reference);
2329	return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
2330}
2331
2332
2333status_t
2334DIEVariable::AddAttribute_start_scope(uint16 attributeName,
2335	const AttributeValue& value)
2336{
2337	fStartScope = value.constant;
2338	return B_OK;
2339}
2340
2341
2342status_t
2343DIEVariable::AddAttribute_external(uint16 attributeName,
2344	const AttributeValue& value)
2345{
2346	fIsExternal = value.flag;
2347	return B_OK;
2348}
2349
2350
2351// #pragma mark - DIEVolatileType
2352
2353
2354DIEVolatileType::DIEVolatileType()
2355{
2356}
2357
2358
2359uint16
2360DIEVolatileType::Tag() const
2361{
2362	return DW_TAG_volatile_type;
2363}
2364
2365
2366status_t
2367DIEVolatileType::AddAttribute_decl_file(uint16 attributeName,
2368	const AttributeValue& value)
2369{
2370	fDeclarationLocation.SetFile(value.constant);
2371	return B_OK;
2372}
2373
2374
2375status_t
2376DIEVolatileType::AddAttribute_decl_line(uint16 attributeName,
2377	const AttributeValue& value)
2378{
2379	fDeclarationLocation.SetLine(value.constant);
2380	return B_OK;
2381}
2382
2383
2384status_t
2385DIEVolatileType::AddAttribute_decl_column(uint16 attributeName,
2386	const AttributeValue& value)
2387{
2388	fDeclarationLocation.SetColumn(value.constant);
2389	return B_OK;
2390}
2391
2392
2393// #pragma mark - DIEDwarfProcedure
2394
2395
2396DIEDwarfProcedure::DIEDwarfProcedure()
2397{
2398}
2399
2400
2401uint16
2402DIEDwarfProcedure::Tag() const
2403{
2404	return DW_TAG_dwarf_procedure;
2405}
2406
2407
2408LocationDescription*
2409DIEDwarfProcedure::GetLocationDescription()
2410{
2411	return &fLocationDescription;
2412}
2413
2414
2415// #pragma mark - DIERestrictType
2416
2417
2418DIERestrictType::DIERestrictType()
2419{
2420}
2421
2422
2423uint16
2424DIERestrictType::Tag() const
2425{
2426	return DW_TAG_restrict_type;
2427}
2428
2429
2430// #pragma mark - DIEInterfaceType
2431
2432
2433DIEInterfaceType::DIEInterfaceType()
2434{
2435}
2436
2437
2438uint16
2439DIEInterfaceType::Tag() const
2440{
2441	return DW_TAG_interface_type;
2442}
2443
2444
2445// #pragma mark - DIEImportedModule
2446
2447
2448DIEImportedModule::DIEImportedModule()
2449{
2450}
2451
2452
2453uint16
2454DIEImportedModule::Tag() const
2455{
2456	return DW_TAG_imported_module;
2457}
2458
2459
2460// #pragma mark - DIEUnspecifiedType
2461
2462
2463DIEUnspecifiedType::DIEUnspecifiedType()
2464{
2465}
2466
2467
2468uint16
2469DIEUnspecifiedType::Tag() const
2470{
2471	return DW_TAG_unspecified_type;
2472}
2473
2474
2475status_t
2476DIEUnspecifiedType::AddAttribute_decl_file(uint16 attributeName,
2477	const AttributeValue& value)
2478{
2479	fDeclarationLocation.SetFile(value.constant);
2480	return B_OK;
2481}
2482
2483
2484status_t
2485DIEUnspecifiedType::AddAttribute_decl_line(uint16 attributeName,
2486	const AttributeValue& value)
2487{
2488	fDeclarationLocation.SetLine(value.constant);
2489	return B_OK;
2490}
2491
2492
2493status_t
2494DIEUnspecifiedType::AddAttribute_decl_column(uint16 attributeName,
2495	const AttributeValue& value)
2496{
2497	fDeclarationLocation.SetColumn(value.constant);
2498	return B_OK;
2499}
2500
2501
2502// #pragma mark - DIEPartialUnit
2503
2504
2505DIEPartialUnit::DIEPartialUnit()
2506{
2507}
2508
2509
2510uint16
2511DIEPartialUnit::Tag() const
2512{
2513	return DW_TAG_partial_unit;
2514}
2515
2516
2517// #pragma mark - DIEImportedUnit
2518
2519
2520DIEImportedUnit::DIEImportedUnit()
2521{
2522}
2523
2524
2525uint16
2526DIEImportedUnit::Tag() const
2527{
2528	return DW_TAG_imported_unit;
2529}
2530
2531
2532// #pragma mark - DIECondition
2533
2534
2535DIECondition::DIECondition()
2536{
2537}
2538
2539
2540uint16
2541DIECondition::Tag() const
2542{
2543	return DW_TAG_condition;
2544}
2545
2546
2547// #pragma mark - DIESharedType
2548
2549
2550DIESharedType::DIESharedType()
2551{
2552	fBlockSize.SetTo(~(uint64)0);
2553}
2554
2555
2556uint16
2557DIESharedType::Tag() const
2558{
2559	return DW_TAG_shared_type;
2560}
2561
2562
2563status_t
2564DIESharedType::AddAttribute_count(uint16 attributeName,
2565	const AttributeValue& value)
2566{
2567	return SetDynamicAttributeValue(fBlockSize, value);
2568}
2569
2570
2571status_t
2572DIESharedType::AddAttribute_decl_file(uint16 attributeName,
2573	const AttributeValue& value)
2574{
2575	fDeclarationLocation.SetFile(value.constant);
2576	return B_OK;
2577}
2578
2579
2580status_t
2581DIESharedType::AddAttribute_decl_line(uint16 attributeName,
2582	const AttributeValue& value)
2583{
2584	fDeclarationLocation.SetLine(value.constant);
2585	return B_OK;
2586}
2587
2588
2589status_t
2590DIESharedType::AddAttribute_decl_column(uint16 attributeName,
2591	const AttributeValue& value)
2592{
2593	fDeclarationLocation.SetColumn(value.constant);
2594	return B_OK;
2595}
2596
2597
2598// #pragma mark - DIETypeUnit
2599
2600
2601DIETypeUnit::DIETypeUnit()
2602{
2603}
2604
2605
2606uint16
2607DIETypeUnit::Tag() const
2608{
2609	return DW_TAG_type_unit;
2610}
2611
2612
2613// #pragma mark - DIERValueReferenceType
2614
2615
2616DIERValueReferenceType::DIERValueReferenceType()
2617{
2618}
2619
2620
2621uint16
2622DIERValueReferenceType::Tag() const
2623{
2624	return DW_TAG_rvalue_reference_type;
2625}
2626
2627
2628// #pragma mark - DIETemplateTemplateParameter
2629
2630
2631DIETemplateTemplateParameter::DIETemplateTemplateParameter()
2632	:
2633	fName(NULL)
2634{
2635}
2636
2637
2638uint16
2639DIETemplateTemplateParameter::Tag() const
2640{
2641	return DW_TAG_GNU_template_template_param;
2642}
2643
2644
2645const char*
2646DIETemplateTemplateParameter::Name() const
2647{
2648	return fName;
2649}
2650
2651
2652status_t
2653DIETemplateTemplateParameter::AddAttribute_name(uint16 attributeName,
2654	const AttributeValue& value)
2655{
2656	fName = value.string;
2657	return B_OK;
2658}
2659
2660
2661// #pragma mark - DIETemplateTypeParameterPack
2662
2663
2664DIETemplateTypeParameterPack::DIETemplateTypeParameterPack()
2665	:
2666	fName(NULL)
2667{
2668}
2669
2670
2671uint16
2672DIETemplateTypeParameterPack::Tag() const
2673{
2674	return DW_TAG_GNU_template_parameter_pack;
2675}
2676
2677
2678const char*
2679DIETemplateTypeParameterPack::Name() const
2680{
2681	return fName;
2682}
2683
2684
2685status_t
2686DIETemplateTypeParameterPack::AddAttribute_name(uint16 attributeName,
2687	const AttributeValue& value)
2688{
2689	fName = value.string;
2690	return B_OK;
2691}
2692
2693
2694status_t
2695DIETemplateTypeParameterPack::AddChild(DebugInfoEntry* child)
2696{
2697	if (child->Tag() == DW_TAG_template_type_parameter) {
2698		fChildren.Add(child);
2699		return B_OK;
2700	}
2701
2702	return DIEDeclaredBase::AddChild(child);
2703}
2704
2705
2706// #pragma mark - DIETemplateValueParameterPack
2707
2708
2709DIETemplateValueParameterPack::DIETemplateValueParameterPack()
2710	:
2711	fName(NULL)
2712{
2713}
2714
2715
2716uint16
2717DIETemplateValueParameterPack::Tag() const
2718{
2719	return DW_TAG_GNU_formal_parameter_pack;
2720}
2721
2722
2723const char*
2724DIETemplateValueParameterPack::Name() const
2725{
2726	return fName;
2727}
2728
2729
2730status_t
2731DIETemplateValueParameterPack::AddAttribute_name(uint16 attributeName,
2732	const AttributeValue& value)
2733{
2734	fName = value.string;
2735	return B_OK;
2736}
2737
2738
2739status_t
2740DIETemplateValueParameterPack::AddChild(DebugInfoEntry* child)
2741{
2742	if (child->Tag() == DW_TAG_formal_parameter) {
2743		fChildren.Add(child);
2744		return B_OK;
2745	}
2746
2747	return DIEDeclaredBase::AddChild(child);
2748}
2749
2750
2751// #pragma mark - DIECallSite
2752
2753
2754DIECallSite::DIECallSite()
2755	:
2756	fName(NULL)
2757{
2758}
2759
2760
2761uint16
2762DIECallSite::Tag() const
2763{
2764	return DW_TAG_GNU_call_site;
2765}
2766
2767
2768const char*
2769DIECallSite::Name() const
2770{
2771	return fName;
2772}
2773
2774
2775status_t
2776DIECallSite::AddAttribute_name(uint16 attributeName,
2777	const AttributeValue& value)
2778{
2779	fName = value.string;
2780	return B_OK;
2781}
2782
2783
2784status_t
2785DIECallSite::AddChild(DebugInfoEntry* child)
2786{
2787	if (child->Tag() == DW_TAG_GNU_call_site_parameter
2788		|| child->Tag() == DW_TAG_call_site_parameter) {
2789		fChildren.Add(child);
2790		return B_OK;
2791	}
2792
2793	return DIEDeclaredBase::AddChild(child);
2794}
2795
2796
2797// #pragma mark - DIECallSiteParameter
2798
2799
2800DIECallSiteParameter::DIECallSiteParameter()
2801	:
2802	fName(NULL)
2803{
2804}
2805
2806
2807uint16
2808DIECallSiteParameter::Tag() const
2809{
2810	return DW_TAG_GNU_call_site_parameter;
2811}
2812
2813
2814const char*
2815DIECallSiteParameter::Name() const
2816{
2817	return fName;
2818}
2819
2820
2821status_t
2822DIECallSiteParameter::AddAttribute_name(uint16 attributeName,
2823	const AttributeValue& value)
2824{
2825	fName = value.string;
2826	return B_OK;
2827}
2828
2829
2830status_t
2831DIECallSiteParameter::AddChild(DebugInfoEntry* child)
2832{
2833	return DIEDeclaredBase::AddChild(child);
2834}
2835
2836
2837// #pragma mark - DebugInfoEntryFactory
2838
2839
2840DebugInfoEntryFactory::DebugInfoEntryFactory()
2841{
2842}
2843
2844
2845status_t
2846DebugInfoEntryFactory::CreateDebugInfoEntry(uint16 tag, DebugInfoEntry*& _entry)
2847{
2848	DebugInfoEntry* entry = NULL;
2849
2850	switch (tag) {
2851		case DW_TAG_array_type:
2852			entry = new(std::nothrow) DIEArrayType;
2853			break;
2854		case DW_TAG_class_type:
2855			entry = new(std::nothrow) DIEClassType;
2856			break;
2857		case DW_TAG_entry_point:
2858			entry = new(std::nothrow) DIEEntryPoint;
2859			break;
2860		case DW_TAG_enumeration_type:
2861			entry = new(std::nothrow) DIEEnumerationType;
2862			break;
2863		case DW_TAG_formal_parameter:
2864			entry = new(std::nothrow) DIEFormalParameter;
2865			break;
2866		case DW_TAG_imported_declaration:
2867			entry = new(std::nothrow) DIEImportedDeclaration;
2868			break;
2869		case DW_TAG_label:
2870			entry = new(std::nothrow) DIELabel;
2871			break;
2872		case DW_TAG_lexical_block:
2873			entry = new(std::nothrow) DIELexicalBlock;
2874			break;
2875		case DW_TAG_member:
2876			entry = new(std::nothrow) DIEMember;
2877			break;
2878		case DW_TAG_pointer_type:
2879			entry = new(std::nothrow) DIEPointerType;
2880			break;
2881		case DW_TAG_reference_type:
2882			entry = new(std::nothrow) DIEReferenceType;
2883			break;
2884		case DW_TAG_compile_unit:
2885			entry = new(std::nothrow) DIECompileUnit;
2886			break;
2887		case DW_TAG_string_type:
2888			entry = new(std::nothrow) DIEStringType;
2889			break;
2890		case DW_TAG_structure_type:
2891			entry = new(std::nothrow) DIEStructureType;
2892			break;
2893		case DW_TAG_subroutine_type:
2894			entry = new(std::nothrow) DIESubroutineType;
2895			break;
2896		case DW_TAG_typedef:
2897			entry = new(std::nothrow) DIETypedef;
2898			break;
2899		case DW_TAG_union_type:
2900			entry = new(std::nothrow) DIEUnionType;
2901			break;
2902		case DW_TAG_unspecified_parameters:
2903			entry = new(std::nothrow) DIEUnspecifiedParameters;
2904			break;
2905		case DW_TAG_variant:
2906			entry = new(std::nothrow) DIEVariant;
2907			break;
2908		case DW_TAG_common_block:
2909			entry = new(std::nothrow) DIECommonBlock;
2910			break;
2911		case DW_TAG_common_inclusion:
2912			entry = new(std::nothrow) DIECommonInclusion;
2913			break;
2914		case DW_TAG_inheritance:
2915			entry = new(std::nothrow) DIEInheritance;
2916			break;
2917		case DW_TAG_inlined_subroutine:
2918			entry = new(std::nothrow) DIEInlinedSubroutine;
2919			break;
2920		case DW_TAG_module:
2921			entry = new(std::nothrow) DIEModule;
2922			break;
2923		case DW_TAG_ptr_to_member_type:
2924			entry = new(std::nothrow) DIEPointerToMemberType;
2925			break;
2926		case DW_TAG_set_type:
2927			entry = new(std::nothrow) DIESetType;
2928			break;
2929		case DW_TAG_subrange_type:
2930			entry = new(std::nothrow) DIESubrangeType;
2931			break;
2932		case DW_TAG_with_stmt:
2933			entry = new(std::nothrow) DIEWithStatement;
2934			break;
2935		case DW_TAG_access_declaration:
2936			entry = new(std::nothrow) DIEAccessDeclaration;
2937			break;
2938		case DW_TAG_base_type:
2939			entry = new(std::nothrow) DIEBaseType;
2940			break;
2941		case DW_TAG_catch_block:
2942			entry = new(std::nothrow) DIECatchBlock;
2943			break;
2944		case DW_TAG_const_type:
2945			entry = new(std::nothrow) DIEConstType;
2946			break;
2947		case DW_TAG_constant:
2948			entry = new(std::nothrow) DIEConstant;
2949			break;
2950		case DW_TAG_enumerator:
2951			entry = new(std::nothrow) DIEEnumerator;
2952			break;
2953		case DW_TAG_file_type:
2954			entry = new(std::nothrow) DIEFileType;
2955			break;
2956		case DW_TAG_friend:
2957			entry = new(std::nothrow) DIEFriend;
2958			break;
2959		case DW_TAG_namelist:
2960			entry = new(std::nothrow) DIENameList;
2961			break;
2962		case DW_TAG_namelist_item:
2963			entry = new(std::nothrow) DIENameListItem;
2964			break;
2965		case DW_TAG_packed_type:
2966			entry = new(std::nothrow) DIEPackedType;
2967			break;
2968		case DW_TAG_subprogram:
2969			entry = new(std::nothrow) DIESubprogram;
2970			break;
2971		case DW_TAG_template_type_parameter:
2972			entry = new(std::nothrow) DIETemplateTypeParameter;
2973			break;
2974		case DW_TAG_template_value_parameter:
2975			entry = new(std::nothrow) DIETemplateValueParameter;
2976			break;
2977		case DW_TAG_thrown_type:
2978			entry = new(std::nothrow) DIEThrownType;
2979			break;
2980		case DW_TAG_try_block:
2981			entry = new(std::nothrow) DIETryBlock;
2982			break;
2983		case DW_TAG_variant_part:
2984			entry = new(std::nothrow) DIEVariantPart;
2985			break;
2986		case DW_TAG_variable:
2987			entry = new(std::nothrow) DIEVariable;
2988			break;
2989		case DW_TAG_volatile_type:
2990			entry = new(std::nothrow) DIEVolatileType;
2991			break;
2992		case DW_TAG_dwarf_procedure:
2993			entry = new(std::nothrow) DIEDwarfProcedure;
2994			break;
2995		case DW_TAG_restrict_type:
2996			entry = new(std::nothrow) DIERestrictType;
2997			break;
2998		case DW_TAG_interface_type:
2999			entry = new(std::nothrow) DIEInterfaceType;
3000			break;
3001		case DW_TAG_namespace:
3002			entry = new(std::nothrow) DIENamespace;
3003			break;
3004		case DW_TAG_imported_module:
3005			entry = new(std::nothrow) DIEImportedModule;
3006			break;
3007		case DW_TAG_unspecified_type:
3008			entry = new(std::nothrow) DIEUnspecifiedType;
3009			break;
3010		case DW_TAG_partial_unit:
3011			entry = new(std::nothrow) DIEPartialUnit;
3012			break;
3013		case DW_TAG_imported_unit:
3014			entry = new(std::nothrow) DIEImportedUnit;
3015			break;
3016		case DW_TAG_condition:
3017			entry = new(std::nothrow) DIECondition;
3018			break;
3019		case DW_TAG_shared_type:
3020			entry = new(std::nothrow) DIESharedType;
3021			break;
3022		case DW_TAG_type_unit:
3023			entry = new(std::nothrow) DIETypeUnit;
3024			break;
3025		case DW_TAG_rvalue_reference_type:
3026			entry = new(std::nothrow) DIERValueReferenceType;
3027			break;
3028		case DW_TAG_GNU_template_template_param:
3029			entry = new(std::nothrow) DIETemplateTemplateParameter;
3030			break;
3031		case DW_TAG_GNU_template_parameter_pack:
3032			entry = new(std::nothrow) DIETemplateTypeParameterPack;
3033			break;
3034		case DW_TAG_GNU_formal_parameter_pack:
3035			entry = new(std::nothrow) DIETemplateValueParameterPack;
3036			break;
3037		case DW_TAG_call_site:
3038		case DW_TAG_GNU_call_site:
3039			entry = new(std::nothrow) DIECallSite;
3040			break;
3041		case DW_TAG_call_site_parameter:
3042		case DW_TAG_GNU_call_site_parameter:
3043			entry = new(std::nothrow) DIECallSiteParameter;
3044			break;
3045		default:
3046			return B_ENTRY_NOT_FOUND;
3047			break;
3048	}
3049
3050	_entry = entry;
3051	return B_OK;
3052}
3053