LLDB mainline
SymbolContext.cpp
Go to the documentation of this file.
1//===-- SymbolContext.cpp -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "lldb/Core/Debugger.h"
12#include "lldb/Core/Module.h"
14#include "lldb/Host/Host.h"
15#include "lldb/Symbol/Block.h"
18#include "lldb/Symbol/Symbol.h"
23#include "lldb/Target/Target.h"
25#include "lldb/Utility/Log.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
32SymbolContext::SymbolContext() : target_sp(), module_sp(), line_entry() {}
33
35 Block *b, LineEntry *le, Symbol *s)
36 : target_sp(), module_sp(m), comp_unit(cu), function(f), block(b),
37 line_entry(), symbol(s) {
38 if (le)
39 line_entry = *le;
40}
41
43 CompileUnit *cu, Function *f, Block *b,
44 LineEntry *le, Symbol *s)
45 : target_sp(t), module_sp(m), comp_unit(cu), function(f), block(b),
46 line_entry(), symbol(s) {
47 if (le)
48 line_entry = *le;
49}
50
52 : target_sp(), module_sp(), line_entry() {
53 sc_scope->CalculateSymbolContext(this);
54}
55
57
58void SymbolContext::Clear(bool clear_target) {
59 if (clear_target)
60 target_sp.reset();
61 module_sp.reset();
62 comp_unit = nullptr;
63 function = nullptr;
64 block = nullptr;
66 symbol = nullptr;
67 variable = nullptr;
68}
69
71 const Address &addr, bool show_fullpaths,
72 bool show_module, bool show_inlined_frames,
73 bool show_function_arguments,
74 bool show_function_name) const {
75 bool dumped_something = false;
76 if (show_module && module_sp) {
77 if (show_fullpaths)
78 *s << module_sp->GetFileSpec();
79 else
80 *s << module_sp->GetFileSpec().GetFilename();
81 s->PutChar('`');
82 dumped_something = true;
83 }
84
85 if (function != nullptr) {
86 SymbolContext inline_parent_sc;
87 Address inline_parent_addr;
88 if (!show_function_name) {
89 s->Printf("<");
90 dumped_something = true;
91 } else {
92 ConstString name;
93 if (!show_function_arguments)
95 if (!name)
96 name = function->GetName();
97 if (name)
98 name.Dump(s);
99 }
100
101 if (addr.IsValid()) {
102 const addr_t function_offset =
103 addr.GetOffset() -
105 if (!show_function_name) {
106 // Print +offset even if offset is 0
107 dumped_something = true;
108 s->Printf("+%" PRIu64 ">", function_offset);
109 } else if (function_offset) {
110 dumped_something = true;
111 s->Printf(" + %" PRIu64, function_offset);
112 }
113 }
114
115 if (GetParentOfInlinedScope(addr, inline_parent_sc, inline_parent_addr)) {
116 dumped_something = true;
117 Block *inlined_block = block->GetContainingInlinedBlock();
118 const InlineFunctionInfo *inlined_block_info =
119 inlined_block->GetInlinedFunctionInfo();
120 s->Printf(" [inlined] %s", inlined_block_info->GetName().GetCString());
121
122 lldb_private::AddressRange block_range;
123 if (inlined_block->GetRangeContainingAddress(addr, block_range)) {
124 const addr_t inlined_function_offset =
125 addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
126 if (inlined_function_offset) {
127 s->Printf(" + %" PRIu64, inlined_function_offset);
128 }
129 }
130 // "line_entry" will always be valid as GetParentOfInlinedScope(...) will
131 // fill it in correctly with the calling file and line. Previous code
132 // was extracting the calling file and line from inlined_block_info and
133 // using it right away which is not correct. On the first call to this
134 // function "line_entry" will contain the actual line table entry. On
135 // susequent calls "line_entry" will contain the calling file and line
136 // from the previous inline info.
137 if (line_entry.IsValid()) {
138 s->PutCString(" at ");
139 line_entry.DumpStopContext(s, show_fullpaths);
140 }
141
142 if (show_inlined_frames) {
143 s->EOL();
144 s->Indent();
145 const bool show_function_name = true;
146 return inline_parent_sc.DumpStopContext(
147 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
148 show_inlined_frames, show_function_arguments, show_function_name);
149 }
150 } else {
151 if (line_entry.IsValid()) {
152 dumped_something = true;
153 s->PutCString(" at ");
154 if (line_entry.DumpStopContext(s, show_fullpaths))
155 dumped_something = true;
156 }
157 }
158 } else if (symbol != nullptr) {
159 if (!show_function_name) {
160 s->Printf("<");
161 dumped_something = true;
162 } else if (symbol->GetName()) {
163 dumped_something = true;
165 s->PutCString("symbol stub for: ");
166 symbol->GetName().Dump(s);
167 }
168
169 if (addr.IsValid() && symbol->ValueIsAddress()) {
170 const addr_t symbol_offset =
172 if (!show_function_name) {
173 // Print +offset even if offset is 0
174 dumped_something = true;
175 s->Printf("+%" PRIu64 ">", symbol_offset);
176 } else if (symbol_offset) {
177 dumped_something = true;
178 s->Printf(" + %" PRIu64, symbol_offset);
179 }
180 }
181 } else if (addr.IsValid()) {
183 dumped_something = true;
184 }
185 return dumped_something;
186}
187
189 Target *target) const {
190 if (module_sp) {
191 s->Indent(" Module: file = \"");
192 module_sp->GetFileSpec().Dump(s->AsRawOstream());
193 *s << '"';
194 if (module_sp->GetArchitecture().IsValid())
195 s->Printf(", arch = \"%s\"",
196 module_sp->GetArchitecture().GetArchitectureName());
197 s->EOL();
198 }
199
200 if (comp_unit != nullptr) {
201 s->Indent("CompileUnit: ");
202 comp_unit->GetDescription(s, level);
203 s->EOL();
204 }
205
206 if (function != nullptr) {
207 s->Indent(" Function: ");
208 function->GetDescription(s, level, target);
209 s->EOL();
210
211 Type *func_type = function->GetType();
212 if (func_type) {
213 s->Indent(" FuncType: ");
214 func_type->GetDescription(s, level, false, target);
215 s->EOL();
216 }
217 }
218
219 if (block != nullptr) {
220 std::vector<Block *> blocks;
221 blocks.push_back(block);
222 Block *parent_block = block->GetParent();
223
224 while (parent_block) {
225 blocks.push_back(parent_block);
226 parent_block = parent_block->GetParent();
227 }
228 std::vector<Block *>::reverse_iterator pos;
229 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
230 std::vector<Block *>::reverse_iterator end = blocks.rend();
231 for (pos = begin; pos != end; ++pos) {
232 if (pos == begin)
233 s->Indent(" Blocks: ");
234 else
235 s->Indent(" ");
236 (*pos)->GetDescription(s, function, level, target);
237 s->EOL();
238 }
239 }
240
241 if (line_entry.IsValid()) {
242 s->Indent(" LineEntry: ");
243 line_entry.GetDescription(s, level, comp_unit, target, false);
244 s->EOL();
245 }
246
247 if (symbol != nullptr) {
248 s->Indent(" Symbol: ");
249 symbol->GetDescription(s, level, target);
250 s->EOL();
251 }
252
253 if (variable != nullptr) {
254 s->Indent(" Variable: ");
255
256 s->Printf("id = {0x%8.8" PRIx64 "}, ", variable->GetID());
257
258 switch (variable->GetScope()) {
260 s->PutCString("kind = global, ");
261 break;
262
264 s->PutCString("kind = static, ");
265 break;
266
268 s->PutCString("kind = argument, ");
269 break;
270
272 s->PutCString("kind = local, ");
273 break;
274
276 s->PutCString("kind = thread local, ");
277 break;
278
279 default:
280 break;
281 }
282
283 s->Printf("name = \"%s\"\n", variable->GetName().GetCString());
284 }
285}
286
288 uint32_t resolved_mask = 0;
289 if (target_sp)
290 resolved_mask |= eSymbolContextTarget;
291 if (module_sp)
292 resolved_mask |= eSymbolContextModule;
293 if (comp_unit)
294 resolved_mask |= eSymbolContextCompUnit;
295 if (function)
296 resolved_mask |= eSymbolContextFunction;
297 if (block)
298 resolved_mask |= eSymbolContextBlock;
299 if (line_entry.IsValid())
300 resolved_mask |= eSymbolContextLineEntry;
301 if (symbol)
302 resolved_mask |= eSymbolContextSymbol;
303 if (variable)
304 resolved_mask |= eSymbolContextVariable;
305 return resolved_mask;
306}
307
308void SymbolContext::Dump(Stream *s, Target *target) const {
309 *s << this << ": ";
310 s->Indent();
311 s->PutCString("SymbolContext");
312 s->IndentMore();
313 s->EOL();
314 s->IndentMore();
315 s->Indent();
316 *s << "Module = " << module_sp.get() << ' ';
317 if (module_sp)
318 module_sp->GetFileSpec().Dump(s->AsRawOstream());
319 s->EOL();
320 s->Indent();
321 *s << "CompileUnit = " << comp_unit;
322 if (comp_unit != nullptr)
323 s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(),
325 s->EOL();
326 s->Indent();
327 *s << "Function = " << function;
328 if (function != nullptr) {
329 s->Format(" {{{0:x-16}} {1}, address-range = ", function->GetID(),
330 function->GetType()->GetName());
333 s->EOL();
334 s->Indent();
335 Type *func_type = function->GetType();
336 if (func_type) {
337 *s << " Type = ";
338 func_type->Dump(s, false);
339 }
340 }
341 s->EOL();
342 s->Indent();
343 *s << "Block = " << block;
344 if (block != nullptr)
345 s->Format(" {{{0:x-16}}", block->GetID());
346 s->EOL();
347 s->Indent();
348 *s << "LineEntry = ";
351 s->EOL();
352 s->Indent();
353 *s << "Symbol = " << symbol;
354 if (symbol != nullptr && symbol->GetMangled())
355 *s << ' ' << symbol->GetName().AsCString();
356 s->EOL();
357 *s << "Variable = " << variable;
358 if (variable != nullptr) {
359 s->Format(" {{{0:x-16}} {1}", variable->GetID(),
360 variable->GetType()->GetName());
361 s->EOL();
362 }
363 s->IndentLess();
364 s->IndentLess();
365}
366
368 const SymbolContext &rhs) {
369 return lhs.function == rhs.function && lhs.symbol == rhs.symbol &&
370 lhs.module_sp.get() == rhs.module_sp.get() &&
371 lhs.comp_unit == rhs.comp_unit &&
372 lhs.target_sp.get() == rhs.target_sp.get() &&
374 lhs.variable == rhs.variable;
375}
376
378 const SymbolContext &rhs) {
379 return !(lhs == rhs);
380}
381
382bool SymbolContext::GetAddressRange(uint32_t scope, uint32_t range_idx,
383 bool use_inline_block_range,
384 AddressRange &range) const {
385 if ((scope & eSymbolContextLineEntry) && line_entry.IsValid()) {
386 range = line_entry.range;
387 return true;
388 }
389
390 if ((scope & eSymbolContextBlock) && (block != nullptr)) {
391 if (use_inline_block_range) {
392 Block *inline_block = block->GetContainingInlinedBlock();
393 if (inline_block)
394 return inline_block->GetRangeAtIndex(range_idx, range);
395 } else {
396 return block->GetRangeAtIndex(range_idx, range);
397 }
398 }
399
400 if ((scope & eSymbolContextFunction) && (function != nullptr)) {
401 if (range_idx == 0) {
402 range = function->GetAddressRange();
403 return true;
404 }
405 }
406
407 if ((scope & eSymbolContextSymbol) && (symbol != nullptr)) {
408 if (range_idx == 0) {
409 if (symbol->ValueIsAddress()) {
412 return true;
413 }
414 }
415 }
416 range.Clear();
417 return false;
418}
419
421 LanguageType lang;
422 if (function && (lang = function->GetLanguage()) != eLanguageTypeUnknown) {
423 return lang;
424 } else if (variable &&
426 return lang;
427 } else if (symbol && (lang = symbol->GetLanguage()) != eLanguageTypeUnknown) {
428 return lang;
429 } else if (comp_unit &&
431 return lang;
432 } else if (symbol) {
433 // If all else fails, try to guess the language from the name.
434 return symbol->GetMangled().GuessLanguage();
435 }
437}
438
440 SymbolContext &next_frame_sc,
441 Address &next_frame_pc) const {
442 next_frame_sc.Clear(false);
443 next_frame_pc.Clear();
444
445 if (block) {
446 // const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress();
447
448 // In order to get the parent of an inlined function we first need to see
449 // if we are in an inlined block as "this->block" could be an inlined
450 // block, or a parent of "block" could be. So lets check if this block or
451 // one of this blocks parents is an inlined function.
452 Block *curr_inlined_block = block->GetContainingInlinedBlock();
453 if (curr_inlined_block) {
454 // "this->block" is contained in an inline function block, so to get the
455 // scope above the inlined block, we get the parent of the inlined block
456 // itself
457 Block *next_frame_block = curr_inlined_block->GetParent();
458 // Now calculate the symbol context of the containing block
459 next_frame_block->CalculateSymbolContext(&next_frame_sc);
460
461 // If we get here we weren't able to find the return line entry using the
462 // nesting of the blocks and the line table. So just use the call site
463 // info from our inlined block.
464
465 AddressRange range;
466 if (curr_inlined_block->GetRangeContainingAddress(curr_frame_pc, range)) {
467 // To see there this new frame block it, we need to look at the call
468 // site information from
469 const InlineFunctionInfo *curr_inlined_block_inlined_info =
470 curr_inlined_block->GetInlinedFunctionInfo();
471 next_frame_pc = range.GetBaseAddress();
472 next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
473 next_frame_sc.line_entry.file =
474 curr_inlined_block_inlined_info->GetCallSite().GetFile();
475 next_frame_sc.line_entry.original_file =
476 curr_inlined_block_inlined_info->GetCallSite().GetFile();
477 next_frame_sc.line_entry.line =
478 curr_inlined_block_inlined_info->GetCallSite().GetLine();
479 next_frame_sc.line_entry.column =
480 curr_inlined_block_inlined_info->GetCallSite().GetColumn();
481 return true;
482 } else {
484
485 if (log) {
486 LLDB_LOGF(
487 log,
488 "warning: inlined block 0x%8.8" PRIx64
489 " doesn't have a range that contains file address 0x%" PRIx64,
490 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
491 }
492#ifdef LLDB_CONFIGURATION_DEBUG
493 else {
494 ObjectFile *objfile = nullptr;
495 if (module_sp) {
496 if (SymbolFile *symbol_file = module_sp->GetSymbolFile())
497 objfile = symbol_file->GetObjectFile();
498 }
499 if (objfile) {
500 Debugger::ReportWarning(llvm::formatv(
501 "inlined block {0:x} doesn't have a range that contains file "
502 "address {1:x} in {2}",
503 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress(),
504 objfile->GetFileSpec().GetPath()));
505 } else {
506 Debugger::ReportWarning(llvm::formatv(
507 "inlined block {0:x} doesn't have a range that contains file "
508 "address {1:x}",
509 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()));
510 }
511 }
512#endif
513 }
514 }
515 }
516
517 return false;
518}
519
521 if (function) {
522 if (block) {
523 // If this symbol context has a block, check to see if this block is
524 // itself, or is contained within a block with inlined function
525 // information. If so, then the inlined block is the block that defines
526 // the function.
527 Block *inlined_block = block->GetContainingInlinedBlock();
528 if (inlined_block)
529 return inlined_block;
530
531 // The block in this symbol context is not inside an inlined block, so
532 // the block that defines the function is the function's top level block,
533 // which is returned below.
534 }
535
536 // There is no block information in this symbol context, so we must assume
537 // that the block that is desired is the top level block of the function
538 // itself.
539 return &function->GetBlock(true);
540 }
541 return nullptr;
542}
543
546
547 if (Block *function_block = GetFunctionBlock())
548 if (CompilerDeclContext decl_ctx = function_block->GetDeclContext())
549 lang_type = decl_ctx.GetLanguage();
550
551 if (lang_type == eLanguageTypeUnknown)
552 lang_type = GetLanguage();
553
554 if (auto *lang = Language::FindPlugin(lang_type))
555 return lang->GetInstanceVariableName();
556
557 return {};
558}
559
560void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
561 Block *curr_block = block;
562 bool isInlinedblock = false;
563 if (curr_block != nullptr &&
564 curr_block->GetContainingInlinedBlock() != nullptr)
565 isInlinedblock = true;
566
567 // Find all types that match the current block if we have one and put them
568 // first in the list. Keep iterating up through all blocks.
569 while (curr_block != nullptr && !isInlinedblock) {
570 type_map.ForEach(
571 [curr_block, &type_list](const lldb::TypeSP &type_sp) -> bool {
572 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
573 if (scs && curr_block == scs->CalculateSymbolContextBlock())
574 type_list.Insert(type_sp);
575 return true; // Keep iterating
576 });
577
578 // Remove any entries that are now in "type_list" from "type_map" since we
579 // can't remove from type_map while iterating
580 type_list.ForEach([&type_map](const lldb::TypeSP &type_sp) -> bool {
581 type_map.Remove(type_sp);
582 return true; // Keep iterating
583 });
584 curr_block = curr_block->GetParent();
585 }
586 // Find all types that match the current function, if we have onem, and put
587 // them next in the list.
588 if (function != nullptr && !type_map.Empty()) {
589 const size_t old_type_list_size = type_list.GetSize();
590 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
591 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
592 if (scs && function == scs->CalculateSymbolContextFunction())
593 type_list.Insert(type_sp);
594 return true; // Keep iterating
595 });
596
597 // Remove any entries that are now in "type_list" from "type_map" since we
598 // can't remove from type_map while iterating
599 const size_t new_type_list_size = type_list.GetSize();
600 if (new_type_list_size > old_type_list_size) {
601 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
602 type_map.Remove(type_list.GetTypeAtIndex(i));
603 }
604 }
605 // Find all types that match the current compile unit, if we have one, and
606 // put them next in the list.
607 if (comp_unit != nullptr && !type_map.Empty()) {
608 const size_t old_type_list_size = type_list.GetSize();
609
610 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
611 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
612 if (scs && comp_unit == scs->CalculateSymbolContextCompileUnit())
613 type_list.Insert(type_sp);
614 return true; // Keep iterating
615 });
616
617 // Remove any entries that are now in "type_list" from "type_map" since we
618 // can't remove from type_map while iterating
619 const size_t new_type_list_size = type_list.GetSize();
620 if (new_type_list_size > old_type_list_size) {
621 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
622 type_map.Remove(type_list.GetTypeAtIndex(i));
623 }
624 }
625 // Find all types that match the current module, if we have one, and put them
626 // next in the list.
627 if (module_sp && !type_map.Empty()) {
628 const size_t old_type_list_size = type_list.GetSize();
629 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
630 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
631 if (scs && module_sp == scs->CalculateSymbolContextModule())
632 type_list.Insert(type_sp);
633 return true; // Keep iterating
634 });
635 // Remove any entries that are now in "type_list" from "type_map" since we
636 // can't remove from type_map while iterating
637 const size_t new_type_list_size = type_list.GetSize();
638 if (new_type_list_size > old_type_list_size) {
639 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
640 type_map.Remove(type_list.GetTypeAtIndex(i));
641 }
642 }
643 // Any types that are left get copied into the list an any order.
644 if (!type_map.Empty()) {
645 type_map.ForEach([&type_list](const lldb::TypeSP &type_sp) -> bool {
646 type_list.Insert(type_sp);
647 return true; // Keep iterating
648 });
649 }
650}
651
654 if (function) {
655 if (block) {
656 Block *inlined_block = block->GetContainingInlinedBlock();
657
658 if (inlined_block) {
659 const InlineFunctionInfo *inline_info =
660 inlined_block->GetInlinedFunctionInfo();
661 if (inline_info)
662 return inline_info->GetName();
663 }
664 }
665 return function->GetMangled().GetName(preference);
666 } else if (symbol && symbol->ValueIsAddress()) {
667 return symbol->GetMangled().GetName(preference);
668 } else {
669 // No function, return an empty string.
670 return ConstString();
671 }
672}
673
676 Address start_addr;
677 if (block) {
678 Block *inlined_block = block->GetContainingInlinedBlock();
679 if (inlined_block) {
680 if (inlined_block->GetStartAddress(start_addr)) {
682 return line_entry;
683 }
684 return LineEntry();
685 }
686 }
687
688 if (function) {
692 return line_entry;
693 }
694 return LineEntry();
695}
696
698 AddressRange &range,
699 Status &error) {
700 if (!line_entry.IsValid()) {
701 error.SetErrorString("Symbol context has no line table.");
702 return false;
703 }
704
705 range = line_entry.range;
706 if (line_entry.line > end_line) {
707 error.SetErrorStringWithFormat(
708 "end line option %d must be after the current line: %d", end_line,
710 return false;
711 }
712
713 uint32_t line_index = 0;
714 bool found = false;
715 while (true) {
716 LineEntry this_line;
717 line_index = comp_unit->FindLineEntry(line_index, line_entry.line, nullptr,
718 false, &this_line);
719 if (line_index == UINT32_MAX)
720 break;
721 if (LineEntry::Compare(this_line, line_entry) == 0) {
722 found = true;
723 break;
724 }
725 }
726
727 LineEntry end_entry;
728 if (!found) {
729 // Can't find the index of the SymbolContext's line entry in the
730 // SymbolContext's CompUnit.
731 error.SetErrorString(
732 "Can't find the current line entry in the CompUnit - can't process "
733 "the end-line option");
734 return false;
735 }
736
737 line_index = comp_unit->FindLineEntry(line_index, end_line, nullptr, false,
738 &end_entry);
739 if (line_index == UINT32_MAX) {
740 error.SetErrorStringWithFormat(
741 "could not find a line table entry corresponding "
742 "to end line number %d",
743 end_line);
744 return false;
745 }
746
747 Block *func_block = GetFunctionBlock();
748 if (func_block && func_block->GetRangeIndexContainingAddress(
749 end_entry.range.GetBaseAddress()) == UINT32_MAX) {
750 error.SetErrorStringWithFormat(
751 "end line number %d is not contained within the current function.",
752 end_line);
753 return false;
754 }
755
756 lldb::addr_t range_size = end_entry.range.GetBaseAddress().GetFileAddress() -
758 range.SetByteSize(range_size);
759 return true;
760}
761
763 Status &error) {
764 error.Clear();
765
766 if (!target_sp) {
767 return nullptr;
768 }
769
770 Target &target = *target_sp;
771 Module *module = module_sp.get();
772
773 auto ProcessMatches = [this, &name, &target,
774 module](const SymbolContextList &sc_list,
775 Status &error) -> const Symbol * {
776 llvm::SmallVector<const Symbol *, 1> external_symbols;
777 llvm::SmallVector<const Symbol *, 1> internal_symbols;
778 for (const SymbolContext &sym_ctx : sc_list) {
779 if (sym_ctx.symbol) {
780 const Symbol *symbol = sym_ctx.symbol;
781 const Address sym_address = symbol->GetAddress();
782
783 if (sym_address.IsValid()) {
784 switch (symbol->GetType()) {
785 case eSymbolTypeData:
792 // If the demangled name was synthesized, then don't use it for
793 // expressions. Only let the symbol match if the mangled named
794 // matches for these symbols.
795 if (symbol->GetMangled().GetMangledName() != name)
796 break;
797 }
798 if (symbol->IsExternal()) {
799 external_symbols.push_back(symbol);
800 } else {
801 internal_symbols.push_back(symbol);
802 }
803 break;
805 ConstString reexport_name = symbol->GetReExportedSymbolName();
806 if (reexport_name) {
807 ModuleSP reexport_module_sp;
808 ModuleSpec reexport_module_spec;
809 reexport_module_spec.GetPlatformFileSpec() =
811 if (reexport_module_spec.GetPlatformFileSpec()) {
812 reexport_module_sp =
813 target.GetImages().FindFirstModule(reexport_module_spec);
814 if (!reexport_module_sp) {
815 reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
816 reexport_module_sp =
817 target.GetImages().FindFirstModule(reexport_module_spec);
818 }
819 }
820 // Don't allow us to try and resolve a re-exported symbol if it
821 // is the same as the current symbol
822 if (name == symbol->GetReExportedSymbolName() &&
823 module == reexport_module_sp.get())
824 return nullptr;
825
827 error);
828 }
829 } break;
830
831 case eSymbolTypeCode: // We already lookup functions elsewhere
833 case eSymbolTypeLocal:
834 case eSymbolTypeParam:
842 case eSymbolTypeBlock:
853 break;
854 }
855 }
856 }
857 }
858
859 if (external_symbols.size() > 1) {
860 StreamString ss;
861 ss.Printf("Multiple external symbols found for '%s'\n", name.AsCString());
862 for (const Symbol *symbol : external_symbols) {
864 }
865 ss.PutChar('\n');
866 error.SetErrorString(ss.GetData());
867 return nullptr;
868 } else if (external_symbols.size()) {
869 return external_symbols[0];
870 } else if (internal_symbols.size() > 1) {
871 StreamString ss;
872 ss.Printf("Multiple internal symbols found for '%s'\n", name.AsCString());
873 for (const Symbol *symbol : internal_symbols) {
875 ss.PutChar('\n');
876 }
877 error.SetErrorString(ss.GetData());
878 return nullptr;
879 } else if (internal_symbols.size()) {
880 return internal_symbols[0];
881 } else {
882 return nullptr;
883 }
884 };
885
886 if (module) {
887 SymbolContextList sc_list;
888 module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
889 const Symbol *const module_symbol = ProcessMatches(sc_list, error);
890
891 if (!error.Success()) {
892 return nullptr;
893 } else if (module_symbol) {
894 return module_symbol;
895 }
896 }
897
898 {
899 SymbolContextList sc_list;
901 sc_list);
902 const Symbol *const target_symbol = ProcessMatches(sc_list, error);
903
904 if (!error.Success()) {
905 return nullptr;
906 } else if (target_symbol) {
907 return target_symbol;
908 }
909 }
910
911 return nullptr; // no error; we just didn't find anything
912}
913
914//
915// SymbolContextSpecifier
916//
917
919 : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
920 m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
921 m_address_range_up(), m_type(eNothingSpecified) {}
922
924
926 SpecificationType type) {
927 bool return_value = true;
928 switch (type) {
930 Clear();
931 break;
933 m_start_line = line_no;
935 break;
937 m_end_line = line_no;
939 break;
940 default:
941 return_value = false;
942 break;
943 }
944 return return_value;
945}
946
947bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
948 SpecificationType type) {
949 bool return_value = true;
950 switch (type) {
952 Clear();
953 break;
954 case eModuleSpecified: {
955 // See if we can find the Module, if so stick it in the SymbolContext.
956 FileSpec module_file_spec(spec_string);
957 ModuleSpec module_spec(module_file_spec);
958 lldb::ModuleSP module_sp =
959 m_target_sp ? m_target_sp->GetImages().FindFirstModule(module_spec)
960 : nullptr;
962 if (module_sp)
963 m_module_sp = module_sp;
964 else
965 m_module_spec.assign(spec_string);
966 } break;
967 case eFileSpecified:
968 // CompUnits can't necessarily be resolved here, since an inlined function
969 // might show up in a number of CompUnits. Instead we just convert to a
970 // FileSpec and store it away.
971 m_file_spec_up = std::make_unique<FileSpec>(spec_string);
973 break;
975 if ((return_value = llvm::to_integer(spec_string, m_start_line)))
977 break;
979 if ((return_value = llvm::to_integer(spec_string, m_end_line)))
981 break;
983 m_function_spec.assign(spec_string);
985 break;
987 Clear();
988 m_class_name.assign(spec_string);
990 break;
992 // Not specified yet...
993 break;
994 }
995
996 return return_value;
997}
998
1000 m_module_spec.clear();
1001 m_file_spec_up.reset();
1002 m_function_spec.clear();
1003 m_class_name.clear();
1004 m_start_line = 0;
1005 m_end_line = 0;
1006 m_address_range_up.reset();
1007
1009}
1010
1013 return true;
1014
1015 // Only compare targets if this specifier has one and it's not the Dummy
1016 // target. Otherwise if a specifier gets made in the dummy target and
1017 // copied over we'll artificially fail the comparision.
1018 if (m_target_sp && !m_target_sp->IsDummyTarget() &&
1019 m_target_sp != sc.target_sp)
1020 return false;
1021
1022 if (m_type & eModuleSpecified) {
1023 if (sc.module_sp) {
1024 if (m_module_sp.get() != nullptr) {
1025 if (m_module_sp.get() != sc.module_sp.get())
1026 return false;
1027 } else {
1028 FileSpec module_file_spec(m_module_spec);
1029 if (!FileSpec::Match(module_file_spec, sc.module_sp->GetFileSpec()))
1030 return false;
1031 }
1032 }
1033 }
1034 if (m_type & eFileSpecified) {
1035 if (m_file_spec_up) {
1036 // If we don't have a block or a comp_unit, then we aren't going to match
1037 // a source file.
1038 if (sc.block == nullptr && sc.comp_unit == nullptr)
1039 return false;
1040
1041 // Check if the block is present, and if so is it inlined:
1042 bool was_inlined = false;
1043 if (sc.block != nullptr) {
1044 const InlineFunctionInfo *inline_info =
1046 if (inline_info != nullptr) {
1047 was_inlined = true;
1049 inline_info->GetDeclaration().GetFile()))
1050 return false;
1051 }
1052 }
1053
1054 // Next check the comp unit, but only if the SymbolContext was not
1055 // inlined.
1056 if (!was_inlined && sc.comp_unit != nullptr) {
1058 return false;
1059 }
1060 }
1061 }
1064 return false;
1065 }
1066
1067 if (m_type & eFunctionSpecified) {
1068 // First check the current block, and if it is inlined, get the inlined
1069 // function name:
1070 bool was_inlined = false;
1071 ConstString func_name(m_function_spec.c_str());
1072
1073 if (sc.block != nullptr) {
1074 const InlineFunctionInfo *inline_info =
1076 if (inline_info != nullptr) {
1077 was_inlined = true;
1078 const Mangled &name = inline_info->GetMangled();
1079 if (!name.NameMatches(func_name))
1080 return false;
1081 }
1082 }
1083 // If it wasn't inlined, check the name in the function or symbol:
1084 if (!was_inlined) {
1085 if (sc.function != nullptr) {
1086 if (!sc.function->GetMangled().NameMatches(func_name))
1087 return false;
1088 } else if (sc.symbol != nullptr) {
1089 if (!sc.symbol->GetMangled().NameMatches(func_name))
1090 return false;
1091 }
1092 }
1093 }
1094
1095 return true;
1096}
1097
1100
1101 } else {
1102 Address match_address(addr, nullptr);
1103 SymbolContext sc;
1104 m_target_sp->GetImages().ResolveSymbolContextForAddress(
1105 match_address, eSymbolContextEverything, sc);
1106 return SymbolContextMatches(sc);
1107 }
1108 return true;
1109}
1110
1112 Stream *s, lldb::DescriptionLevel level) const {
1113 char path_str[PATH_MAX + 1];
1114
1115 if (m_type == eNothingSpecified) {
1116 s->Printf("Nothing specified.\n");
1117 }
1118
1119 if (m_type == eModuleSpecified) {
1120 s->Indent();
1121 if (m_module_sp) {
1122 m_module_sp->GetFileSpec().GetPath(path_str, PATH_MAX);
1123 s->Printf("Module: %s\n", path_str);
1124 } else
1125 s->Printf("Module: %s\n", m_module_spec.c_str());
1126 }
1127
1128 if (m_type == eFileSpecified && m_file_spec_up != nullptr) {
1129 m_file_spec_up->GetPath(path_str, PATH_MAX);
1130 s->Indent();
1131 s->Printf("File: %s", path_str);
1132 if (m_type == eLineStartSpecified) {
1133 s->Printf(" from line %" PRIu64 "", (uint64_t)m_start_line);
1135 s->Printf("to line %" PRIu64 "", (uint64_t)m_end_line);
1136 else
1137 s->Printf("to end");
1138 } else if (m_type == eLineEndSpecified) {
1139 s->Printf(" from start to line %" PRIu64 "", (uint64_t)m_end_line);
1140 }
1141 s->Printf(".\n");
1142 }
1143
1144 if (m_type == eLineStartSpecified) {
1145 s->Indent();
1146 s->Printf("From line %" PRIu64 "", (uint64_t)m_start_line);
1148 s->Printf("to line %" PRIu64 "", (uint64_t)m_end_line);
1149 else
1150 s->Printf("to end");
1151 s->Printf(".\n");
1152 } else if (m_type == eLineEndSpecified) {
1153 s->Printf("From start to line %" PRIu64 ".\n", (uint64_t)m_end_line);
1154 }
1155
1156 if (m_type == eFunctionSpecified) {
1157 s->Indent();
1158 s->Printf("Function: %s.\n", m_function_spec.c_str());
1159 }
1160
1162 s->Indent();
1163 s->Printf("Class name: %s.\n", m_class_name.c_str());
1164 }
1165
1166 if (m_type == eAddressRangeSpecified && m_address_range_up != nullptr) {
1167 s->Indent();
1168 s->PutCString("Address range: ");
1169 m_address_range_up->Dump(s, m_target_sp.get(),
1172 s->PutCString("\n");
1173 }
1174}
1175
1176//
1177// SymbolContextList
1178//
1179
1181
1183
1185 m_symbol_contexts.push_back(sc);
1186}
1187
1189 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
1190 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
1191 m_symbol_contexts.push_back(*pos);
1192}
1193
1195 bool merge_symbol_into_function) {
1196 uint32_t unique_sc_add_count = 0;
1197 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
1198 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos) {
1199 if (AppendIfUnique(*pos, merge_symbol_into_function))
1200 ++unique_sc_add_count;
1201 }
1202 return unique_sc_add_count;
1203}
1204
1206 bool merge_symbol_into_function) {
1207 collection::iterator pos, end = m_symbol_contexts.end();
1208 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1209 if (*pos == sc)
1210 return false;
1211 }
1212 if (merge_symbol_into_function && sc.symbol != nullptr &&
1213 sc.comp_unit == nullptr && sc.function == nullptr &&
1214 sc.block == nullptr && !sc.line_entry.IsValid()) {
1215 if (sc.symbol->ValueIsAddress()) {
1216 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1217 // Don't merge symbols into inlined function symbol contexts
1218 if (pos->block && pos->block->GetContainingInlinedBlock())
1219 continue;
1220
1221 if (pos->function) {
1222 if (pos->function->GetAddressRange().GetBaseAddress() ==
1223 sc.symbol->GetAddressRef()) {
1224 // Do we already have a function with this symbol?
1225 if (pos->symbol == sc.symbol)
1226 return false;
1227 if (pos->symbol == nullptr) {
1228 pos->symbol = sc.symbol;
1229 return false;
1230 }
1231 }
1232 }
1233 }
1234 }
1235 }
1236 m_symbol_contexts.push_back(sc);
1237 return true;
1238}
1239
1241
1242void SymbolContextList::Dump(Stream *s, Target *target) const {
1243
1244 *s << this << ": ";
1245 s->Indent();
1246 s->PutCString("SymbolContextList");
1247 s->EOL();
1248 s->IndentMore();
1249
1250 collection::const_iterator pos, end = m_symbol_contexts.end();
1251 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1252 // pos->Dump(s, target);
1253 pos->GetDescription(s, eDescriptionLevelVerbose, target);
1254 }
1255 s->IndentLess();
1256}
1257
1259 if (idx < m_symbol_contexts.size()) {
1260 sc = m_symbol_contexts[idx];
1261 return true;
1262 }
1263 return false;
1264}
1265
1267 if (idx < m_symbol_contexts.size()) {
1268 m_symbol_contexts.erase(m_symbol_contexts.begin() + idx);
1269 return true;
1270 }
1271 return false;
1272}
1273
1274uint32_t SymbolContextList::GetSize() const { return m_symbol_contexts.size(); }
1275
1276bool SymbolContextList::IsEmpty() const { return m_symbol_contexts.empty(); }
1277
1278uint32_t SymbolContextList::NumLineEntriesWithLine(uint32_t line) const {
1279 uint32_t match_count = 0;
1280 const size_t size = m_symbol_contexts.size();
1281 for (size_t idx = 0; idx < size; ++idx) {
1282 if (m_symbol_contexts[idx].line_entry.line == line)
1283 ++match_count;
1284 }
1285 return match_count;
1286}
1287
1289 Target *target) const {
1290 const size_t size = m_symbol_contexts.size();
1291 for (size_t idx = 0; idx < size; ++idx)
1292 m_symbol_contexts[idx].GetDescription(s, level, target);
1293}
1294
1296 const SymbolContextList &rhs) {
1297 const uint32_t size = lhs.GetSize();
1298 if (size != rhs.GetSize())
1299 return false;
1300
1301 SymbolContext lhs_sc;
1302 SymbolContext rhs_sc;
1303 for (uint32_t i = 0; i < size; ++i) {
1304 lhs.GetContextAtIndex(i, lhs_sc);
1305 rhs.GetContextAtIndex(i, rhs_sc);
1306 if (lhs_sc != rhs_sc)
1307 return false;
1308 }
1309 return true;
1310}
1311
1313 const SymbolContextList &rhs) {
1314 return !(lhs == rhs);
1315}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:349
A section + offset based address range class.
Definition: AddressRange.h:25
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
bool Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style=Address::DumpStyleInvalid) const
Dump a description of this object to a Stream.
void Clear()
Clear the object's state.
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
Definition: AddressRange.h:237
A section + offset based address class.
Definition: Address.h:59
void Clear()
Clear the object's state.
Definition: Address.h:178
@ DumpStyleFileAddress
Display as the file address (if any).
Definition: Address.h:84
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition: Address.h:90
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Definition: Address.h:96
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false) const
Dump a description of this object to a Stream.
Definition: Address.cpp:406
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const
Definition: Address.cpp:907
A class that describes a single lexical block.
Definition: Block.h:41
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition: Block.cpp:136
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:208
bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range)
Definition: Block.cpp:303
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition: Block.h:276
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Definition: Block.cpp:250
Block * GetParent() const
Get the parent block.
Definition: Block.cpp:202
bool GetStartAddress(Address &addr)
Definition: Block.cpp:317
uint32_t GetRangeIndexContainingAddress(const Address &addr)
Definition: Block.cpp:286
A class that describes a compilation unit.
Definition: CompileUnit.h:41
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry)
Find the line entry by line and optional inlined file spec.
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
Definition: CompileUnit.cpp:54
lldb::LanguageType GetLanguage()
Represents a generic declaration context in a program.
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:182
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:205
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1532
uint32_t GetLine() const
Get accessor for the declaration line number.
Definition: Declaration.h:120
uint16_t GetColumn() const
Get accessor for the declaration column number.
Definition: Declaration.h:127
FileSpec & GetFile()
Get accessor for file specification.
Definition: Declaration.h:107
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
A file utility class.
Definition: FileSpec.h:56
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition: FileSpec.cpp:301
void ClearDirectory()
Clear the directory in this object.
Definition: FileSpec.cpp:360
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition: Function.cpp:53
A class that describes a function.
Definition: Function.h:399
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
Definition: Function.cpp:389
const AddressRange & GetAddressRange()
Definition: Function.h:447
ConstString GetName() const
Definition: Function.cpp:679
const Mangled & GetMangled() const
Definition: Function.h:528
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
Definition: Function.cpp:525
lldb::LanguageType GetLanguage() const
Definition: Function.cpp:668
ConstString GetNameNoArguments() const
Definition: Function.cpp:683
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:370
A class that describes information for an inlined function.
Definition: Function.h:125
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition: Function.cpp:108
ConstString GetName() const
Definition: Function.cpp:96
Mangled & GetMangled()
Get accessor for the mangled name object.
Definition: Function.cpp:114
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:53
A class that handles mangled names.
Definition: Mangled.h:33
bool NameMatches(ConstString name) const
Check if "name" matches either the mangled or demangled name.
Definition: Mangled.h:171
lldb::LanguageType GuessLanguage() const
Try to guess the language from the mangling.
Definition: Mangled.cpp:379
ConstString & GetMangledName()
Mangled name get accessor.
Definition: Mangled.h:145
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
Definition: Mangled.cpp:323
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:614
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:500
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:65
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1364
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:44
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:274
An error handling class.
Definition: Status.h:44
const char * GetData() const
Definition: StreamString.h:43
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
size_t PutChar(char ch)
Definition: Stream.cpp:104
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
Defines a list of symbol context objects.
collection m_symbol_contexts
The list of symbol contexts.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
const_iterator end() const
bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function)
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
uint32_t NumLineEntriesWithLine(uint32_t line) const
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void Clear()
Clear the object's state.
SymbolContextList()
Default constructor.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
virtual Function * CalculateSymbolContextFunction()
virtual CompileUnit * CalculateSymbolContextCompileUnit()
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
virtual Block * CalculateSymbolContextBlock()
virtual lldb::ModuleSP CalculateSymbolContextModule()
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
bool AddressMatches(lldb::addr_t addr)
std::unique_ptr< AddressRange > m_address_range_up
std::unique_ptr< FileSpec > m_file_spec_up
bool AddLineSpecification(uint32_t line_no, SpecificationType type)
bool AddSpecification(const char *spec_string, SpecificationType type)
bool SymbolContextMatches(const SymbolContext &sc)
SymbolContextSpecifier(const lldb::TargetSP &target_sp)
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
LineEntry GetFunctionStartLineEntry() const
Get the line entry that corresponds to the function.
const Symbol * FindBestGlobalDataSymbol(ConstString name, Status &error)
Find the best global data symbol visible from this context.
lldb::LanguageType GetLanguage() const
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name) const
Dump the stop context in this object to a Stream.
Function * function
The Function for a given query.
Block * GetFunctionBlock()
Find a block that defines the function represented by this symbol context.
llvm::StringRef GetInstanceVariableName()
Determines the name of the instance variable for the this decl context.
bool GetParentOfInlinedScope(const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &inlined_frame_addr) const
Find the block containing the inlined block that contains this block.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
uint32_t GetResolvedMask() const
void Clear(bool clear_target)
Clear the object's state.
Variable * variable
The global variable matching the given query.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
lldb::TargetSP target_sp
The Target for a given query.
LineEntry line_entry
The LineEntry for a given query.
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error)
SymbolContext()
Default constructor.
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:49
bool ValueIsAddress() const
Definition: Symbol.cpp:167
bool IsExternal() const
Definition: Symbol.h:194
bool GetDemangledNameIsSynthesized() const
Definition: Symbol.h:223
Mangled & GetMangled()
Definition: Symbol.h:145
lldb::LanguageType GetLanguage() const
Definition: Symbol.h:137
Address & GetAddressRef()
Definition: Symbol.h:71
ConstString GetReExportedSymbolName() const
Definition: Symbol.cpp:175
lldb::addr_t GetByteSize() const
Definition: Symbol.cpp:464
ConstString GetName() const
Definition: Symbol.cpp:544
lldb::SymbolType GetType() const
Definition: Symbol.h:167
Address GetAddress() const
Definition: Symbol.h:87
FileSpec GetReExportedSymbolSharedLibrary() const
Definition: Symbol.cpp:189
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
Definition: Symbol.cpp:227
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:967
uint32_t GetSize() const
Definition: TypeList.cpp:60
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition: TypeList.cpp:78
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
void Insert(const lldb::TypeSP &type)
Definition: TypeList.cpp:27
bool Empty() const
Definition: TypeMap.cpp:77
bool Remove(const lldb::TypeSP &type_sp)
Definition: TypeMap.cpp:110
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition: TypeMap.cpp:94
ConstString GetName()
Definition: Type.cpp:303
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
Definition: Type.cpp:172
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition: Type.cpp:237
ConstString GetName() const
Definition: Variable.cpp:71
lldb::LanguageType GetLanguage() const
Definition: Variable.cpp:54
lldb::ValueType GetScope() const
Definition: Variable.h:66
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1022
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1016
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:436
@ eSymbolTypeUndefined
@ eSymbolTypeVariableType
@ eSymbolTypeObjCMetaClass
@ eSymbolTypeReExported
@ eSymbolTypeObjCClass
@ eSymbolTypeObjectFile
@ eSymbolTypeTrampoline
@ eSymbolTypeResolver
@ eSymbolTypeParam
@ eSymbolTypeSourceFile
@ eSymbolTypeException
@ eSymbolTypeInvalid
@ eSymbolTypeVariable
@ eSymbolTypeAbsolute
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
@ eSymbolTypeInstrumentation
@ eSymbolTypeLocal
@ eSymbolTypeHeaderFile
@ eSymbolTypeBlock
@ eSymbolTypeCommonBlock
@ eSymbolTypeCompiler
@ eSymbolTypeLineHeader
@ eSymbolTypeObjCIVar
@ eSymbolTypeLineEntry
@ eSymbolTypeRuntime
@ eSymbolTypeScopeBegin
@ eSymbolTypeScopeEnd
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:423
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:354
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
A line table entry class.
Definition: LineEntry.h:20
FileSpec original_file
The original source file, from debug info.
Definition: LineEntry.h:142
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:146
void Clear()
Clear the object's state.
Definition: LineEntry.cpp:33
bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const
Dump a description of this object to a Stream.
Definition: LineEntry.cpp:70
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:46
static int Compare(const LineEntry &lhs, const LineEntry &rhs)
Compare two LineEntry objects.
Definition: LineEntry.cpp:157
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:139
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const
Definition: LineEntry.cpp:105
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Dumps information specific to a process that stops at this line entry to the supplied stream s.
Definition: LineEntry.cpp:50
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
#define PATH_MAX