2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
7 #include "DebugInfoEntries.h"
11 #include "AttributeValue.h"
15 #define DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(name) \
17 DebugInfoEntry::AddAttribute_##name(uint16 attributeName, \
18 const AttributeValue& value) \
20 return ATTRIBUTE_NOT_HANDLED; \
24 DebugInfoEntry::DebugInfoEntry()
31 DebugInfoEntry::~DebugInfoEntry()
37 DebugInfoEntry::InitAfterHierarchy(DebugInfoEntryInitInfo
& info
)
44 DebugInfoEntry::InitAfterAttributes(DebugInfoEntryInitInfo
& info
)
51 DebugInfoEntry::SetParent(DebugInfoEntry
* parent
)
58 DebugInfoEntry::IsType() const
65 DebugInfoEntry::IsNamespace() const
72 DebugInfoEntry::Name() const
78 DebugInfoEntry::Description() const
85 DebugInfoEntry::Specification() const
92 DebugInfoEntry::AbstractOrigin() const
99 DebugInfoEntry::SignatureType() const
106 DebugInfoEntry::GetLocationDescription()
113 DebugInfoEntry::GetDeclarationFile(uint32
& _file
) const
115 DeclarationLocation
* location
= const_cast<DebugInfoEntry
*>(this)
116 ->GetDeclarationLocation();
117 if (location
== NULL
|| !location
->IsFileSet())
120 _file
= location
->file
;
126 DebugInfoEntry::GetDeclarationLine(uint32
& _line
) const
128 DeclarationLocation
* location
= const_cast<DebugInfoEntry
*>(this)
129 ->GetDeclarationLocation();
130 if (location
== NULL
|| !location
->IsLineSet())
133 _line
= location
->line
;
139 DebugInfoEntry::GetDeclarationColumn(uint32
& _column
) const
141 DeclarationLocation
* location
= const_cast<DebugInfoEntry
*>(this)
142 ->GetDeclarationLocation();
143 if (location
== NULL
|| !location
->IsColumnSet())
146 _column
= location
->column
;
152 DebugInfoEntry::AddChild(DebugInfoEntry
* child
)
154 // ignore children where we don't expect them
155 return ENTRY_NOT_HANDLED
;
160 DebugInfoEntry::AddAttribute_decl_file(uint16 attributeName
,
161 const AttributeValue
& value
)
163 if (DeclarationLocation
* location
= GetDeclarationLocation()) {
164 location
->SetFile(value
.constant
);
168 return ATTRIBUTE_NOT_HANDLED
;
173 DebugInfoEntry::AddAttribute_decl_line(uint16 attributeName
,
174 const AttributeValue
& value
)
176 if (DeclarationLocation
* location
= GetDeclarationLocation()) {
177 location
->SetLine(value
.constant
);
181 return ATTRIBUTE_NOT_HANDLED
;
186 DebugInfoEntry::AddAttribute_decl_column(uint16 attributeName
,
187 const AttributeValue
& value
)
189 if (DeclarationLocation
* location
= GetDeclarationLocation()) {
190 location
->SetColumn(value
.constant
);
194 return ATTRIBUTE_NOT_HANDLED
;
199 DebugInfoEntry::AddAttribute_location(uint16 attributeName
,
200 const AttributeValue
& value
)
202 if (LocationDescription
* location
= GetLocationDescription()) {
203 if (value
.attributeClass
== ATTRIBUTE_CLASS_LOCLISTPTR
) {
204 location
->SetToLocationList(value
.pointer
);
208 if (value
.attributeClass
== ATTRIBUTE_CLASS_BLOCK
) {
209 location
->SetToExpression(value
.block
.data
, value
.block
.length
);
215 return ATTRIBUTE_NOT_HANDLED
;
220 DebugInfoEntry::AddAttribute_sibling(uint16 attributeName
,
221 const AttributeValue
& value
)
223 // This attribute is only intended to help the debug info consumer. We don't
229 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(name
)
230 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(ordering
)
231 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(byte_size
)
232 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(bit_offset
)
233 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(bit_size
)
234 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(stmt_list
)
235 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(low_pc
)
236 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(high_pc
)
237 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(language
)
238 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(discr
)
239 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(discr_value
)
240 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(visibility
)
241 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(import
)
242 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(string_length
)
243 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(common_reference
)
244 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(comp_dir
)
245 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(const_value
)
246 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(containing_type
)
247 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(default_value
)
248 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(inline)
249 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(is_optional
)
250 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(lower_bound
)
251 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(producer
)
252 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(prototyped
)
253 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(return_addr
)
254 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(start_scope
)
255 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(bit_stride
)
256 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(upper_bound
)
257 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(abstract_origin
)
258 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(accessibility
)
259 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(address_class
)
260 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(artificial
)
261 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(base_types
)
262 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(calling_convention
)
263 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(count
)
264 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(data_member_location
)
265 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(declaration
)
266 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(discr_list
)
267 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(encoding
)
268 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(external
)
269 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(frame_base
)
270 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(friend)
271 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(identifier_case
)
272 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(macro_info
)
273 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(namelist_item
)
274 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(priority
)
275 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(segment
)
276 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(specification
)
277 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(static_link
)
278 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(type
)
279 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(use_location
)
280 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(variable_parameter
)
281 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(virtuality
)
282 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(vtable_elem_location
)
283 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(allocated
)
284 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(associated
)
285 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(data_location
)
286 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(byte_stride
)
287 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(entry_pc
)
288 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(use_UTF8
)
289 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(extension
)
290 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(ranges
)
291 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(trampoline
)
292 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_column
)
293 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_file
)
294 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_line
)
295 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(description
)
296 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(binary_scale
)
297 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(decimal_scale
)
298 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(small
)
299 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(decimal_sign
)
300 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(digit_count
)
301 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(picture_string
)
302 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(mutable)
303 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(threads_scaled
)
304 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(explicit)
305 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(object_pointer
)
306 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(endianity
)
307 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(elemental
)
308 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(pure
)
309 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(recursive
)
310 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(signature
)
311 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(main_subprogram
)
312 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(data_bit_offset
)
313 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(const_expr
)
314 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(enum_class
)
315 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(linkage_name
)
316 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_site_value
)
317 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_site_data_value
)
318 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_site_target
)
319 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(call_site_target_clobbered
)
320 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(tail_call
)
321 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(all_tail_call_sites
)
322 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(all_call_sites
)
323 DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(all_source_call_sites
)
327 DebugInfoEntry::GetDeclarationLocation()
334 DebugInfoEntry::SetDynamicAttributeValue(DynamicAttributeValue
& toSet
,
335 const AttributeValue
& value
)
337 switch (value
.attributeClass
) {
338 case ATTRIBUTE_CLASS_CONSTANT
:
339 toSet
.SetTo(value
.constant
);
341 case ATTRIBUTE_CLASS_REFERENCE
:
342 toSet
.SetTo(value
.reference
);
344 case ATTRIBUTE_CLASS_BLOCK
:
345 toSet
.SetTo(value
.block
.data
, value
.block
.length
);
354 DebugInfoEntry::SetConstantAttributeValue(ConstantAttributeValue
& toSet
,
355 const AttributeValue
& value
)
357 switch (value
.attributeClass
) {
358 case ATTRIBUTE_CLASS_CONSTANT
:
359 toSet
.SetTo(value
.constant
);
361 case ATTRIBUTE_CLASS_STRING
:
362 toSet
.SetTo(value
.string
);
364 case ATTRIBUTE_CLASS_BLOCK
:
365 toSet
.SetTo(value
.block
.data
, value
.block
.length
);
374 DebugInfoEntry::SetMemberLocation(MemberLocation
& toSet
,
375 const AttributeValue
& value
)
377 switch (value
.attributeClass
) {
378 case ATTRIBUTE_CLASS_CONSTANT
:
379 toSet
.SetToConstant(value
.constant
);
381 case ATTRIBUTE_CLASS_BLOCK
:
382 toSet
.SetToExpression(value
.block
.data
, value
.block
.length
);
384 case ATTRIBUTE_CLASS_LOCLISTPTR
:
385 toSet
.SetToLocationList(value
.pointer
);