1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | #include "SymbolFileDWARF.h" |
11 | |
12 | #include <algorithm> |
13 | #include <set> |
14 | |
15 | #include "lldb/Core/RegularExpression.h" |
16 | #include "lldb/Core/Stream.h" |
17 | #include "lldb/Symbol/ObjectFile.h" |
18 | |
19 | #include "DWARFDebugAranges.h" |
20 | #include "DWARFDebugInfo.h" |
21 | #include "DWARFCompileUnit.h" |
22 | #include "DWARFDebugAranges.h" |
23 | #include "DWARFDebugInfoEntry.h" |
24 | #include "DWARFFormValue.h" |
25 | #include "LogChannelDWARF.h" |
26 | |
27 | using namespace lldb; |
28 | using namespace lldb_private; |
29 | using namespace std; |
30 | |
31 | |
32 | |
33 | |
34 | DWARFDebugInfo::DWARFDebugInfo() : |
35 | m_dwarf2Data(NULL__null), |
36 | m_compile_units(), |
37 | m_cu_aranges_ap () |
38 | { |
39 | } |
40 | |
41 | |
42 | |
43 | |
44 | void |
45 | DWARFDebugInfo::SetDwarfData(SymbolFileDWARF* dwarf2Data) |
46 | { |
47 | m_dwarf2Data = dwarf2Data; |
48 | m_compile_units.clear(); |
49 | } |
50 | |
51 | |
52 | DWARFDebugAranges & |
53 | DWARFDebugInfo::GetCompileUnitAranges () |
54 | { |
55 | if (m_cu_aranges_ap.get() == NULL__null && m_dwarf2Data) |
56 | { |
57 | Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES(1u << 5))); |
58 | |
59 | m_cu_aranges_ap.reset (new DWARFDebugAranges()); |
60 | const DWARFDataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data(); |
61 | if (debug_aranges_data.GetByteSize() > 0) |
62 | { |
63 | if (log) |
64 | log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" from .debug_aranges", |
65 | m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str()); |
66 | m_cu_aranges_ap->Extract (debug_aranges_data); |
67 | |
68 | } |
69 | |
70 | |
71 | std::set<dw_offset_t> cus_with_data; |
72 | for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++) |
73 | { |
74 | dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n); |
75 | if (offset != DW_INVALID_OFFSET(~(dw_offset_t)0)) |
76 | cus_with_data.insert (offset); |
77 | } |
78 | |
79 | |
80 | bool printed = false; |
81 | const size_t num_compile_units = GetNumCompileUnits(); |
82 | for (size_t idx = 0; idx < num_compile_units; ++idx) |
83 | { |
84 | DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx); |
85 | |
86 | dw_offset_t offset = cu->GetOffset(); |
87 | if (cus_with_data.find(offset) == cus_with_data.end()) |
88 | { |
89 | if (log) |
90 | { |
91 | if (!printed) |
92 | log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing", |
93 | m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str()); |
94 | printed = true; |
95 | } |
96 | cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get()); |
97 | } |
98 | } |
99 | |
100 | const bool minimize = true; |
101 | m_cu_aranges_ap->Sort (minimize); |
102 | } |
103 | return *m_cu_aranges_ap.get(); |
104 | } |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | bool |
111 | DWARFDebugInfo::LookupAddress |
112 | ( |
113 | const dw_addr_t address, |
114 | const dw_offset_t hint_die_offset, |
115 | DWARFCompileUnitSP& cu_sp, |
116 | DWARFDebugInfoEntry** function_die, |
117 | DWARFDebugInfoEntry** block_die |
118 | ) |
119 | { |
120 | |
121 | if (hint_die_offset != DW_INVALID_OFFSET(~(dw_offset_t)0)) |
122 | cu_sp = GetCompileUnit(hint_die_offset); |
123 | else |
124 | { |
125 | DWARFDebugAranges &cu_aranges = GetCompileUnitAranges (); |
126 | const dw_offset_t cu_offset = cu_aranges.FindAddress (address); |
127 | cu_sp = GetCompileUnit(cu_offset); |
128 | } |
129 | |
130 | if (cu_sp.get()) |
131 | { |
132 | if (cu_sp->LookupAddress(address, function_die, block_die)) |
133 | return true; |
134 | cu_sp.reset(); |
135 | } |
136 | else |
137 | { |
138 | |
139 | |
140 | DWARFDebugInfoEntry* die_ptr = GetDIEPtr(hint_die_offset, &cu_sp); |
141 | if (die_ptr) |
142 | { |
143 | if (cu_sp.get()) |
144 | { |
145 | if (function_die || block_die) |
146 | return die_ptr->LookupAddress(address, m_dwarf2Data, cu_sp.get(), function_die, block_die); |
147 | |
148 | |
149 | return true; |
150 | } |
151 | } |
152 | } |
153 | return false; |
154 | } |
155 | |
156 | |
157 | void |
158 | DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() |
159 | { |
160 | if (m_compile_units.empty()) |
161 | { |
162 | if (m_dwarf2Data != NULL__null) |
163 | { |
164 | lldb::offset_t offset = 0; |
165 | const DWARFDataExtractor &debug_info_data = m_dwarf2Data->get_debug_info_data(); |
166 | while (debug_info_data.ValidOffset(offset)) |
167 | { |
168 | DWARFCompileUnitSP cu_sp(new DWARFCompileUnit(m_dwarf2Data)); |
169 | |
170 | if (cu_sp.get() == NULL__null) |
171 | break; |
172 | |
173 | if (cu_sp->Extract(debug_info_data, &offset) == false) |
174 | break; |
175 | |
176 | m_compile_units.push_back(cu_sp); |
177 | |
178 | offset = cu_sp->GetNextCompileUnitOffset(); |
179 | } |
180 | } |
181 | } |
182 | } |
183 | |
184 | size_t |
185 | DWARFDebugInfo::GetNumCompileUnits() |
186 | { |
187 | ParseCompileUnitHeadersIfNeeded(); |
188 | return m_compile_units.size(); |
189 | } |
190 | |
191 | DWARFCompileUnit* |
192 | DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) |
193 | { |
194 | DWARFCompileUnit* cu = NULL__null; |
195 | if (idx < GetNumCompileUnits()) |
196 | cu = m_compile_units[idx].get(); |
197 | return cu; |
198 | } |
199 | |
200 | bool |
201 | DWARFDebugInfo::ContainsCompileUnit (const DWARFCompileUnit *cu) const |
202 | { |
203 | |
204 | |
205 | CompileUnitColl::const_iterator end_pos = m_compile_units.end(); |
206 | CompileUnitColl::const_iterator pos; |
207 | |
208 | for (pos = m_compile_units.begin(); pos != end_pos; ++pos) |
209 | { |
210 | if (pos->get() == cu) |
211 | return true; |
212 | } |
213 | return false; |
214 | } |
215 | |
216 | static int |
217 | CompareDWARFCompileUnitSPOffset (const void *key, const void *arrmem) |
218 | { |
219 | const dw_offset_t key_cu_offset = *(dw_offset_t*) key; |
220 | const dw_offset_t cu_offset = ((DWARFCompileUnitSP *)arrmem)->get()->GetOffset(); |
221 | if (key_cu_offset < cu_offset) |
222 | return -1; |
223 | if (key_cu_offset > cu_offset) |
224 | return 1; |
225 | return 0; |
226 | } |
227 | |
228 | DWARFCompileUnitSP |
229 | DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr) |
230 | { |
231 | DWARFCompileUnitSP cu_sp; |
232 | uint32_t cu_idx = DW_INVALID_INDEX0xFFFFFFFFul; |
233 | if (cu_offset != DW_INVALID_OFFSET(~(dw_offset_t)0)) |
234 | { |
235 | ParseCompileUnitHeadersIfNeeded(); |
236 | |
237 | DWARFCompileUnitSP* match = (DWARFCompileUnitSP*)bsearch(&cu_offset, &m_compile_units[0], m_compile_units.size(), sizeof(DWARFCompileUnitSP), CompareDWARFCompileUnitSPOffset); |
238 | if (match) |
239 | { |
240 | cu_sp = *match; |
241 | cu_idx = match - &m_compile_units[0]; |
242 | } |
243 | } |
244 | if (idx_ptr) |
245 | *idx_ptr = cu_idx; |
246 | return cu_sp; |
247 | } |
248 | |
249 | DWARFCompileUnitSP |
250 | DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset) |
251 | { |
252 | DWARFCompileUnitSP cu_sp; |
253 | if (die_offset != DW_INVALID_OFFSET(~(dw_offset_t)0)) |
254 | { |
255 | ParseCompileUnitHeadersIfNeeded(); |
256 | |
257 | CompileUnitColl::const_iterator end_pos = m_compile_units.end(); |
258 | CompileUnitColl::const_iterator pos; |
259 | |
260 | for (pos = m_compile_units.begin(); pos != end_pos; ++pos) |
261 | { |
262 | dw_offset_t cu_start_offset = (*pos)->GetOffset(); |
263 | dw_offset_t cu_end_offset = (*pos)->GetNextCompileUnitOffset(); |
264 | if (cu_start_offset <= die_offset && die_offset < cu_end_offset) |
265 | { |
266 | cu_sp = *pos; |
267 | break; |
268 | } |
269 | } |
270 | } |
271 | return cu_sp; |
272 | } |
273 | |
274 | |
275 | |
276 | |
277 | |
278 | |
279 | DWARFDebugInfoEntry* |
280 | DWARFDebugInfo::GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr) |
281 | { |
282 | DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset)); |
283 | if (cu_sp_ptr) |
284 | *cu_sp_ptr = cu_sp; |
285 | if (cu_sp.get()) |
286 | return cu_sp->GetDIEPtr(die_offset); |
287 | return NULL__null; |
288 | } |
289 | |
290 | DWARFDebugInfoEntry* |
291 | DWARFDebugInfo::GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle) |
292 | { |
293 | assert (cu_handle)((cu_handle) ? static_cast<void> (0) : __assert_fail ("cu_handle" , "/tmp/buildd/llvm-toolchain-snapshot-3.6~svn219601/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp" , 293, __PRETTY_FUNCTION__)); |
294 | DWARFDebugInfoEntry* die = NULL__null; |
295 | if (*cu_handle) |
296 | die = (*cu_handle)->GetDIEPtr(die_offset); |
297 | |
298 | if (die == NULL__null) |
299 | { |
300 | DWARFCompileUnitSP cu_sp (GetCompileUnitContainingDIE(die_offset)); |
301 | if (cu_sp.get()) |
302 | { |
303 | *cu_handle = cu_sp.get(); |
304 | die = cu_sp->GetDIEPtr(die_offset); |
305 | } |
306 | } |
307 | if (die == NULL__null) |
308 | *cu_handle = NULL__null; |
309 | return die; |
310 | } |
311 | |
312 | |
313 | const DWARFDebugInfoEntry* |
314 | DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr) |
315 | { |
316 | DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset)); |
317 | if (cu_sp_ptr) |
318 | *cu_sp_ptr = cu_sp; |
319 | if (cu_sp.get()) |
320 | return cu_sp->GetDIEPtrContainingOffset(die_offset); |
321 | |
322 | return NULL__null; |
323 | |
324 | } |
325 | |
326 | |
327 | |
328 | |
329 | void |
330 | DWARFDebugInfo::AddCompileUnit(DWARFCompileUnitSP& cu) |
331 | { |
332 | m_compile_units.push_back(cu); |
333 | } |
334 | |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | |
356 | void |
357 | DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* userData) |
358 | { |
359 | if (dwarf2Data) |
360 | { |
361 | lldb::offset_t offset = 0; |
362 | uint32_t depth = 0; |
363 | DWARFCompileUnitSP cu(new DWARFCompileUnit(dwarf2Data)); |
364 | if (cu.get() == NULL__null) |
365 | return; |
366 | DWARFDebugInfoEntry die; |
367 | |
368 | while (cu->Extract(dwarf2Data->get_debug_info_data(), &offset)) |
369 | { |
370 | const dw_offset_t next_cu_offset = cu->GetNextCompileUnitOffset(); |
371 | |
372 | depth = 0; |
373 | |
374 | |
375 | offset = callback(dwarf2Data, cu, NULL__null, offset, depth, userData); |
376 | |
377 | |
378 | if (offset < next_cu_offset) |
379 | { |
380 | |
381 | |
382 | bool done = false; |
383 | while (!done && die.Extract(dwarf2Data, cu.get(), &offset)) |
384 | { |
385 | |
386 | offset = callback(dwarf2Data, cu, &die, offset, depth, userData); |
387 | |
388 | if (die.IsNULL()) |
389 | { |
390 | if (depth) |
391 | --depth; |
392 | else |
393 | done = true; |
394 | } |
395 | else if (die.HasChildren()) |
396 | ++depth; |
397 | } |
398 | } |
399 | |
400 | |
401 | |
402 | |
403 | if (!dwarf2Data->get_debug_info_data().ValidOffset(offset)) |
404 | break; |
405 | |
406 | |
407 | |
408 | |
409 | if (!cu.unique()) |
410 | cu.reset(new DWARFCompileUnit(dwarf2Data)); |
411 | |
412 | |
413 | |
414 | offset = next_cu_offset; |
415 | } |
416 | } |
417 | } |
418 | |
419 | typedef struct DumpInfo |
420 | { |
421 | DumpInfo(Stream* init_strm, uint32_t off, uint32_t depth) : |
422 | strm(init_strm), |
423 | die_offset(off), |
424 | recurse_depth(depth), |
425 | found_depth(UINT32_MAX(4294967295U)), |
426 | found_die(false), |
427 | ancestors() |
428 | { |
429 | } |
430 | Stream* strm; |
431 | const uint32_t die_offset; |
432 | const uint32_t recurse_depth; |
433 | uint32_t found_depth; |
434 | bool found_die; |
435 | std::vector<DWARFDebugInfoEntry> ancestors; |
436 | |
437 | DISALLOW_COPY_AND_ASSIGN(DumpInfo)DumpInfo(const DumpInfo&); const DumpInfo& operator=( const DumpInfo&); |
438 | } DumpInfo; |
439 | |
440 | |
441 | |
442 | |
443 | |
444 | |
445 | |
446 | |
447 | |
448 | |
449 | |
450 | static dw_offset_t DumpCallback |
451 | ( |
452 | SymbolFileDWARF* dwarf2Data, |
453 | DWARFCompileUnitSP& cu_sp, |
454 | DWARFDebugInfoEntry* die, |
455 | const dw_offset_t next_offset, |
456 | const uint32_t curr_depth, |
457 | void* userData |
458 | ) |
459 | { |
460 | DumpInfo* dumpInfo = (DumpInfo*)userData; |
461 | |
462 | const DWARFCompileUnit* cu = cu_sp.get(); |
| 3 | | Calling '__shared_ptr::get' | |
|
| 4 | | Returning from '__shared_ptr::get' | |
|
| |
463 | |
464 | Stream *s = dumpInfo->strm; |
465 | bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors); |
466 | |
467 | if (die) |
| |
468 | { |
469 | |
470 | if (dumpInfo->die_offset == DW_INVALID_OFFSET(~(dw_offset_t)0)) |
471 | { |
472 | |
473 | if (curr_depth < dumpInfo->recurse_depth) |
474 | die->Dump(dwarf2Data, cu, *s, 0); |
475 | } |
476 | else |
477 | { |
478 | |
479 | if (dumpInfo->die_offset == die->GetOffset()) |
480 | { |
481 | |
482 | if (show_parents) |
483 | { |
484 | s->SetIndentLevel(0); |
485 | const uint32_t num_ancestors = dumpInfo->ancestors.size(); |
486 | if (num_ancestors > 0) |
487 | { |
488 | for (uint32_t i=0; i<num_ancestors-1; ++i) |
489 | { |
490 | dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0); |
491 | s->IndentMore(); |
492 | } |
493 | } |
494 | } |
495 | |
496 | dumpInfo->found_depth = curr_depth; |
497 | |
498 | die->Dump(dwarf2Data, cu, *s, 0); |
499 | |
500 | |
501 | dumpInfo->found_die = true; |
502 | |
503 | |
504 | if (!die->HasChildren() || dumpInfo->recurse_depth == 0) |
505 | return DW_INVALID_OFFSET(~(dw_offset_t)0); |
506 | } |
507 | else if (dumpInfo->found_die) |
508 | { |
509 | |
510 | if (curr_depth <= dumpInfo->found_depth) |
511 | return DW_INVALID_OFFSET(~(dw_offset_t)0); |
512 | |
513 | |
514 | |
515 | |
516 | if (dumpInfo->recurse_depth == UINT32_MAX(4294967295U) || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) |
517 | die->Dump(dwarf2Data, cu, *s, 0); |
518 | } |
519 | else if (dumpInfo->die_offset > die->GetOffset()) |
520 | { |
521 | if (show_parents) |
522 | dumpInfo->ancestors.back() = *die; |
523 | } |
524 | } |
525 | |
526 | |
527 | if (die->IsNULL()) |
528 | { |
529 | if (show_parents) |
530 | dumpInfo->ancestors.pop_back(); |
531 | |
532 | if (curr_depth <= 1) |
533 | return cu->GetNextCompileUnitOffset(); |
534 | else |
535 | s->IndentLess(); |
536 | } |
537 | else if (die->HasChildren()) |
538 | { |
539 | if (show_parents) |
540 | { |
541 | DWARFDebugInfoEntry null_die; |
542 | dumpInfo->ancestors.push_back(null_die); |
543 | } |
544 | s->IndentMore(); |
545 | } |
546 | } |
547 | else |
548 | { |
549 | if (cu == NULL__null) |
| 7 | | Assuming pointer value is null | |
|
| |
550 | s->PutCString("NULL - cu"); |
551 | |
552 | s->SetIndentLevel(0); |
553 | |
554 | |
555 | if (dumpInfo->die_offset == DW_INVALID_OFFSET(~(dw_offset_t)0)) |
| |
556 | { |
557 | |
558 | cu->Dump(s); |
559 | return cu->GetFirstDIEOffset(); |
560 | } |
561 | else |
562 | { |
563 | if (show_parents) |
| |
564 | { |
565 | dumpInfo->ancestors.clear(); |
566 | dumpInfo->ancestors.resize(1); |
567 | } |
568 | |
569 | |
570 | |
571 | if (dumpInfo->die_offset < cu->GetFirstDIEOffset()) |
| 11 | | Called C++ object pointer is null |
|
572 | { |
573 | |
574 | |
575 | return DW_INVALID_OFFSET(~(dw_offset_t)0); |
576 | } |
577 | else |
578 | { |
579 | |
580 | if (dumpInfo->die_offset < cu->GetNextCompileUnitOffset()) |
581 | { |
582 | |
583 | if (s->GetVerbose()) |
584 | cu->Dump(s); |
585 | |
586 | return next_offset; |
587 | |
588 | |
589 | } |
590 | else |
591 | { |
592 | |
593 | return cu->GetNextCompileUnitOffset(); |
594 | } |
595 | } |
596 | } |
597 | } |
598 | |
599 | |
600 | return next_offset; |
601 | } |
602 | |
603 | |
604 | |
605 | |
606 | |
607 | |
608 | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | |
615 | void |
616 | DWARFDebugInfo::Dump |
617 | ( |
618 | Stream *s, |
619 | SymbolFileDWARF* dwarf2Data, |
620 | const uint32_t die_offset, |
621 | const uint32_t recurse_depth |
622 | ) |
623 | { |
624 | DumpInfo dumpInfo(s, die_offset, recurse_depth); |
625 | s->PutCString(".debug_info contents"); |
626 | if (dwarf2Data->get_debug_info_data().GetByteSize() > 0) |
627 | { |
628 | if (die_offset == DW_INVALID_OFFSET(~(dw_offset_t)0)) |
629 | s->PutCString(":\n"); |
630 | else |
631 | { |
632 | s->Printf(" for DIE entry at .debug_info[0x%8.8x]", die_offset); |
633 | if (recurse_depth != UINT32_MAX(4294967295U)) |
634 | s->Printf(" recursing %u levels deep.", recurse_depth); |
635 | s->EOL(); |
636 | } |
637 | } |
638 | else |
639 | { |
640 | s->PutCString(": < EMPTY >\n"); |
641 | return; |
642 | } |
643 | DWARFDebugInfo::Parse(dwarf2Data, DumpCallback, &dumpInfo); |
644 | } |
645 | |
646 | |
647 | |
648 | |
649 | |
650 | |
651 | |
652 | |
653 | void |
654 | DWARFDebugInfo::Dump (Stream *s, const uint32_t die_offset, const uint32_t recurse_depth) |
655 | { |
656 | DumpInfo dumpInfo(s, die_offset, recurse_depth); |
657 | |
658 | s->PutCString("Dumping .debug_info section from internal representation\n"); |
659 | |
660 | CompileUnitColl::const_iterator pos; |
661 | uint32_t curr_depth = 0; |
662 | ParseCompileUnitHeadersIfNeeded(); |
663 | for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) |
| 1 | Loop condition is true. Entering loop body | |
|
664 | { |
665 | const DWARFCompileUnitSP& cu_sp = *pos; |
666 | DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL__null, 0, curr_depth, &dumpInfo); |
| |
667 | |
668 | const DWARFDebugInfoEntry* die = cu_sp->DIE(); |
669 | if (die) |
670 | die->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth); |
671 | } |
672 | } |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | |
679 | |
680 | |
681 | |
682 | |
683 | |
684 | |
685 | typedef struct FindCallbackStringInfoTag |
686 | { |
687 | const char* name; |
688 | bool ignore_case; |
689 | RegularExpression* regex; |
690 | vector<dw_offset_t>& die_offsets; |
691 | } FindCallbackStringInfo; |
692 | |
693 | static dw_offset_t FindCallbackString |
694 | ( |
695 | SymbolFileDWARF* dwarf2Data, |
696 | DWARFCompileUnitSP& cu_sp, |
697 | DWARFDebugInfoEntry* die, |
698 | const dw_offset_t next_offset, |
699 | const uint32_t curr_depth, |
700 | void* userData |
701 | ) |
702 | { |
703 | FindCallbackStringInfo* info = (FindCallbackStringInfo*)userData; |
704 | const DWARFCompileUnit* cu = cu_sp.get(); |
705 | |
706 | if (die) |
707 | { |
708 | const char* die_name = die->GetName(dwarf2Data, cu); |
709 | if (die_name) |
710 | { |
711 | if (info->regex) |
712 | { |
713 | if (info->regex->Execute(die_name)) |
714 | info->die_offsets.push_back(die->GetOffset()); |
715 | } |
716 | else |
717 | { |
718 | if ((info->ignore_case ? strcasecmp(die_name, info->name) : strcmp(die_name, info->name)) == 0) |
719 | info->die_offsets.push_back(die->GetOffset()); |
720 | } |
721 | } |
722 | } |
723 | |
724 | |
725 | return next_offset; |
726 | } |
727 | |
728 | |
729 | |
730 | |
731 | |
732 | |
733 | |
734 | |
735 | |
736 | bool |
737 | DWARFDebugInfo::Find(const char* name, bool ignore_case, vector<dw_offset_t>& die_offsets) const |
738 | { |
739 | die_offsets.clear(); |
740 | if (name && name[0]) |
741 | { |
742 | FindCallbackStringInfo info = { name, ignore_case, NULL__null, die_offsets }; |
743 | DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info); |
744 | } |
745 | return !die_offsets.empty(); |
746 | } |
747 | |
748 | |
749 | |
750 | |
751 | |
752 | |
753 | |
754 | |
755 | |
756 | bool |
757 | DWARFDebugInfo::Find(RegularExpression& re, vector<dw_offset_t>& die_offsets) const |
758 | { |
759 | die_offsets.clear(); |
760 | FindCallbackStringInfo info = { NULL__null, false, &re, die_offsets }; |
761 | DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info); |
762 | return !die_offsets.empty(); |
763 | } |