headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / debugger / dwarf / DebugInfoEntry.cpp
blob0ec4a777aa180c5f803722ea90748dd619db6fb6
1 /*
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.
5 */
7 #include "DebugInfoEntries.h"
9 #include <new>
11 #include "AttributeValue.h"
12 #include "Dwarf.h"
15 #define DEFINE_DEBUG_INFO_ENTRY_ATTR_SETTER(name) \
16 status_t \
17 DebugInfoEntry::AddAttribute_##name(uint16 attributeName, \
18 const AttributeValue& value) \
19 { \
20 return ATTRIBUTE_NOT_HANDLED; \
24 DebugInfoEntry::DebugInfoEntry()
26 fParent(NULL)
31 DebugInfoEntry::~DebugInfoEntry()
36 status_t
37 DebugInfoEntry::InitAfterHierarchy(DebugInfoEntryInitInfo& info)
39 return B_OK;
43 status_t
44 DebugInfoEntry::InitAfterAttributes(DebugInfoEntryInitInfo& info)
46 return B_OK;
50 void
51 DebugInfoEntry::SetParent(DebugInfoEntry* parent)
53 fParent = parent;
57 bool
58 DebugInfoEntry::IsType() const
60 return false;
64 bool
65 DebugInfoEntry::IsNamespace() const
67 return false;
71 const char*
72 DebugInfoEntry::Name() const
74 return NULL;
77 const char*
78 DebugInfoEntry::Description() const
80 return NULL;
84 DebugInfoEntry*
85 DebugInfoEntry::Specification() const
87 return NULL;
91 DebugInfoEntry*
92 DebugInfoEntry::AbstractOrigin() const
94 return NULL;
98 DebugInfoEntry*
99 DebugInfoEntry::SignatureType() const
101 return NULL;
105 LocationDescription*
106 DebugInfoEntry::GetLocationDescription()
108 return NULL;
112 bool
113 DebugInfoEntry::GetDeclarationFile(uint32& _file) const
115 DeclarationLocation* location = const_cast<DebugInfoEntry*>(this)
116 ->GetDeclarationLocation();
117 if (location == NULL || !location->IsFileSet())
118 return false;
120 _file = location->file;
121 return true;
125 bool
126 DebugInfoEntry::GetDeclarationLine(uint32& _line) const
128 DeclarationLocation* location = const_cast<DebugInfoEntry*>(this)
129 ->GetDeclarationLocation();
130 if (location == NULL || !location->IsLineSet())
131 return false;
133 _line = location->line;
134 return true;
138 bool
139 DebugInfoEntry::GetDeclarationColumn(uint32& _column) const
141 DeclarationLocation* location = const_cast<DebugInfoEntry*>(this)
142 ->GetDeclarationLocation();
143 if (location == NULL || !location->IsColumnSet())
144 return false;
146 _column = location->column;
147 return true;
151 status_t
152 DebugInfoEntry::AddChild(DebugInfoEntry* child)
154 // ignore children where we don't expect them
155 return ENTRY_NOT_HANDLED;
159 status_t
160 DebugInfoEntry::AddAttribute_decl_file(uint16 attributeName,
161 const AttributeValue& value)
163 if (DeclarationLocation* location = GetDeclarationLocation()) {
164 location->SetFile(value.constant);
165 return B_OK;
168 return ATTRIBUTE_NOT_HANDLED;
172 status_t
173 DebugInfoEntry::AddAttribute_decl_line(uint16 attributeName,
174 const AttributeValue& value)
176 if (DeclarationLocation* location = GetDeclarationLocation()) {
177 location->SetLine(value.constant);
178 return B_OK;
181 return ATTRIBUTE_NOT_HANDLED;
185 status_t
186 DebugInfoEntry::AddAttribute_decl_column(uint16 attributeName,
187 const AttributeValue& value)
189 if (DeclarationLocation* location = GetDeclarationLocation()) {
190 location->SetColumn(value.constant);
191 return B_OK;
194 return ATTRIBUTE_NOT_HANDLED;
198 status_t
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);
205 return B_OK;
208 if (value.attributeClass == ATTRIBUTE_CLASS_BLOCK) {
209 location->SetToExpression(value.block.data, value.block.length);
210 return B_OK;
212 return B_BAD_DATA;
215 return ATTRIBUTE_NOT_HANDLED;
219 status_t
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
224 // need it.
225 return B_OK;
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)
326 DeclarationLocation*
327 DebugInfoEntry::GetDeclarationLocation()
329 return NULL;
333 status_t
334 DebugInfoEntry::SetDynamicAttributeValue(DynamicAttributeValue& toSet,
335 const AttributeValue& value)
337 switch (value.attributeClass) {
338 case ATTRIBUTE_CLASS_CONSTANT:
339 toSet.SetTo(value.constant);
340 return B_OK;
341 case ATTRIBUTE_CLASS_REFERENCE:
342 toSet.SetTo(value.reference);
343 return B_OK;
344 case ATTRIBUTE_CLASS_BLOCK:
345 toSet.SetTo(value.block.data, value.block.length);
346 return B_OK;
347 default:
348 return B_BAD_DATA;
353 status_t
354 DebugInfoEntry::SetConstantAttributeValue(ConstantAttributeValue& toSet,
355 const AttributeValue& value)
357 switch (value.attributeClass) {
358 case ATTRIBUTE_CLASS_CONSTANT:
359 toSet.SetTo(value.constant);
360 return B_OK;
361 case ATTRIBUTE_CLASS_STRING:
362 toSet.SetTo(value.string);
363 return B_OK;
364 case ATTRIBUTE_CLASS_BLOCK:
365 toSet.SetTo(value.block.data, value.block.length);
366 return B_OK;
367 default:
368 return B_BAD_DATA;
373 status_t
374 DebugInfoEntry::SetMemberLocation(MemberLocation& toSet,
375 const AttributeValue& value)
377 switch (value.attributeClass) {
378 case ATTRIBUTE_CLASS_CONSTANT:
379 toSet.SetToConstant(value.constant);
380 return B_OK;
381 case ATTRIBUTE_CLASS_BLOCK:
382 toSet.SetToExpression(value.block.data, value.block.length);
383 return B_OK;
384 case ATTRIBUTE_CLASS_LOCLISTPTR:
385 toSet.SetToLocationList(value.pointer);
386 return B_OK;
387 default:
388 return B_BAD_DATA;